2024-06-19 17:08:59 +02:00
|
|
|
import { ActivityPubActorType } from '@peertube/peertube-models'
|
2023-07-31 14:34:36 +02:00
|
|
|
import { WEBSERVER } from '@server/initializers/constants.js'
|
2021-12-06 16:53:00 +01:00
|
|
|
|
2024-06-19 17:08:59 +02:00
|
|
|
export function handleToNameAndHost (handle: string) {
|
2021-12-06 16:53:00 +01:00
|
|
|
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[]) {
|
2021-12-06 16:53:00 +01:00
|
|
|
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'
|
2021-12-06 16:53:00 +01:00
|
|
|
}
|