@@ -15,6 +15,7 @@ import { promiseOrTimeout } from "../utils/promise";
15
15
import { QueryCacher } from "../utils/queryCacher" ;
16
16
import { brandingHashKey , brandingIPKey , brandingKey } from "../utils/redisKeys" ;
17
17
import * as SeedRandom from "seedrandom" ;
18
+ import { getEtag } from "../middleware/etag" ;
18
19
19
20
enum BrandingSubmissionType {
20
21
Title = "title" ,
@@ -294,6 +295,10 @@ export async function getBranding(req: Request, res: Response) {
294
295
try {
295
296
const result = await getVideoBranding ( res , videoID , service , ip , returnUserID , fetchAll ) ;
296
297
298
+ await getEtag ( "branding" , ( videoID as string ) , service )
299
+ . then ( etag => res . set ( "ETag" , etag ) )
300
+ . catch ( ( ) => null ) ;
301
+
297
302
const status = result . titles . length > 0 || result . thumbnails . length > 0 ? 200 : 404 ;
298
303
return res . status ( status ) . json ( result ) ;
299
304
} catch ( e ) {
@@ -317,6 +322,10 @@ export async function getBrandingByHashEndpoint(req: Request, res: Response) {
317
322
try {
318
323
const result = await getVideoBrandingByHash ( hashPrefix , service , ip , returnUserID , fetchAll ) ;
319
324
325
+ await getEtag ( "brandingHash" , ( hashPrefix as string ) , service )
326
+ . then ( etag => res . set ( "ETag" , etag ) )
327
+ . catch ( ( ) => null ) ;
328
+
320
329
const status = ! isEmpty ( result ) ? 200 : 404 ;
321
330
return res . status ( status ) . json ( result ) ;
322
331
} catch ( e ) {
0 commit comments