mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-14 17:04:38 +00:00
Implement new notification query resolver
This commit is contained in:
parent
4d307f09f7
commit
65f911d49f
@ -24,10 +24,10 @@ export default {
|
||||
|
||||
switch (args.read) {
|
||||
case true:
|
||||
whereClause = 'WHERE notification.read = TRUE'
|
||||
whereClause = 'AND notification.read = TRUE'
|
||||
break
|
||||
case false:
|
||||
whereClause = 'WHERE notification.read = FALSE'
|
||||
whereClause = 'AND notification.read = FALSE'
|
||||
break
|
||||
default:
|
||||
whereClause = ''
|
||||
@ -48,17 +48,18 @@ export default {
|
||||
const readTxResultPromise = session.readTransaction(async transaction => {
|
||||
const notificationsTransactionResponse = await transaction.run(
|
||||
`
|
||||
MATCH (resource {deleted: false, disabled: false})-[notification:NOTIFIED]->(user:User {id:$id})
|
||||
WHERE (labels(resource)[0] in [Post, Comment] AND NOT resource.deleted AND NOT resource.disabled) OR labels(resource)[0] in [Report]
|
||||
${whereClause}
|
||||
WITH user, notification, resource,
|
||||
[(resource)<-[:WROTE]-(author:User) | author {.*}] as authors,
|
||||
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post{.*, author: properties(author)} ] as posts
|
||||
WITH resource, user, notification, authors, posts,
|
||||
resource {.*, __typename: labels(resource)[0], author: authors[0], post: posts[0]} as finalResource
|
||||
RETURN notification {.*, from: finalResource, to: properties(user)}
|
||||
${orderByClause}
|
||||
${offset} ${limit}
|
||||
MATCH (resource)-[notification:NOTIFIED]->(user:User {id:$id})
|
||||
WHERE ((labels(resource)[0] in ["Post", "Comment"] AND NOT resource.deleted AND NOT resource.disabled) OR labels(resource)[0] in ["Report"])
|
||||
${whereClause}
|
||||
WITH user, notification, resource,
|
||||
[(resource)<-[:WROTE]-(author:User) | author {.*}] as authors,
|
||||
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post {.*, author: properties(author)} ] as posts,
|
||||
[(reportedResource)<-[:BELONGS_TO]-(resource)<-[file:FILED]-(user) | file {.*, reportedResource: apoc.map.merge(properties(reportedResource), {__typename: labels(reportedResource)[0]})} ] as files
|
||||
WITH resource, user, notification, authors, posts, files,
|
||||
resource {.*, __typename: labels(resource)[0], author: authors[0], post: posts[0], filed: files} as finalResource
|
||||
RETURN notification {.*, from: finalResource, to: properties(user)}
|
||||
${orderByClause}
|
||||
${offset} ${limit}
|
||||
`,
|
||||
{ id: currentUser.id },
|
||||
)
|
||||
|
||||
@ -3,6 +3,7 @@ type FILED {
|
||||
reasonCategory: ReasonCategory!
|
||||
reasonDescription: String!
|
||||
submitter: User
|
||||
reportedResource: ReportedResource
|
||||
}
|
||||
|
||||
# this list equals the strings of an array in file "webapp/constants/modals.js"
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
type NOTIFIED {
|
||||
id: ID!
|
||||
from: NotificationSource
|
||||
to: User
|
||||
createdAt: String!
|
||||
updatedAt: String!
|
||||
read: Boolean
|
||||
reason: NotificationReason
|
||||
read: Boolean!
|
||||
reason: NotificationReason!
|
||||
from: NotificationSource!
|
||||
to: User!
|
||||
}
|
||||
|
||||
union NotificationSource = Post | Comment | Report
|
||||
|
||||
@ -5,6 +5,24 @@
|
||||
"kind": "UNION",
|
||||
"name": "NotificationSource",
|
||||
"possibleTypes": [
|
||||
{
|
||||
"name": "Post"
|
||||
},
|
||||
{
|
||||
"name": "Comment"
|
||||
},
|
||||
{
|
||||
"name": "Report"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "UNION",
|
||||
"name": "ReportedResource",
|
||||
"possibleTypes": [
|
||||
{
|
||||
"name": "User"
|
||||
},
|
||||
{
|
||||
"name": "Post"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user