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 (