2024-06-19 10:08:59 -05:00
|
|
|
import { ActivityPubActorType } from '@peertube/peertube-models'
|
2023-07-31 07:34:36 -05:00
|
|
|
import { WEBSERVER } from '@server/initializers/constants.js'
|
2021-12-06 09:53:00 -06:00
|
|
|
|
2024-06-19 10:08:59 -05:00
|
|
|
export function handleToNameAndHost (handle: string) {
|
2021-12-06 09:53:00 -06:00
|
|
|
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[]) {
|
2021-12-06 09:53:00 -06:00
|
|
|
return handles.map(h => handleToNameAndHost(h))
|
|
|
|
}
|
|
|
|
|
2024-06-19 10:08:59 -05:00
|
|
|
const accountType = new Set([ 'Person', 'Application', 'Group', 'Service', 'Organization' ])
|
|
|
|
export function isAccountActor (type: ActivityPubActorType) {
|
|
|
|
return accountType.has(type)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isChannelActor (type: ActivityPubActorType) {
|
|
|
|
return type === 'Group'
|
2021-12-06 09:53:00 -06:00
|
|
|
}
|