57e4e1c1a9
In the future we'll stop to expose all available rates to improve users privacy
34 lines
836 B
TypeScript
34 lines
836 B
TypeScript
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
|
|
}
|