1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Add ability for instances to follow any actor

This commit is contained in:
Chocobozzz 2021-07-20 14:15:15 +02:00
parent 7f28f2ddba
commit 4d029ef8ec
No known key found for this signature in database
GPG key ID: 583A612D890159BE
45 changed files with 884 additions and 528 deletions

View file

@ -1,4 +1,4 @@
import { exists } from './misc'
import { exists, isArray } from './misc'
import { FollowState } from '@shared/models'
function isFollowStateValid (value: FollowState) {
@ -7,8 +7,24 @@ function isFollowStateValid (value: FollowState) {
return value === 'pending' || value === 'accepted'
}
function isRemoteHandleValid (value: string) {
if (!exists(value)) return false
if (typeof value !== 'string') return false
return value.includes('@')
}
function isEachUniqueHandleValid (handles: string[]) {
return isArray(handles) &&
handles.every(handle => {
return isRemoteHandleValid(handle) && handles.indexOf(handle) === handles.lastIndexOf(handle)
})
}
// ---------------------------------------------------------------------------
export {
isFollowStateValid
isFollowStateValid,
isRemoteHandleValid,
isEachUniqueHandleValid
}

View file

@ -19,7 +19,6 @@ function isHostValid (host: string) {
function isEachUniqueHostValid (hosts: string[]) {
return isArray(hosts) &&
hosts.length !== 0 &&
hosts.every(host => {
return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
})