♻️🩹 backend,oo: fixing instances of controllers, and wip rename from drive -> oo (#525)
This commit is contained in:
+12
@@ -9,6 +9,9 @@ import { registerHealthProvider } from '@/services/health-providers.service';
|
||||
interface RequestQuery {
|
||||
editing_session_key: string;
|
||||
}
|
||||
interface RenameRequestBody {
|
||||
title: string;
|
||||
}
|
||||
const keyCheckLock = createSingleProcessorLock<[status: number, body: unknown]>();
|
||||
|
||||
registerHealthProvider({
|
||||
@@ -85,4 +88,13 @@ export default class TwakeDriveBackendCallbackController {
|
||||
});
|
||||
await res.status(status).send(body);
|
||||
}
|
||||
|
||||
public async updateSessionFilename(req: Request<RequestQuery, {}, RenameRequestBody>, res: Response): Promise<void> {
|
||||
try {
|
||||
await onlyofficeService.meta(req.params.editing_session_key, req.body.title);
|
||||
res.send({ ok: 1 });
|
||||
} catch (err) {
|
||||
res.status(500).send({ error: -58650 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export const TwakeDriveBackendCallbackRoutes = {
|
||||
mount(router: Router) {
|
||||
const controller = new TwakeDriveBackendCallbackController();
|
||||
// Why post ? to garantee it is never cached and always ran
|
||||
router.post('/session/:editing_session_key/check', authMiddleware, controller.checkSessionStatus);
|
||||
router.post('/session/:editing_session_key/check', authMiddleware, controller.checkSessionStatus.bind(controller));
|
||||
router.post('/session/:editing_session_key/title', authMiddleware, controller.updateSessionFilename.bind(controller));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { Router } from 'express';
|
||||
export const BrowserEditorRoutes = {
|
||||
mount(router: Router) {
|
||||
const controller = new BrowserEditorController();
|
||||
router.get('/', requirementsMiddleware, authMiddleware, controller.index);
|
||||
router.get('/editor', requirementsMiddleware, authMiddleware, controller.editor);
|
||||
router.get('/', requirementsMiddleware, authMiddleware, controller.index.bind(controller));
|
||||
router.get('/editor', requirementsMiddleware, authMiddleware, controller.editor.bind(controller));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { Router } from 'express';
|
||||
export const OnlyOfficeRoutes = {
|
||||
mount(router: Router) {
|
||||
const controller = new OnlyOfficeController();
|
||||
router.get(`/:mode/read`, requirementsMiddleware, controller.read);
|
||||
router.post(`/:mode/callback`, requirementsMiddleware, controller.ooCallback);
|
||||
router.get(`/:mode/read`, requirementsMiddleware, controller.read.bind(controller));
|
||||
router.post(`/:mode/callback`, requirementsMiddleware, controller.ooCallback.bind(controller));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -196,6 +196,17 @@ namespace CommandService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Meta {
|
||||
export interface Response extends SuccessResponse {
|
||||
key: string;
|
||||
}
|
||||
export class Request extends BaseRequest<Response> {
|
||||
constructor(public readonly key: string, public readonly meta: { title: string }) {
|
||||
super('meta');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,6 +366,14 @@ class OnlyOfficeService implements IHealthProvider {
|
||||
async deleteForgotten(key: string): Promise<string> {
|
||||
return new CommandService.DeleteForgotten.Request(key).post().then(response => response.key);
|
||||
}
|
||||
/**
|
||||
* Updates the meta information of the document for all collaborative editors.
|
||||
*
|
||||
* That's the official description. It send file renames to OO.
|
||||
*/
|
||||
async meta(key: string, title: string): Promise<string> {
|
||||
return new CommandService.Meta.Request(key, { title }).post().then(response => response.key);
|
||||
}
|
||||
}
|
||||
|
||||
export default new OnlyOfficeService();
|
||||
|
||||
Reference in New Issue
Block a user