From c29d97bcbb7923d3a1e2446b170840515b8acb9c Mon Sep 17 00:00:00 2001 From: Johnson Liang Date: Thu, 18 Apr 2024 13:24:37 +0800 Subject: [PATCH 1/5] feat: add awardee check to mgpAwardee --- src/graphql/resolvers/Query.js | 8 ++++++++ src/graphql/typeDefs.graphql | 2 ++ src/liff/pages/MgpAwardee.svelte | 30 ++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/graphql/resolvers/Query.js b/src/graphql/resolvers/Query.js index df0edbb2..5761b133 100644 --- a/src/graphql/resolvers/Query.js +++ b/src/graphql/resolvers/Query.js @@ -1,5 +1,6 @@ import UserArticleLink from 'src/database/models/userArticleLink'; import UserSettings from 'src/database/models/userSettings'; +import AppVariable from 'src/database/models/AppVariable'; import { groupEventQueue, expiredGroupEventQueue } from 'src/lib/queues'; import { processConnection } from '../utils/connection'; @@ -26,4 +27,11 @@ export default { orderBy, }); }, + + async isMgpAwardee(root, args, { userId }) { + const awardees = ((await AppVariable.get('mgpAwardees')) || '') + .trim() + .split('\n'); + return awardees.includes(userId); + }, }; diff --git a/src/graphql/typeDefs.graphql b/src/graphql/typeDefs.graphql index 7fa2dc03..a24b848d 100644 --- a/src/graphql/typeDefs.graphql +++ b/src/graphql/typeDefs.graphql @@ -16,6 +16,8 @@ type Query { # Get user's notification setting setting: UserSetting @auth(check: ["userId"]) + + isMgpAwardee: Boolean @auth(check: ["userId"]) } type Mutation { diff --git a/src/liff/pages/MgpAwardee.svelte b/src/liff/pages/MgpAwardee.svelte index 5e88bbfa..5c25a8d5 100644 --- a/src/liff/pages/MgpAwardee.svelte +++ b/src/liff/pages/MgpAwardee.svelte @@ -1,6 +1,20 @@ 得獎者@Cofacts x 第四屆 MyGoPen 謠言惑眾獎 -