From 6d166db484e0d1f171469160f2f886f12a5b63c3 Mon Sep 17 00:00:00 2001 From: Chris Bongers Date: Mon, 27 Jul 2026 19:30:08 +0200 Subject: [PATCH] feat: log article post views via viewPost mutation Removes the Article-type exclusion in the viewPost GraphQL mutation so opening a post page/modal logs a view for every post type, unifying behavior with the /r/:postId redirector. The views worker's one-week per-user/post dedup and once-per-day streak increment make duplicate sends from both producers safe. Co-Authored-By: Claude Fable 5 --- __tests__/posts.ts | 4 ++-- src/schema/posts.ts | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/__tests__/posts.ts b/__tests__/posts.ts index 975ff5b08c..319a831869 100644 --- a/__tests__/posts.ts +++ b/__tests__/posts.ts @@ -4617,11 +4617,11 @@ describe('mutation viewPost', () => { expect(notifyView).toBeCalledTimes(1); }); - it('should should not submit view event for articles', async () => { + it('should submit view event for articles', async () => { loggedUser = '1'; const res = await client.mutate(MUTATION, { variables }); expect(res.errors).toBeFalsy(); - expect(notifyView).toBeCalledTimes(0); + expect(notifyView).toBeCalledTimes(1); }); }); diff --git a/src/schema/posts.ts b/src/schema/posts.ts index cb07c72689..056b8d205c 100644 --- a/src/schema/posts.ts +++ b/src/schema/posts.ts @@ -3408,16 +3408,14 @@ export const resolvers: IResolvers = { ): Promise => { const post = await ctx.con.getRepository(Post).findOneByOrFail({ id }); await ensureSourcePermissions(ctx, post.sourceId); - if (post.type !== PostType.Article) { - await notifyView( - ctx.log, - post.id, - ctx.userId, - ctx.req.headers['referer'], - new Date(), - post.tagsStr?.split?.(',') ?? [], - ); - } + await notifyView( + ctx.log, + post.id, + ctx.userId, + ctx.req.headers['referer'], + new Date(), + post.tagsStr?.split?.(',') ?? [], + ); return { _: true }; }, dismissPostFeedback: async (