mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-11-23 03:36:42 +11:00
Update communications.js
This commit is contained in:
parent
a4e71cb412
commit
c6b18cb768
1 changed files with 29 additions and 21 deletions
|
@ -621,7 +621,7 @@ router.post("/:id/pins", auth, async (req, res, next) => {
|
||||||
`${req.user.username} unpinned a message from the chat.`,
|
`${req.user.username} unpinned a message from the chat.`,
|
||||||
chat,
|
chat,
|
||||||
req.user.id
|
req.user.id
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const pin = await Pin.create({
|
const pin = await Pin.create({
|
||||||
|
@ -679,27 +679,35 @@ router.put("/:id/read", auth, async (req, res, next) => {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
if (chat) {
|
if (chat) {
|
||||||
await chat.update({
|
if (req.user.storedStatus !== "invisible") {
|
||||||
lastRead: chat.chat.lastMessages[0]?.id || null
|
await chat.update({
|
||||||
})
|
lastRead: chat.chat.lastMessages[0]?.id || null
|
||||||
io.to(req.user.id).emit("readChat", {
|
|
||||||
id: chat.id,
|
|
||||||
lastRead: chat.chat.lastMessages[0]?.id || null
|
|
||||||
})
|
|
||||||
res.sendStatus(204)
|
|
||||||
for (const user of chat.chat.users) {
|
|
||||||
io.to(user.id).emit("readReceipt", {
|
|
||||||
id: chat.id,
|
|
||||||
messageId: chat.chat.lastMessages[0]?.id || null,
|
|
||||||
userId: req.user.id,
|
|
||||||
chatId: chat.chat.id,
|
|
||||||
user: {
|
|
||||||
username: req.user.username,
|
|
||||||
avatar: req.user.avatar,
|
|
||||||
id: req.user.id
|
|
||||||
},
|
|
||||||
previousMessageId: chat.lastRead
|
|
||||||
})
|
})
|
||||||
|
io.to(req.user.id).emit("readChat", {
|
||||||
|
id: chat.id,
|
||||||
|
lastRead: chat.chat.lastMessages[0]?.id || null
|
||||||
|
})
|
||||||
|
res.sendStatus(204)
|
||||||
|
for (const user of chat.chat.users) {
|
||||||
|
io.to(user.id).emit("readReceipt", {
|
||||||
|
id: chat.id,
|
||||||
|
messageId: chat.chat.lastMessages[0]?.id || null,
|
||||||
|
userId: req.user.id,
|
||||||
|
chatId: chat.chat.id,
|
||||||
|
user: {
|
||||||
|
username: req.user.username,
|
||||||
|
avatar: req.user.avatar,
|
||||||
|
id: req.user.id
|
||||||
|
},
|
||||||
|
previousMessageId: chat.lastRead
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
io.to(req.user.id).emit("readChat", {
|
||||||
|
id: chat.id,
|
||||||
|
lastRead: chat.chat.lastMessages[0]?.id || null
|
||||||
|
})
|
||||||
|
res.sendStatus(204)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw Errors.invalidParameter("chat association id")
|
throw Errors.invalidParameter("chat association id")
|
||||||
|
|
Loading…
Reference in a new issue