diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-16 11:08:25 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | efc32059d980c51793e8e9ac0fb6a885a8026f94 (patch) | |
tree | c272e63fd57a9625b53dc26ceb1b46aee35d21d3 /server/helpers/utils.ts | |
parent | d846501818c2d29e66e6fd141789cb04fd55a437 (diff) | |
download | PeerTube-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.ts | 18 |
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' | |||
6 | import { ResultList } from '../../shared' | 6 | import { ResultList } from '../../shared' |
7 | import { VideoResolution } from '../../shared/models/videos/video-resolution.enum' | 7 | import { VideoResolution } from '../../shared/models/videos/video-resolution.enum' |
8 | import { AccountInstance } from '../models/account/account-interface' | 8 | import { AccountInstance } from '../models/account/account-interface' |
9 | import { logger } from './logger' | ||
9 | 10 | ||
10 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { | 11 | function 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 | ||
82 | let applicationAccount: AccountInstance | 83 | let serverAccount: AccountInstance |
83 | async function getApplicationAccount () { | 84 | async 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 | ||
91 | type SortType = { sortModel: any, sortValue: string } | 97 | type 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 | } |