PeerTube/server/core/helpers/actors.ts

23 lines
685 B
TypeScript
Raw Normal View History

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