aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/utils.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-16 11:08:25 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commitefc32059d980c51793e8e9ac0fb6a885a8026f94 (patch)
treec272e63fd57a9625b53dc26ceb1b46aee35d21d3 /server/helpers/utils.ts
parentd846501818c2d29e66e6fd141789cb04fd55a437 (diff)
downloadPeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.tar.gz
PeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.tar.zst
PeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.zip
Send server announce when users upload a video
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r--server/helpers/utils.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 39957c90f..3af14a68a 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -6,6 +6,7 @@ import { CONFIG, database as db } from '../initializers'
6import { ResultList } from '../../shared' 6import { ResultList } from '../../shared'
7import { VideoResolution } from '../../shared/models/videos/video-resolution.enum' 7import { VideoResolution } from '../../shared/models/videos/video-resolution.enum'
8import { AccountInstance } from '../models/account/account-interface' 8import { AccountInstance } from '../models/account/account-interface'
9import { logger } from './logger'
9 10
10function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { 11function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) {
11 return res.type('json').status(400).end() 12 return res.type('json').status(400).end()
@@ -79,13 +80,18 @@ function resetSequelizeInstance (instance: Sequelize.Instance<any>, savedFields:
79 }) 80 })
80} 81}
81 82
82let applicationAccount: AccountInstance 83let serverAccount: AccountInstance
83async function getApplicationAccount () { 84async function getServerAccount () {
84 if (applicationAccount === undefined) { 85 if (serverAccount === undefined) {
85 applicationAccount = await db.Account.loadApplication() 86 serverAccount = await db.Account.loadApplication()
86 } 87 }
87 88
88 return Promise.resolve(applicationAccount) 89 if (!serverAccount) {
90 logger.error('Cannot load server account.')
91 process.exit(0)
92 }
93
94 return Promise.resolve(serverAccount)
89} 95}
90 96
91type SortType = { sortModel: any, sortValue: string } 97type SortType = { sortModel: any, sortValue: string }
@@ -99,6 +105,6 @@ export {
99 isSignupAllowed, 105 isSignupAllowed,
100 computeResolutionsToTranscode, 106 computeResolutionsToTranscode,
101 resetSequelizeInstance, 107 resetSequelizeInstance,
102 getApplicationAccount, 108 getServerAccount,
103 SortType 109 SortType
104} 110}