2018-05-25 09:32:36 +00:00
|
|
|
import { ActivityAudience } from '../../../shared/models/activitypub'
|
2019-04-11 12:26:41 +00:00
|
|
|
import { ACTIVITY_PUB } from '../../initializers/constants'
|
2022-03-18 10:17:35 +00:00
|
|
|
import { MActorFollowersUrl } from '../../types/models'
|
2018-05-25 09:32:36 +00:00
|
|
|
|
2019-08-15 09:53:26 +00:00
|
|
|
function getAudience (actorSender: MActorFollowersUrl, isPublic = true) {
|
2018-05-25 09:32:36 +00:00
|
|
|
return buildAudience([ actorSender.followersUrl ], isPublic)
|
|
|
|
}
|
|
|
|
|
2018-05-28 10:13:00 +00:00
|
|
|
function buildAudience (followerUrls: string[], isPublic = true) {
|
2018-07-25 20:01:25 +00:00
|
|
|
let to: string[] = []
|
|
|
|
let cc: string[] = []
|
2018-05-25 09:32:36 +00:00
|
|
|
|
|
|
|
if (isPublic) {
|
|
|
|
to = [ ACTIVITY_PUB.PUBLIC ]
|
2018-05-28 10:13:00 +00:00
|
|
|
cc = followerUrls
|
2018-05-25 09:32:36 +00:00
|
|
|
} else { // Unlisted
|
2018-06-12 18:04:58 +00:00
|
|
|
to = []
|
|
|
|
cc = []
|
2018-05-25 09:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return { to, cc }
|
|
|
|
}
|
|
|
|
|
2018-06-12 18:04:58 +00:00
|
|
|
function audiencify<T> (object: T, audience: ActivityAudience) {
|
2022-03-23 15:14:33 +00:00
|
|
|
return { ...audience, ...object }
|
2018-05-25 09:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
buildAudience,
|
|
|
|
getAudience,
|
2022-03-18 10:17:35 +00:00
|
|
|
audiencify
|
2018-05-25 09:32:36 +00:00
|
|
|
}
|