X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Fupdate-host.ts;h=759443623ef74950c8cdfcb65cc9eb5b5422b6f8;hb=3daf400219fe8cc94025886ba14876bc59a45244;hp=7c46dc52b17d0f3a6a76864262680fea6c6e6605;hpb=571389d43b8fc8aaf27e77c06f19b320b08dbbc9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 7c46dc52b..759443623 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts @@ -1,15 +1,19 @@ import { database as db } from '../server/initializers/database' -// import { hasFriends } from '../server/lib/friends' +import { getServerAccount } from '../server/helpers/utils' db.init(true) .then(() => { - // FIXME: check if has followers - // return hasFriends() - return true + return getServerAccount() }) - .then(itHasFriends => { - if (itHasFriends === true) { - console.log('Cannot update host because you have friends!') + .then(serverAccount => { + return db.AccountFollow.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined) + }) + .then(res => { + return res.total > 0 + }) + .then(hasFollowing => { + if (hasFollowing === true) { + console.log('Cannot update host because you follow other servers!') process.exit(-1) }