mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05: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:
parent
64ffd66fa4
commit
c96fbc526e
3 changed files with 7 additions and 3 deletions
|
@ -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 () {
|
||||
|
|
Loading…
Reference in a new issue