diff --git a/src/resolvers/moderation.js b/src/resolvers/moderation.js index 8e171dbf6..10046dd03 100644 --- a/src/resolvers/moderation.js +++ b/src/resolvers/moderation.js @@ -1,28 +1,28 @@ export default { Mutation: { disable: async (object, params, { user, driver }) => { - const { resource: { id: postId } } = params + const { resource: { id } } = params const { id: userId } = user const cypher = ` MATCH (u:User {id: $userId}) - MATCH (p:Post {id: $postId}) - SET p.disabled = true - MERGE (p)<-[:DISABLED]-(u) + MATCH (r {id: $id}) + SET r.disabled = true + MERGE (r)<-[:DISABLED]-(u) ` const session = driver.session() - const res = await session.run(cypher, { postId, userId }) + const res = await session.run(cypher, { id, userId }) session.close() return Boolean(res) }, enable: async (object, params, { user, driver }) => { - const { resource: { id: postId } } = params + const { resource: { id } } = params const cypher = ` - MATCH (p:Post {id: $postId})<-[d:DISABLED]-() + MATCH (p {id: $id})<-[d:DISABLED]-() SET p.disabled = false DELETE d ` const session = driver.session() - const res = await session.run(cypher, { postId }) + const res = await session.run(cypher, { id }) session.close() return Boolean(res) } diff --git a/src/schema.graphql b/src/schema.graphql index ddafd880e..5e58d5f1d 100644 --- a/src/schema.graphql +++ b/src/schema.graphql @@ -76,6 +76,7 @@ type User { avatar: String deleted: Boolean disabled: Boolean + disabledBy: User @relation(name: "DISABLED", direction: "IN") role: UserGroupEnum location: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l") @@ -165,6 +166,7 @@ type Comment { updatedAt: String deleted: Boolean disabled: Boolean + disabledBy: User @relation(name: "DISABLED", direction: "IN") } type Report {