Fix global search nsfw policy when logged in
authorChocobozzz <me@florianbigard.com>
Mon, 15 Jun 2020 12:40:35 +0000 (14:40 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 15 Jun 2020 13:04:51 +0000 (15:04 +0200)
server/controllers/api/search.ts

index e35a7346e4e905eea7e7699e49a3c8f28a828a8d..a0da5e30cfbee0e3dff45556d7eb762bfee76437 100644 (file)
@@ -173,7 +173,11 @@ async function searchVideosIndex (query: VideosSearchQuery, res: express.Respons
 
   // Use the default instance NSFW policy if not specified
   if (!body.nsfw) {
-    body.nsfw = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list'
+    const nsfwPolicy = res.locals.oauth
+      ? res.locals.oauth.token.User.nsfwPolicy
+      : CONFIG.INSTANCE.DEFAULT_NSFW_POLICY
+
+    body.nsfw = nsfwPolicy === 'do_not_list'
       ? 'false'
       : 'both'
   }