diff --git a/backend/src/middleware/notifications/notificationsMiddleware.js b/backend/src/middleware/notifications/notificationsMiddleware.js index bab6f4e3d..dce35883d 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.js +++ b/backend/src/middleware/notifications/notificationsMiddleware.js @@ -140,9 +140,9 @@ const notifyReportFiler = async (resolve, root, args, context, resolveInfo) => { }, ) }) - } catch (error) { - debug(error) - } finally { + } catch (error) { + debug(error) + } finally { session.close() } } diff --git a/backend/src/middleware/notifications/notificationsMiddleware.spec.js b/backend/src/middleware/notifications/notificationsMiddleware.spec.js index 925f8d459..cd51d8eb9 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.spec.js +++ b/backend/src/middleware/notifications/notificationsMiddleware.spec.js @@ -34,7 +34,7 @@ const createCommentMutation = gql` } } ` -const fileReportMutation = gql ` +const fileReportMutation = gql` mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) { fileReport( resourceId: $resourceId @@ -106,7 +106,7 @@ describe('notifications', () => { reasonDescription reportedResource { __typename - ...on User { + ... on User { id name } @@ -592,7 +592,7 @@ describe('notifications', () => { }) authenticatedUser = await notifiedUser.toJson() } - const setExpectedNotificationOfReportedResource = (reportedResource) => { + const setExpectedNotificationOfReportedResource = reportedResource => { return expect.objectContaining({ data: { notifications: [ @@ -607,8 +607,8 @@ describe('notifications', () => { { reasonCategory: 'discrimination_etc', reasonDescription: 'I am free to be gay !!!', - reportedResource - } + reportedResource, + }, ], }, }, @@ -633,7 +633,7 @@ describe('notifications', () => { await neode.create('User', reportedUserOrAuthorData) resourceId = 'reportedUser' await fileReportAction() - + const expected = setExpectedNotificationOfReportedResource({ __typename: 'User', id: 'reportedUser', @@ -663,7 +663,7 @@ describe('notifications', () => { await createPostAction() resourceId = 'p47' await fileReportAction() - + const expected = setExpectedNotificationOfReportedResource({ __typename: 'Post', id: 'p47', @@ -697,7 +697,7 @@ describe('notifications', () => { await createCommentOnPostAction() resourceId = 'c47' await fileReportAction() - + const expected = setExpectedNotificationOfReportedResource({ __typename: 'Comment', id: 'c47', diff --git a/backend/src/models/Comment.js b/backend/src/models/Comment.js index c3a79c6e1..9746d2fc0 100644 --- a/backend/src/models/Comment.js +++ b/backend/src/models/Comment.js @@ -34,7 +34,12 @@ module.exports = { read: { type: 'boolean', default: false }, reason: { type: 'string', - valid: ['mentioned_in_post', 'mentioned_in_comment', 'commented_on_post', 'filed_report_on_resource'], + valid: [ + 'mentioned_in_post', + 'mentioned_in_comment', + 'commented_on_post', + 'filed_report_on_resource', + ], }, createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() }, }, diff --git a/backend/src/models/Report.js b/backend/src/models/Report.js index fbd31795d..523cfd0fd 100644 --- a/backend/src/models/Report.js +++ b/backend/src/models/Report.js @@ -59,7 +59,12 @@ module.exports = { read: { type: 'boolean', default: false }, reason: { type: 'string', - valid: ['mentioned_in_post', 'mentioned_in_comment', 'commented_on_post', 'filed_report_on_resource'], + valid: [ + 'mentioned_in_post', + 'mentioned_in_comment', + 'commented_on_post', + 'filed_report_on_resource', + ], }, }, }, diff --git a/backend/src/schema/resolvers/notifications.js b/backend/src/schema/resolvers/notifications.js index a55296a81..8451c7744 100644 --- a/backend/src/schema/resolvers/notifications.js +++ b/backend/src/schema/resolvers/notifications.js @@ -87,7 +87,7 @@ export default { `, { resourceId: args.id, - id: currentUser.id + id: currentUser.id, }, ) log(markNotificationAsReadTransactionResponse) diff --git a/backend/src/schema/resolvers/notifications.spec.js b/backend/src/schema/resolvers/notifications.spec.js index 833927da5..71a60405c 100644 --- a/backend/src/schema/resolvers/notifications.spec.js +++ b/backend/src/schema/resolvers/notifications.spec.js @@ -40,7 +40,7 @@ describe('given some notifications', () => { const categoryIds = ['cat1'] author = await factory.create('User', { id: 'author' }) user = await factory.create('User', { id: 'you' }) - const [neighbor,badWomen] = await Promise.all([ + const [neighbor, badWomen] = await Promise.all([ factory.create('User', { id: 'neighbor' }), factory.create('User', { id: 'badWomen', name: 'Mrs. Badwomen' }), factory.create('Category', { id: 'cat1' }), @@ -199,16 +199,16 @@ describe('given some notifications', () => { reasonDescription reportedResource { __typename - ...on User { + ... on User { id name } - ...on Post { + ... on Post { id title content } - ...on Comment { + ... on Comment { id content } @@ -275,15 +275,17 @@ describe('given some notifications', () => { from: { __typename: 'Report', id: 'reportOnUser', - filed: [{ - reasonCategory: 'discrimination_etc', - reasonDescription: 'This user is harassing me with bigoted remarks!', - reportedResource: { - __typename: 'User', - id: 'badWomen', - name: 'Mrs. Badwomen', + filed: [ + { + reasonCategory: 'discrimination_etc', + reasonDescription: 'This user is harassing me with bigoted remarks!', + reportedResource: { + __typename: 'User', + id: 'badWomen', + name: 'Mrs. Badwomen', + }, }, - }], + ], }, }, { @@ -293,16 +295,19 @@ describe('given some notifications', () => { from: { __typename: 'Report', id: 'reportOnPost', - filed: [{ - reasonCategory: 'other', - reasonDescription: "This shouldn't be shown to anybody else! It's my private thing!", - reportedResource: { - __typename: 'Post', - id: 'p4', - title: 'Bad Post', - content: 'I am bad content !!!', + filed: [ + { + reasonCategory: 'other', + reasonDescription: + "This shouldn't be shown to anybody else! It's my private thing!", + reportedResource: { + __typename: 'Post', + id: 'p4', + title: 'Bad Post', + content: 'I am bad content !!!', + }, }, - }], + ], }, }, { @@ -312,15 +317,17 @@ describe('given some notifications', () => { from: { __typename: 'Report', id: 'reportOnComment', - filed: [{ - reasonCategory: 'discrimination_etc', - reasonDescription: 'This user is harassing me!', - reportedResource: { - __typename: 'Comment', - id: 'c4', - content: 'I am bad content in a bad comment to a bad post !!!', + filed: [ + { + reasonCategory: 'discrimination_etc', + reasonDescription: 'This user is harassing me!', + reportedResource: { + __typename: 'Comment', + id: 'c4', + content: 'I am bad content in a bad comment to a bad post !!!', + }, }, - }], + ], }, }, ]), @@ -364,15 +371,17 @@ describe('given some notifications', () => { from: { __typename: 'Report', id: 'reportOnUser', - filed: [{ - reasonCategory: 'discrimination_etc', - reasonDescription: 'This user is harassing me with bigoted remarks!', - reportedResource: { - __typename: 'User', - id: 'badWomen', - name: 'Mrs. Badwomen', + filed: [ + { + reasonCategory: 'discrimination_etc', + reasonDescription: 'This user is harassing me with bigoted remarks!', + reportedResource: { + __typename: 'User', + id: 'badWomen', + name: 'Mrs. Badwomen', + }, }, - }], + ], }, }, { @@ -382,15 +391,17 @@ describe('given some notifications', () => { from: { __typename: 'Report', id: 'reportOnComment', - filed: [{ - reasonCategory: 'discrimination_etc', - reasonDescription: 'This user is harassing me!', - reportedResource: { - __typename: 'Comment', - id: 'c4', - content: 'I am bad content in a bad comment to a bad post !!!', + filed: [ + { + reasonCategory: 'discrimination_etc', + reasonDescription: 'This user is harassing me!', + reportedResource: { + __typename: 'Comment', + id: 'c4', + content: 'I am bad content in a bad comment to a bad post !!!', + }, }, - }], + ], }, }, ]),