Skip to content

Commit

Permalink
fix: don't show non visible community picks (#2139)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelchris authored Aug 13, 2024
1 parent f2a6fa8 commit 6439310
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions __tests__/submissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,37 @@ describe('mutation submitArticle', () => {
});
});

it('should reject if the post exist but not visible', async () => {
loggedUser = '1';
const request = 'http://p8.com';
await saveFixtures(con, Source, sourcesFixture);
await saveFixtures(con, ArticlePost, [
{
id: 'pdeleted',
shortId: 'spdeleted',
title: 'PDeleted',
url: request,
canonicalUrl: request,
score: 0,
sourceId: 'a',
createdAt: new Date('2021-09-22T07:15:51.247Z'),
tagsStr: 'javascript,webdev',
visible: false,
},
]);

const res = await client.mutate(MUTATION, { variables: { url: request } });
expect(res.errors).toBeFalsy();
expect(res.data).toEqual({
submitArticle: {
result: 'rejected',
reason: SubmissionFailErrorMessage.POST_DELETED,
post: null,
submission: null,
},
});
});

it('should not allow invalid urls', async () => {
loggedUser = '1';
const request = 'test/sample/url';
Expand Down
2 changes: 1 addition & 1 deletion src/schema/submissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const resolvers: IResolvers<unknown, BaseContext> = traceResolvers<
.getRepository(ArticlePost)
.findOneBy([{ url }, { canonicalUrl: url }]);
if (existingPost) {
if (existingPost.deleted) {
if (existingPost.deleted || !existingPost.visible) {
return {
result: 'rejected',
reason: SubmissionFailErrorMessage.POST_DELETED,
Expand Down

0 comments on commit 6439310

Please sign in to comment.