PeerTube/server/core/helpers/actors.ts

23 lines
685 B
TypeScript
Raw Normal View History

2024-06-19 10:08:59 -05:00
import { ActivityPubActorType } from '@peertube/peertube-models'
import { WEBSERVER } from '@server/initializers/constants.js'
2024-06-19 10:08:59 -05:00
export function handleToNameAndHost (handle: string) {
let [ name, host ] = handle.split('@')
if (host === WEBSERVER.HOST) host = null
return { name, host, handle }
}
2024-06-19 10:08:59 -05:00
export function handlesToNameAndHost (handles: string[]) {
return handles.map(h => handleToNameAndHost(h))
}
2024-06-19 10:37:27 -05:00
const accountType = new Set([ 'Person', 'Application', 'Service', 'Organization' ])
2024-06-19 10:08:59 -05:00
export function isAccountActor (type: ActivityPubActorType) {
return accountType.has(type)
}
export function isChannelActor (type: ActivityPubActorType) {
return type === 'Group'
}