diff --git a/src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts b/src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts index 68ac34aa..efbbaa81 100644 --- a/src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts +++ b/src/graphql/mutations/CreateOrUpdateArticleReplyFeedback.ts @@ -4,7 +4,10 @@ import { assertUser, getContentDefaultStatus } from 'util/user'; import FeedbackVote from 'graphql/models/FeedbackVote'; import ArticleReply from 'graphql/models/ArticleReply'; -import type { Article, ArticleReply as ArticleReplyType } from 'rumors-db/schema/articles'; +import type { + Article, + ArticleReply as ArticleReplyType, +} from 'rumors-db/schema/articles'; import type { ArticleReplyFeedback } from 'rumors-db/schema/articlereplyfeedbacks'; import type { Reply } from 'rumors-db/schema/replies'; @@ -105,7 +108,17 @@ export default { }, async resolve( rootValue, - { articleId, replyId, vote, comment }, + { + articleId, + replyId, + vote, + comment, + }: { + articleId: string; + replyId: string; + vote: 1 | 0 | -1; + comment?: string | null; + }, { user, loaders } ) { assertUser(user); @@ -152,23 +165,19 @@ export default { // Fill in reply & article reply author ID // - const [ - { userId: replyUserId }, - article, - ] = await loaders.docLoader.loadMany([ - { - index: 'replies', - id: replyId, - }, - { - index: 'articles', - id: articleId, - }, - ]) as [Reply, Article]; + const [{ userId: replyUserId }, article] = + (await loaders.docLoader.loadMany([ + { + index: 'replies', + id: replyId, + }, + { + index: 'articles', + id: articleId, + }, + ])) as [Reply, Article]; - const ar = article.articleReplies.find( - ar => ar.replyId === replyId - ); + const ar = article.articleReplies.find((ar) => ar.replyId === replyId); // Make typescript happy if (!ar) { diff --git a/src/scripts/blockUser.ts b/src/scripts/blockUser.ts index 987b5888..f5f793c5 100644 --- a/src/scripts/blockUser.ts +++ b/src/scripts/blockUser.ts @@ -167,7 +167,9 @@ async function processArticleReplies(userId: string) { }, }; - const articleRepliesToProcess: Array = []; + const articleRepliesToProcess: Array< + Article['articleReplies'][0] & { articleId: string } + > = []; for await (const { _id, _source: { articleReplies }, @@ -221,7 +223,10 @@ async function processArticleReplyFeedbacks(userId: string) { for await (const { _source: { articleId, replyId }, - } of getAllDocs('articlereplyfeedbacks', NORMAL_FEEDBACK_QUERY)) { + } of getAllDocs( + 'articlereplyfeedbacks', + NORMAL_FEEDBACK_QUERY + )) { articleReplyIdsWithNormalFeedbacks.push({ articleId, replyId }); } @@ -309,7 +314,13 @@ async function processArticles(userId: string) { console.log('Article status update result', updateByQueryResult); } -async function main({ userId, blockedReason }: { userId: string; blockedReason: string }) { +async function main({ + userId, + blockedReason, +}: { + userId: string; + blockedReason: string; +}) { await writeBlockedReasonToUser(userId, blockedReason); await processArticles(userId); await processReplyRequests(userId);