mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Implement block+unblock basic features
This commit is contained in:
parent
700bdcb8f1
commit
293054a05b
@ -38,9 +38,17 @@ export default {
|
||||
},
|
||||
Mutation: {
|
||||
block: async (object, args, context, resolveInfo) => {
|
||||
if (context.user.id === args.id) return null
|
||||
const { user: currentUser } = context
|
||||
if (currentUser.id === args.id) return null
|
||||
await instance.cypher(
|
||||
`
|
||||
MATCH(u:User {id: $currentUser.id})-[r:FOLLOWS]->(b:User {id: $args.id})
|
||||
DELETE r
|
||||
`,
|
||||
{ currentUser, args },
|
||||
)
|
||||
const [user, blockedUser] = await Promise.all([
|
||||
instance.find('User', context.user.id),
|
||||
instance.find('User', currentUser.id),
|
||||
instance.find('User', args.id),
|
||||
])
|
||||
await user.relateTo(blockedUser, 'blocked')
|
||||
|
||||
@ -44,7 +44,7 @@ type User {
|
||||
)
|
||||
isBlocked: Boolean! @cypher(
|
||||
statement: """
|
||||
MATCH (this)-[:BLOCKED]->(u:User {id: $cypherParams.currentUserId})
|
||||
MATCH (this)<-[:BLOCKED]-(u:User {id: $cypherParams.currentUserId})
|
||||
RETURN COUNT(u) >= 1
|
||||
"""
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user