diff --git a/backend/src/models/Comment.js b/backend/src/models/Comment.js index f596c58f1..ee2f9512d 100644 --- a/backend/src/models/Comment.js +++ b/backend/src/models/Comment.js @@ -25,7 +25,7 @@ module.exports = { target: 'User', direction: 'in', }, - disabledBy: { + decidedByModerator: { type: 'relationship', relationship: 'DECIDED', target: 'User', diff --git a/backend/src/models/Post.js b/backend/src/models/Post.js index bf630c419..2d812d491 100644 --- a/backend/src/models/Post.js +++ b/backend/src/models/Post.js @@ -17,7 +17,7 @@ module.exports = { image: { type: 'string', allow: [null] }, deleted: { type: 'boolean', default: false }, disabled: { type: 'boolean', default: false }, - disabledBy: { + decidedByModerator: { type: 'relationship', relationship: 'DECIDED', target: 'User', diff --git a/backend/src/models/User.js b/backend/src/models/User.js index ac1eef5e4..329ee6f8d 100644 --- a/backend/src/models/User.js +++ b/backend/src/models/User.js @@ -42,7 +42,7 @@ module.exports = { }, }, friends: { type: 'relationship', relationship: 'FRIENDS', target: 'User', direction: 'both' }, - disabledBy: { + decidedByModerator: { type: 'relationship', relationship: 'DECIDED', target: 'User', diff --git a/backend/src/schema/resolvers/comments.js b/backend/src/schema/resolvers/comments.js index ea5943269..4867b8700 100644 --- a/backend/src/schema/resolvers/comments.js +++ b/backend/src/schema/resolvers/comments.js @@ -68,7 +68,7 @@ export default { hasOne: { author: '<-[:WROTE]-(related:User)', post: '-[:COMMENTS]->(related:Post)', - disabledBy: '<-[:DECIDED]-(related:User)', + decidedByModerator: '<-[:DECIDED]-(related:User)', }, }), }, diff --git a/backend/src/schema/resolvers/moderation.js b/backend/src/schema/resolvers/moderation.js index f7f5d0c33..33d021656 100644 --- a/backend/src/schema/resolvers/moderation.js +++ b/backend/src/schema/resolvers/moderation.js @@ -4,21 +4,21 @@ export default { const { id: resourceId } = params const { id: userId } = user const cypher = ` - MATCH (u:User {id: $userId}) - MATCH (resource {id: $resourceId}) - WHERE resource:User OR resource:Comment OR resource:Post - SET resource.disabled = true - MERGE (resource)<-[decision:DECIDED]-(u) - SET ( - CASE - WHEN decision.createdAt IS NOT NULL - THEN decision END).updatedAt = toString(datetime()) - SET ( - CASE - WHEN decision.createdAt IS NULL - THEN decision END).createdAt = toString(datetime()) - SET decision.disabled = true, decision.closed = false, decision.last = true - RETURN resource {.id} + MATCH (u:User {id: $userId}) + MATCH (resource {id: $resourceId}) + WHERE resource:User OR resource:Comment OR resource:Post + SET resource.disabled = true + MERGE (resource)<-[decision:DECIDED]-(u) + SET ( + CASE + WHEN decision.createdAt IS NOT NULL + THEN decision END).updatedAt = toString(datetime()) + SET ( + CASE + WHEN decision.createdAt IS NULL + THEN decision END).createdAt = toString(datetime()) + SET decision.disabled = true, decision.closed = false, decision.last = true + RETURN resource {.id} ` const session = driver.session() const res = await session.run(cypher, { resourceId, userId }) @@ -32,14 +32,14 @@ export default { enable: async (object, params, { user, driver }) => { const { id: resourceId } = params const cypher = ` - MATCH (resource {id: $resourceId})<-[decision:DECIDED]-(:User) - SET resource.disabled = false - DELETE decision - RETURN resource {.id} + MATCH (resource {id: $resourceId})<-[decision:DECIDED]-(:User) + SET resource.disabled = false + SET decision.disabled = false, decision.updatedAt = toString(datetime()) + RETURN resource {.id} ` // Wolle - // SET decision.updatedAt = toString(datetime()) - // SET decision.disabled = false + // DELETE decision + const session = driver.session() const res = await session.run(cypher, { resourceId }) session.close() diff --git a/backend/src/schema/resolvers/moderation.spec.js b/backend/src/schema/resolvers/moderation.spec.js index 2ac0dd934..531bec693 100644 --- a/backend/src/schema/resolvers/moderation.spec.js +++ b/backend/src/schema/resolvers/moderation.spec.js @@ -26,7 +26,7 @@ const commentQuery = gql` Comment(id: $id) { id disabled - disabledBy { + decidedByModerator { id } } @@ -38,7 +38,7 @@ const postQuery = gql` Post(id: $id) { id disabled - disabledBy { + decidedByModerator { id } } @@ -144,11 +144,11 @@ describe('moderate resources', () => { }) }) - it('changes .disabledBy', async () => { + it('changes .decidedByModerator', async () => { variables = { id: 'comment-id' } - const before = { data: { Comment: [{ id: 'comment-id', disabledBy: null }] } } + const before = { data: { Comment: [{ id: 'comment-id', decidedByModerator: null }] } } const expected = { - data: { Comment: [{ id: 'comment-id', disabledBy: { id: 'moderator-id' } }] }, + data: { Comment: [{ id: 'comment-id', decidedByModerator: { id: 'moderator-id' } }] }, } await expect(query({ query: commentQuery, variables })).resolves.toMatchObject(before) await expect(mutate({ mutation: disableMutation, variables })).resolves.toMatchObject({ @@ -185,11 +185,11 @@ describe('moderate resources', () => { }) }) - it('changes .disabledBy', async () => { + it('changes .decidedByModerator', async () => { variables = { id: 'sample-post-id' } - const before = { data: { Post: [{ id: 'sample-post-id', disabledBy: null }] } } + const before = { data: { Post: [{ id: 'sample-post-id', decidedByModerator: null }] } } const expected = { - data: { Post: [{ id: 'sample-post-id', disabledBy: { id: 'moderator-id' } }] }, + data: { Post: [{ id: 'sample-post-id', decidedByModerator: { id: 'moderator-id' } }] }, } await expect(query({ query: postQuery, variables })).resolves.toMatchObject(before) @@ -278,9 +278,9 @@ describe('moderate resources', () => { }) }) - it('changes .disabledBy', async () => { + it('changes .decidedByModerator', async () => { const expected = { - data: { Comment: [{ id: 'comment-id', disabledBy: null }] }, + data: { Comment: [{ id: 'comment-id', decidedByModerator: { id: 'moderator-id' } }] }, errors: undefined, } await expect(mutate({ mutation: enableMutation, variables })).resolves.toMatchObject({ @@ -320,9 +320,9 @@ describe('moderate resources', () => { }) }) - it('changes .disabledBy', async () => { + it('changes .decidedByModerator', async () => { const expected = { - data: { Post: [{ id: 'post-id', disabledBy: null }] }, + data: { Post: [{ id: 'post-id', decidedByModerator: { id: 'moderator-id' } }] }, errors: undefined, } await expect(mutate({ mutation: enableMutation, variables })).resolves.toMatchObject({ diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index de28d1000..f2a083e52 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -306,7 +306,7 @@ export default { }, hasOne: { author: '<-[:WROTE]-(related:User)', - disabledBy: '<-[:DECIDED]-(related:User)', + decidedByModerator: '<-[:DECIDED]-(related:User)', pinnedBy: '<-[:PINNED]-(related:User)', }, count: { diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js index a84d04c1d..82f6fcfb5 100644 --- a/backend/src/schema/resolvers/users.js +++ b/backend/src/schema/resolvers/users.js @@ -198,7 +198,7 @@ export default { }, hasOne: { invitedBy: '<-[:INVITED]-(related:User)', - disabledBy: '<-[:DECIDED]-(related:User)', + decidedByModerator: '<-[:DECIDED]-(related:User)', location: '-[:IS_IN]->(related:Location)', }, hasMany: { diff --git a/backend/src/schema/types/type/Comment.gql b/backend/src/schema/types/type/Comment.gql index 21220186a..4c1b9968e 100644 --- a/backend/src/schema/types/type/Comment.gql +++ b/backend/src/schema/types/type/Comment.gql @@ -9,7 +9,7 @@ type Comment { updatedAt: String deleted: Boolean disabled: Boolean - disabledBy: User @relation(name: "DECIDED", direction: "IN") + decidedByModerator: User @relation(name: "DECIDED", direction: "IN") } type Mutation { diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 5d94d7af0..77ec432e2 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -47,7 +47,7 @@ type Post { deleted: Boolean disabled: Boolean pinned: Boolean - disabledBy: User @relation(name: "DECIDED", direction: "IN") + decidedByModerator: User @relation(name: "DECIDED", direction: "IN") createdAt: String updatedAt: String language: String diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index a437fd8ef..ebe9c2a3c 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -8,7 +8,7 @@ type User { coverImg: String deleted: Boolean disabled: Boolean - disabledBy: User @relation(name: "DECIDED", direction: "IN") + decidedByModerator: User @relation(name: "DECIDED", direction: "IN") role: UserGroup! publicKey: String invitedBy: User @relation(name: "INVITED", direction: "IN") diff --git a/webapp/graphql/Moderation.js b/webapp/graphql/Moderation.js index 27e1cf700..391c08062 100644 --- a/webapp/graphql/Moderation.js +++ b/webapp/graphql/Moderation.js @@ -25,7 +25,7 @@ export const reportListQuery = () => { name disabled deleted - disabledBy { + decidedByModerator { id slug name @@ -56,7 +56,7 @@ export const reportListQuery = () => { disabled deleted } - disabledBy { + decidedByModerator { id slug name @@ -80,7 +80,7 @@ export const reportListQuery = () => { contributionsCount commentedCount } - disabledBy { + decidedByModerator { id slug name diff --git a/webapp/pages/moderation/index.vue b/webapp/pages/moderation/index.vue index 19da03099..13db490ff 100644 --- a/webapp/pages/moderation/index.vue +++ b/webapp/pages/moderation/index.vue @@ -29,7 +29,10 @@ - + -
+
{{ $t('moderation.reports.disabledBy') }}
- +
{{ $t('moderation.reports.noDecision') }}