mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Implement disabling of comments+users+posts
This commit is contained in:
parent
1c34f10f96
commit
f40a67b7a8
@ -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)
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user