X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Fupdate-host.ts;h=3fb5f1972dd85b6491fed4d9979533743dbeefe7;hb=d169c4ad46291b8895498da268800bec650b43f2;hp=06d84a658ca416107372efec502ac8424b62525c;hpb=fdbda9e3d6564ec908733c7019305f6a3c363a9f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 06d84a658..3fb5f1972 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts @@ -1,20 +1,26 @@ -import * as Promise from 'bluebird' +import { getServerActor } from '../server/helpers/utils' +import { initDatabaseModels } from '../server/initializers' +import { ActorFollowModel } from '../server/models/activitypub/actor-follow' +import { VideoModel } from '../server/models/video/video' -import { database as db } from '../server/initializers/database' -import { hasFriends } from '../server/lib/friends' - -db.init(true) +initDatabaseModels(true) .then(() => { - return hasFriends() + return getServerActor() + }) + .then(serverAccount => { + return ActorFollowModel.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined) + }) + .then(res => { + return res.total > 0 }) - .then(itHasFriends => { - if (itHasFriends === true) { - console.log('Cannot update host because you have friends!') + .then(hasFollowing => { + if (hasFollowing === true) { + console.log('Cannot update host because you follow other servers!') process.exit(-1) } console.log('Updating torrent files.') - return db.Video.list() + return VideoModel.list() }) .then(videos => { const tasks: Promise[] = []