mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
messages created by current user are not set to seen
This commit is contained in:
parent
9f1f028454
commit
5bf933887c
@ -385,7 +385,7 @@ describe('Message', () => {
|
||||
data: {
|
||||
Message: [
|
||||
expect.objectContaining({ seen: true }),
|
||||
expect.objectContaining({ seen: true }),
|
||||
expect.objectContaining({ seen: false }),
|
||||
expect.objectContaining({ seen: true }),
|
||||
],
|
||||
},
|
||||
|
||||
@ -91,15 +91,18 @@ export default {
|
||||
},
|
||||
MarkMessagesAsSeen: async (_parent, params, context, _resolveInfo) => {
|
||||
const { messageIds } = params
|
||||
const currentUserId = context.user.id
|
||||
const session = context.driver.session()
|
||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||
const setSeenCypher = `
|
||||
MATCH (m:Message) WHERE m.id IN $messageIds
|
||||
MATCH (m:Message)<-[:CREATED]-(user:User)
|
||||
WHERE m.id IN $messageIds AND NOT user.id = $currentUserId
|
||||
SET m.seen = true
|
||||
RETURN m { .* }
|
||||
`
|
||||
const setSeenTxResponse = await transaction.run(setSeenCypher, {
|
||||
messageIds,
|
||||
currentUserId,
|
||||
})
|
||||
const messages = await setSeenTxResponse.records.map((record) => record.get('m'))
|
||||
return messages
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user