diff options
Diffstat (limited to 'server/lib/redis.ts')
-rw-r--r-- | server/lib/redis.ts | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/server/lib/redis.ts b/server/lib/redis.ts index d1d88d853..46617b07e 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts | |||
@@ -9,7 +9,8 @@ import { | |||
9 | USER_PASSWORD_CREATE_LIFETIME, | 9 | USER_PASSWORD_CREATE_LIFETIME, |
10 | VIEW_LIFETIME, | 10 | VIEW_LIFETIME, |
11 | WEBSERVER, | 11 | WEBSERVER, |
12 | TRACKER_RATE_LIMITS | 12 | TRACKER_RATE_LIMITS, |
13 | RESUMABLE_UPLOAD_SESSION_LIFETIME | ||
13 | } from '../initializers/constants' | 14 | } from '../initializers/constants' |
14 | import { CONFIG } from '../initializers/config' | 15 | import { CONFIG } from '../initializers/config' |
15 | 16 | ||
@@ -202,6 +203,30 @@ class Redis { | |||
202 | ]) | 203 | ]) |
203 | } | 204 | } |
204 | 205 | ||
206 | /* ************ Resumable uploads final responses ************ */ | ||
207 | |||
208 | setUploadSession (uploadId: string, response?: { video: { id: number, shortUUID: string, uuid: string } }) { | ||
209 | return this.setValue( | ||
210 | 'resumable-upload-' + uploadId, | ||
211 | response | ||
212 | ? JSON.stringify(response) | ||
213 | : '', | ||
214 | RESUMABLE_UPLOAD_SESSION_LIFETIME | ||
215 | ) | ||
216 | } | ||
217 | |||
218 | doesUploadSessionExist (uploadId: string) { | ||
219 | return this.exists('resumable-upload-' + uploadId) | ||
220 | } | ||
221 | |||
222 | async getUploadSession (uploadId: string) { | ||
223 | const value = await this.getValue('resumable-upload-' + uploadId) | ||
224 | |||
225 | return value | ||
226 | ? JSON.parse(value) | ||
227 | : '' | ||
228 | } | ||
229 | |||
205 | /* ************ Keys generation ************ */ | 230 | /* ************ Keys generation ************ */ |
206 | 231 | ||
207 | generateCachedRouteKey (req: express.Request) { | 232 | generateCachedRouteKey (req: express.Request) { |