mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-31 04:37:57 +00:00
🩹(addon) skip link generation when one already exists in the event
Detect whether a meeting link is already present in the calendar event item or its body, and prevent generating a new link if one is found. Detection is based on the presence of the app URL in the text. This is imperfect but covers the most naive scenarios.
This commit is contained in:
committed by
aleb_the_flash
parent
52bad6faaf
commit
321cb99f82
@@ -1,4 +1,5 @@
|
||||
/* global Office */
|
||||
const { APP_NAME } = require("../common/index");
|
||||
const { createRoom, initSession } = require("../common/api");
|
||||
const { startPolling } = require("../common/polling");
|
||||
const { saveSession, loadSession } = require("../common/session");
|
||||
@@ -6,6 +7,7 @@ const { openTransitDialog } = require("../common/transitDialog");
|
||||
const { buildMeetingMessage } = require("../common/messageBuilder");
|
||||
const { applyAppName } = require("../common/helpers");
|
||||
const { initI18n, t } = require("../common/i18n");
|
||||
const { isMeetingAlreadyAdded } = require("../common/meetingDetector");
|
||||
|
||||
Office.onReady(async function (info) {
|
||||
|
||||
@@ -26,6 +28,24 @@ function notify(message) {
|
||||
}
|
||||
|
||||
function insertMeetingLink(event, session) {
|
||||
const item = Office.context.mailbox.item;
|
||||
|
||||
isMeetingAlreadyAdded(item)
|
||||
.then((alreadyAdded) => {
|
||||
if (alreadyAdded) {
|
||||
notify(t("meeting.already_added", { app_name: APP_NAME }));
|
||||
event.completed();
|
||||
return;
|
||||
}
|
||||
return _doInsertMeetingLink(event, session);
|
||||
})
|
||||
.catch((err) => {
|
||||
notify(t("meeting.error.details", { message: err.message }));
|
||||
event.completed();
|
||||
});
|
||||
}
|
||||
|
||||
function _doInsertMeetingLink(event, session) {
|
||||
createRoom(session)
|
||||
.then((data) => {
|
||||
const isWeb = Office.context.diagnostics.platform === "OfficeOnline";
|
||||
@@ -36,7 +56,7 @@ function insertMeetingLink(event, session) {
|
||||
return new Promise((resolve, reject) => {
|
||||
item.body.setSelectedDataAsync(text, { coercionType }, (setResult) => {
|
||||
if (setResult.status !== Office.AsyncResultStatus.Succeeded) {
|
||||
notify(t('meeting.error.details', { message: setResult.error.message }));
|
||||
notify(t("meeting.error.details", { message: setResult.error.message }));
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user