Merge pull request #6996 from overleaf/tm-expired-project-chat

Add endpoints to chat for deleting expired project chat data

GitOrigin-RevId: e4eb7c7a79472bb116b2095a76c870e204590288
This commit is contained in:
Thomas
2022-03-17 09:03:41 +00:00
committed by Copybot
parent a28e0eaab0
commit 4cc888ce2f
7 changed files with 121 additions and 1 deletions
@@ -54,6 +54,20 @@ async function findAllThreadRooms(projectId) {
.toArray()
}
async function findAllThreadRoomsAndGlobalThread(projectId) {
return db.rooms
.find(
{
project_id: ObjectId(projectId.toString()),
},
{
thread_id: 1,
resolved: 1,
}
)
.toArray()
}
async function resolveThread(projectId, threadId, userId) {
await db.rooms.updateOne(
{
@@ -93,13 +107,21 @@ async function deleteThread(projectId, threadId) {
return room._id
}
async function deleteAllThreadsInProject(projectId) {
await db.rooms.deleteMany({
project_id: ObjectId(projectId.toString()),
})
}
module.exports = ThreadManager = {
GLOBAL_THREAD,
findOrCreateThread,
findAllThreadRooms,
findAllThreadRoomsAndGlobalThread,
resolveThread,
reopenThread,
deleteThread,
deleteAllThreadsInProject,
}
;[
'findOrCreateThread',