diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-26 10:45:10 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-26 11:02:04 +0200 |
commit | 2cebd797014561ebc0bfee07ee8b5d83820adb66 (patch) | |
tree | fe912e29c7321c3c29e94691520615a741899e71 /server/helpers | |
parent | c1e791bad0b079af67398f6407221e6dcbb573dd (diff) | |
download | PeerTube-2cebd797014561ebc0bfee07ee8b5d83820adb66.tar.gz PeerTube-2cebd797014561ebc0bfee07ee8b5d83820adb66.tar.zst PeerTube-2cebd797014561ebc0bfee07ee8b5d83820adb66.zip |
Fix last commit
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 8 | ||||
-rw-r--r-- | server/helpers/utils.ts | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 70904af0c..338c96582 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -110,7 +110,7 @@ function isScheduleVideoUpdatePrivacyValid (value: number) { | |||
110 | ) | 110 | ) |
111 | } | 111 | } |
112 | 112 | ||
113 | function isVideoFileInfoHashValid (value: string) { | 113 | function isVideoFileInfoHashValid (value: string | null | undefined) { |
114 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) | 114 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) |
115 | } | 115 | } |
116 | 116 | ||
@@ -158,7 +158,7 @@ async function isVideoExist (id: string, res: Response) { | |||
158 | video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(id) | 158 | video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(id) |
159 | } | 159 | } |
160 | 160 | ||
161 | if (video && video !== null) { | 161 | if (video === null) { |
162 | res.status(404) | 162 | res.status(404) |
163 | .json({ error: 'Video not found' }) | 163 | .json({ error: 'Video not found' }) |
164 | .end() | 164 | .end() |
@@ -173,7 +173,7 @@ async function isVideoExist (id: string, res: Response) { | |||
173 | async function isVideoChannelOfAccountExist (channelId: number, user: UserModel, res: Response) { | 173 | async function isVideoChannelOfAccountExist (channelId: number, user: UserModel, res: Response) { |
174 | if (user.hasRight(UserRight.UPDATE_ANY_VIDEO) === true) { | 174 | if (user.hasRight(UserRight.UPDATE_ANY_VIDEO) === true) { |
175 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(channelId) | 175 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(channelId) |
176 | if (videoChannel && videoChannel !== null) { | 176 | if (videoChannel === null) { |
177 | res.status(400) | 177 | res.status(400) |
178 | .json({ error: 'Unknown video video channel on this instance.' }) | 178 | .json({ error: 'Unknown video video channel on this instance.' }) |
179 | .end() | 179 | .end() |
@@ -186,7 +186,7 @@ async function isVideoChannelOfAccountExist (channelId: number, user: UserModel, | |||
186 | } | 186 | } |
187 | 187 | ||
188 | const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, user.Account.id) | 188 | const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, user.Account.id) |
189 | if (videoChannel && videoChannel !== null) { | 189 | if (videoChannel === null) { |
190 | res.status(400) | 190 | res.status(400) |
191 | .json({ error: 'Unknown video video channel for this account.' }) | 191 | .json({ error: 'Unknown video video channel for this account.' }) |
192 | .end() | 192 | .end() |
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 7ff1556e3..cfb427570 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -144,7 +144,8 @@ let serverActor: ActorModel | |||
144 | async function getServerActor () { | 144 | async function getServerActor () { |
145 | if (serverActor === undefined) { | 145 | if (serverActor === undefined) { |
146 | const application = await ApplicationModel.load() | 146 | const application = await ApplicationModel.load() |
147 | if (!application) throw Error('Could not application.') | 147 | if (!application) throw Error('Could not load Application from database.') |
148 | |||
148 | serverActor = application.Account.Actor | 149 | serverActor = application.Account.Actor |
149 | } | 150 | } |
150 | 151 | ||