mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 02:00:10 +02:00
Merge pull request #7317 from overleaf/jpa-return-chat-edit-status
[misc] return non-success status from editing chat messages back to web GitOrigin-RevId: a3d5f59ac1d92662ac9e9c94b1516441d66e831a
This commit is contained in:
@@ -58,13 +58,16 @@ async function editMessage(req, res) {
|
||||
const { projectId, threadId, messageId } = req.params
|
||||
logger.log({ projectId, threadId, messageId, content }, 'editing message')
|
||||
const room = await ThreadManager.findOrCreateThread(projectId, threadId)
|
||||
await MessageManager.updateMessage(
|
||||
const found = await MessageManager.updateMessage(
|
||||
room._id,
|
||||
messageId,
|
||||
userId,
|
||||
content,
|
||||
Date.now()
|
||||
)
|
||||
if (!found) {
|
||||
return res.sendStatus(404)
|
||||
}
|
||||
res.sendStatus(204)
|
||||
}
|
||||
|
||||
|
||||
@@ -53,12 +53,13 @@ async function updateMessage(roomId, messageId, userId, content, timestamp) {
|
||||
if (userId) {
|
||||
query.user_id = ObjectId(userId)
|
||||
}
|
||||
await db.messages.updateOne(query, {
|
||||
const res = await db.messages.updateOne(query, {
|
||||
$set: {
|
||||
content,
|
||||
edited_at: timestamp,
|
||||
},
|
||||
})
|
||||
return res.modifiedCount === 1
|
||||
}
|
||||
|
||||
async function deleteMessage(roomId, messageId) {
|
||||
|
||||
@@ -83,7 +83,7 @@ describe('Editing a message', async function () {
|
||||
ObjectId(),
|
||||
newContent
|
||||
)
|
||||
expect(response.statusCode).to.equal(204)
|
||||
expect(response.statusCode).to.equal(404)
|
||||
})
|
||||
|
||||
it('should then list the old message in the threads', async function () {
|
||||
|
||||
Reference in New Issue
Block a user