♻️🩹 backend,oo: fixing instances of controllers, and wip rename from drive -> oo (#525)
This commit is contained in:
@@ -110,6 +110,7 @@ export default class ApplicationsApiService extends TdriveService<undefined> {
|
|||||||
method: "GET" | "POST" | "DELETE",
|
method: "GET" | "POST" | "DELETE",
|
||||||
url: string,
|
url: string,
|
||||||
appId: string,
|
appId: string,
|
||||||
|
data?: unknown,
|
||||||
) {
|
) {
|
||||||
const app = this.requireApplicationConfig(appId);
|
const app = this.requireApplicationConfig(appId);
|
||||||
if (!app.internal_domain)
|
if (!app.internal_domain)
|
||||||
@@ -129,6 +130,7 @@ export default class ApplicationsApiService extends TdriveService<undefined> {
|
|||||||
return axios.request({
|
return axios.request({
|
||||||
url: finalURL,
|
url: finalURL,
|
||||||
method: method,
|
method: method,
|
||||||
|
data,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: signature,
|
Authorization: signature,
|
||||||
},
|
},
|
||||||
@@ -158,16 +160,17 @@ export default class ApplicationsApiService extends TdriveService<undefined> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove any reference to the `editing_session_key` in the plugin
|
* Change the filename in the external editing session
|
||||||
* @param editingSessionKey {@see DriveFile.editing_session_key} to delete
|
* @param editingSessionKey {@see DriveFile.editing_session_key} to change
|
||||||
* @returns `true` if the key was deleted
|
* @param filename The new filename
|
||||||
*/
|
*/
|
||||||
async deleteEditingKey(editingSessionKey: string): Promise<boolean> {
|
async renameEditingKeyFilename(editingSessionKey: string, filename: string): Promise<boolean> {
|
||||||
const parsedKey = EditingSessionKeyFormat.parse(editingSessionKey);
|
const parsedKey = EditingSessionKeyFormat.parse(editingSessionKey);
|
||||||
const response = await this.requestFromApplication(
|
const response = await this.requestFromApplication(
|
||||||
"DELETE",
|
"POST",
|
||||||
"tdriveApi/1/session/" + encodeURIComponent(editingSessionKey),
|
`tdriveApi/1/session/${encodeURIComponent(editingSessionKey)}/title`,
|
||||||
parsedKey.applicationId,
|
parsedKey.applicationId,
|
||||||
|
{ title: filename },
|
||||||
);
|
);
|
||||||
return !!response.data.done as boolean;
|
return !!response.data.done as boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -9,6 +9,9 @@ import { registerHealthProvider } from '@/services/health-providers.service';
|
|||||||
interface RequestQuery {
|
interface RequestQuery {
|
||||||
editing_session_key: string;
|
editing_session_key: string;
|
||||||
}
|
}
|
||||||
|
interface RenameRequestBody {
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
const keyCheckLock = createSingleProcessorLock<[status: number, body: unknown]>();
|
const keyCheckLock = createSingleProcessorLock<[status: number, body: unknown]>();
|
||||||
|
|
||||||
registerHealthProvider({
|
registerHealthProvider({
|
||||||
@@ -85,4 +88,13 @@ export default class TwakeDriveBackendCallbackController {
|
|||||||
});
|
});
|
||||||
await res.status(status).send(body);
|
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) {
|
mount(router: Router) {
|
||||||
const controller = new TwakeDriveBackendCallbackController();
|
const controller = new TwakeDriveBackendCallbackController();
|
||||||
// Why post ? to garantee it is never cached and always ran
|
// 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 = {
|
export const BrowserEditorRoutes = {
|
||||||
mount(router: Router) {
|
mount(router: Router) {
|
||||||
const controller = new BrowserEditorController();
|
const controller = new BrowserEditorController();
|
||||||
router.get('/', requirementsMiddleware, authMiddleware, controller.index);
|
router.get('/', requirementsMiddleware, authMiddleware, controller.index.bind(controller));
|
||||||
router.get('/editor', requirementsMiddleware, authMiddleware, controller.editor);
|
router.get('/editor', requirementsMiddleware, authMiddleware, controller.editor.bind(controller));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import type { Router } from 'express';
|
|||||||
export const OnlyOfficeRoutes = {
|
export const OnlyOfficeRoutes = {
|
||||||
mount(router: Router) {
|
mount(router: Router) {
|
||||||
const controller = new OnlyOfficeController();
|
const controller = new OnlyOfficeController();
|
||||||
router.get(`/:mode/read`, requirementsMiddleware, controller.read);
|
router.get(`/:mode/read`, requirementsMiddleware, controller.read.bind(controller));
|
||||||
router.post(`/:mode/callback`, requirementsMiddleware, controller.ooCallback);
|
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> {
|
async deleteForgotten(key: string): Promise<string> {
|
||||||
return new CommandService.DeleteForgotten.Request(key).post().then(response => response.key);
|
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();
|
export default new OnlyOfficeService();
|
||||||
|
|||||||
Reference in New Issue
Block a user