diff --git a/src/backend/model/extension/ExtensionMessengerHandler.ts b/src/backend/model/extension/ExtensionMessengerHandler.ts index ff7aeddb..2ff04304 100644 --- a/src/backend/model/extension/ExtensionMessengerHandler.ts +++ b/src/backend/model/extension/ExtensionMessengerHandler.ts @@ -17,7 +17,12 @@ export class ExtensionMessengerHandler implements IExtensionMessengers { addMessenger>(name: string, config: DynamicConfig[], callbacks: { sendMedia: (config: C, media: MediaDTOWithThPath[]) => Promise }): void { - this.extLogger.silly('Adding new Messenger:', name); + if (MessengerRepository.Instance.get(name)) { + this.extLogger.silly('Messenger already exist. Overriding it:', name); + MessengerRepository.Instance.remove({Name: name}); + } else { + this.extLogger.silly('Adding new Messenger:', name); + } const em = new ExtensionMessenger(name, config, callbacks); this.messengers.push(em); MessengerRepository.Instance.register(em); diff --git a/src/backend/model/messenger/MessengerRepository.ts b/src/backend/model/messenger/MessengerRepository.ts index 31a98163..fadc6abf 100644 --- a/src/backend/model/messenger/MessengerRepository.ts +++ b/src/backend/model/messenger/MessengerRepository.ts @@ -18,7 +18,7 @@ export class MessengerRepository { return Object.values(this.messengers); } - remove(m: Messenger>): void { + remove(m: { Name: string }): void { if (!this.messengers[m.Name]) { throw new Error('Messenger does not exist:' + m.Name); }