mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
[chat] clone comment threads when cloning project with ranges (#32852)
* [project-history] add best effort flush when cloning project * [web] update labels in clone project modal for admins * [project-history] do not shadow history flush failure * [web] fix accessible label for 'Add comment' button * [chat] clone comment threads when cloning project with ranges GitOrigin-RevId: ef30204c8a94b3d6204d56dcca2f62a46319996b
This commit is contained in:
@@ -3,6 +3,7 @@ import * as MessageManager from './MessageManager.js'
|
||||
import * as MessageFormatter from './MessageFormatter.js'
|
||||
import * as ThreadManager from '../Threads/ThreadManager.js'
|
||||
import { ObjectId } from '../../mongodb.js'
|
||||
import { promiseMapWithLimit } from '@overleaf/promise-utils'
|
||||
|
||||
const DEFAULT_MESSAGE_LIMIT = 50
|
||||
const MAX_MESSAGE_LENGTH = 10 * 1024 // 10kb, about 1,500 words
|
||||
@@ -114,6 +115,10 @@ export async function generateThreadData(context) {
|
||||
return await callMessageHttpController(context, _generateThreadData)
|
||||
}
|
||||
|
||||
export async function cloneCommentThreads(context) {
|
||||
return await callMessageHttpController(context, _cloneCommentThreads)
|
||||
}
|
||||
|
||||
export async function getStatus(context) {
|
||||
const message = 'chat is alive'
|
||||
context.res.status(200).setBody(message)
|
||||
@@ -436,3 +441,16 @@ async function _duplicateCommentThreads(req, res) {
|
||||
}
|
||||
res.json({ newThreads: result })
|
||||
}
|
||||
|
||||
async function _cloneCommentThreads(req, res) {
|
||||
const { projectId: sourceProjectId } = req.params
|
||||
const { targetProjectId } = req.body
|
||||
const rooms = await ThreadManager.cloneThreads(
|
||||
sourceProjectId,
|
||||
targetProjectId
|
||||
)
|
||||
await promiseMapWithLimit(10, rooms, async ({ from, to }) => {
|
||||
await MessageManager.duplicateRoomToOtherRoom(from, to)
|
||||
})
|
||||
res.status(204)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user