blob: 2bd5bb06649fc178b5e5080f8b8b371da740eb6c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import { ActivityAudience } from '../../../shared/models/activitypub'
import { ACTIVITY_PUB } from '../../initializers/constants'
import { MActorFollowersUrl } from '../../types/models'
function getAudience (actorSender: MActorFollowersUrl, isPublic = true) {
return buildAudience([ actorSender.followersUrl ], isPublic)
}
function buildAudience (followerUrls: string[], isPublic = true) {
let to: string[] = []
let cc: string[] = []
if (isPublic) {
to = [ ACTIVITY_PUB.PUBLIC ]
cc = followerUrls
} else { // Unlisted
to = []
cc = []
}
return { to, cc }
}
function audiencify<T> (object: T, audience: ActivityAudience) {
return Object.assign(object, audience)
}
// ---------------------------------------------------------------------------
export {
buildAudience,
getAudience,
audiencify
}
|