mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
count unread messages on create room
This commit is contained in:
parent
8e3402a7ef
commit
4afd688fbe
@ -29,13 +29,16 @@ export default {
|
||||
ON CREATE SET
|
||||
room.createdAt = toString(datetime()),
|
||||
room.id = apoc.create.uuid()
|
||||
WITH room, user, currentUser,
|
||||
WITH room, user, currentUser
|
||||
OPTIONAL MATCH (room)<-[:INSIDE]-(message:Message)<-[:CREATED]-(sender:User)
|
||||
WHERE NOT sender.id = $currentUserId AND NOT message.seen
|
||||
WITH room, user, currentUser, message,
|
||||
user.name AS roomName
|
||||
RETURN room {
|
||||
.*,
|
||||
users: [properties(currentUser), properties(user)],
|
||||
roomName: roomName,
|
||||
unreadCount: toString(0)
|
||||
unreadCount: toString(COUNT(DISTINCT message))
|
||||
}
|
||||
`
|
||||
const createRommTxResponse = await transaction.run(createRoomCypher, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user