@futdevpro/nts-dynamo 1.14.8 → 1.14.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/_collections/global-settings.const.d.ts.map +1 -1
- package/build/_collections/global-settings.const.js +1 -0
- package/build/_collections/global-settings.const.js.map +1 -1
- package/build/_models/interfaces/global-settings.interface.d.ts +18 -2
- package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
- package/build/_modules/assistant/_collections/ass-global-settings.const.d.ts +3 -0
- package/build/_modules/assistant/_collections/ass-global-settings.const.d.ts.map +1 -0
- package/build/_modules/assistant/_collections/ass-global-settings.const.js +15 -0
- package/build/_modules/assistant/_collections/ass-global-settings.const.js.map +1 -0
- package/build/_modules/assistant/_collections/ass.util.d.ts +16 -0
- package/build/_modules/assistant/_collections/ass.util.d.ts.map +1 -0
- package/build/_modules/assistant/_collections/ass.util.js +43 -0
- package/build/_modules/assistant/_collections/ass.util.js.map +1 -0
- package/build/_modules/assistant/_models/ass-global-settings.interface.d.ts +14 -0
- package/build/_modules/assistant/_models/ass-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/assistant/_models/ass-global-settings.interface.js +3 -0
- package/build/_modules/assistant/_models/ass-global-settings.interface.js.map +1 -0
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts +23 -0
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts.map +1 -0
- package/build/_modules/assistant/_services/ass-io.control-service.js +59 -0
- package/build/_modules/assistant/_services/ass-io.control-service.js.map +1 -0
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts +15 -0
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts.map +1 -0
- package/build/_modules/assistant/_services/ass-main.control-service.js +12 -0
- package/build/_modules/assistant/_services/ass-main.control-service.js.map +1 -0
- package/build/_modules/assistant/_services/ass.service-base.d.ts +31 -0
- package/build/_modules/assistant/_services/ass.service-base.d.ts.map +1 -0
- package/build/_modules/assistant/_services/ass.service-base.js +56 -0
- package/build/_modules/assistant/_services/ass.service-base.js.map +1 -0
- package/build/_modules/assistant/index.d.ts +7 -0
- package/build/_modules/assistant/index.d.ts.map +1 -0
- package/build/_modules/assistant/index.js +19 -0
- package/build/_modules/assistant/index.js.map +1 -0
- package/build/_modules/bot/_collections/bot-default-commands.const.d.ts +3 -0
- package/build/_modules/bot/_collections/bot-default-commands.const.d.ts.map +1 -0
- package/build/_modules/bot/_collections/bot-default-commands.const.js +14 -0
- package/build/_modules/bot/_collections/bot-default-commands.const.js.map +1 -0
- package/build/_modules/bot/_collections/bot-global-settings.const.d.ts +3 -0
- package/build/_modules/bot/_collections/bot-global-settings.const.d.ts.map +1 -0
- package/build/_modules/bot/_collections/bot-global-settings.const.js +32 -0
- package/build/_modules/bot/_collections/bot-global-settings.const.js.map +1 -0
- package/build/_modules/bot/_collections/bot-operations.util.d.ts +21 -0
- package/build/_modules/bot/_collections/bot-operations.util.d.ts.map +1 -0
- package/build/_modules/bot/_collections/bot-operations.util.js +74 -0
- package/build/_modules/bot/_collections/bot-operations.util.js.map +1 -0
- package/build/_modules/bot/_enums/bot-provider.enum.d.ts +7 -0
- package/build/_modules/bot/_enums/bot-provider.enum.d.ts.map +1 -0
- package/build/_modules/bot/_enums/bot-provider.enum.js +11 -0
- package/build/_modules/bot/_enums/bot-provider.enum.js.map +1 -0
- package/build/_modules/bot/_models/bot-channel.interface.d.ts +8 -0
- package/build/_modules/bot/_models/bot-channel.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-channel.interface.js +3 -0
- package/build/_modules/bot/_models/bot-channel.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-command.interface.d.ts +8 -0
- package/build/_modules/bot/_models/bot-command.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-command.interface.js +3 -0
- package/build/_modules/bot/_models/bot-command.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts +79 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.js +3 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-last-mention-date.interface.d.ts +7 -0
- package/build/_modules/bot/_models/bot-last-mention-date.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-last-mention-date.interface.js +3 -0
- package/build/_modules/bot/_models/bot-last-mention-date.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-last-message-date.interface.d.ts +6 -0
- package/build/_modules/bot/_models/bot-last-message-date.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-last-message-date.interface.js +3 -0
- package/build/_modules/bot/_models/bot-last-message-date.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-message.interface.d.ts +15 -0
- package/build/_modules/bot/_models/bot-message.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-message.interface.js +3 -0
- package/build/_modules/bot/_models/bot-message.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-provider.interface.d.ts +60 -0
- package/build/_modules/bot/_models/bot-provider.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-provider.interface.js +3 -0
- package/build/_modules/bot/_models/bot-provider.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-user.interface.d.ts +8 -0
- package/build/_modules/bot/_models/bot-user.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-user.interface.js +3 -0
- package/build/_modules/bot/_models/bot-user.interface.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.d.ts +11 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.js +13 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.d.ts +5 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.js +19 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.d.ts +8 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.js +3 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.d.ts +53 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.js +369 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/index.d.ts +5 -0
- package/build/_modules/bot/_modules/discord-bot/index.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/index.js +16 -0
- package/build/_modules/bot/_modules/discord-bot/index.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.d.ts +11 -0
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.js +13 -0
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.d.ts +7 -0
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.js +3 -0
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.d.ts +40 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.js +116 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/index.d.ts +4 -0
- package/build/_modules/bot/_modules/slack-bot/index.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/index.js +15 -0
- package/build/_modules/bot/_modules/slack-bot/index.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.d.ts +11 -0
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.js +13 -0
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.d.ts +7 -0
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.js +3 -0
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.d.ts +40 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.js +116 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/index.d.ts +4 -0
- package/build/_modules/bot/_modules/teams-bot/index.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/index.js +15 -0
- package/build/_modules/bot/_modules/teams-bot/index.js.map +1 -0
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts +15 -0
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-commands.control-service.js +72 -0
- package/build/_modules/bot/_services/bot-commands.control-service.js.map +1 -0
- package/build/_modules/bot/_services/bot-io.control-service.d.ts +24 -0
- package/build/_modules/bot/_services/bot-io.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-io.control-service.js +207 -0
- package/build/_modules/bot/_services/bot-io.control-service.js.map +1 -0
- package/build/_modules/bot/_services/bot-main.control-service.d.ts +42 -0
- package/build/_modules/bot/_services/bot-main.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-main.control-service.js +223 -0
- package/build/_modules/bot/_services/bot-main.control-service.js.map +1 -0
- package/build/_modules/bot/_services/bot-provider-factory.service.d.ts +5 -0
- package/build/_modules/bot/_services/bot-provider-factory.service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-provider-factory.service.js +28 -0
- package/build/_modules/bot/_services/bot-provider-factory.service.js.map +1 -0
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts +17 -0
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-routines.control-service.js +40 -0
- package/build/_modules/bot/_services/bot-routines.control-service.js.map +1 -0
- package/build/_modules/bot/index.d.ts +21 -0
- package/build/_modules/bot/index.d.ts.map +1 -0
- package/build/_modules/bot/index.js +35 -0
- package/build/_modules/bot/index.js.map +1 -0
- package/build/_modules/defaults/_models/default-user.data-model.d.ts +20 -0
- package/build/_modules/defaults/_models/default-user.data-model.d.ts.map +1 -0
- package/build/_modules/defaults/_models/default-user.data-model.js +73 -0
- package/build/_modules/defaults/_models/default-user.data-model.js.map +1 -0
- package/build/_modules/defaults/_services/default-auth.service.d.ts +51 -0
- package/build/_modules/defaults/_services/default-auth.service.d.ts.map +1 -0
- package/build/_modules/defaults/_services/default-auth.service.js +159 -0
- package/build/_modules/defaults/_services/default-auth.service.js.map +1 -0
- package/build/_modules/defaults/_services/default-socket-events.service.d.ts +24 -0
- package/build/_modules/defaults/_services/default-socket-events.service.d.ts.map +1 -0
- package/build/_modules/defaults/_services/default-socket-events.service.js +61 -0
- package/build/_modules/defaults/_services/default-socket-events.service.js.map +1 -0
- package/build/_modules/defaults/_services/default-user.data-service.d.ts +25 -0
- package/build/_modules/defaults/_services/default-user.data-service.d.ts.map +1 -0
- package/build/_modules/defaults/_services/default-user.data-service.js +88 -0
- package/build/_modules/defaults/_services/default-user.data-service.js.map +1 -0
- package/build/_modules/defaults/index.d.ts +5 -0
- package/build/_modules/defaults/index.d.ts.map +1 -0
- package/build/_modules/defaults/index.js +16 -0
- package/build/_modules/defaults/index.js.map +1 -0
- package/build/_modules/messaging/_collections/msg-global-settings.const.d.ts +6 -0
- package/build/_modules/messaging/_collections/msg-global-settings.const.d.ts.map +1 -0
- package/build/_modules/messaging/_collections/msg-global-settings.const.js +27 -0
- package/build/_modules/messaging/_collections/msg-global-settings.const.js.map +1 -0
- package/build/_modules/messaging/_collections/msg.util.d.ts +25 -0
- package/build/_modules/messaging/_collections/msg.util.d.ts.map +1 -0
- package/build/_modules/messaging/_collections/msg.util.js +63 -0
- package/build/_modules/messaging/_collections/msg.util.js.map +1 -0
- package/build/_modules/messaging/_models/msg-global-settings.interface.d.ts +38 -0
- package/build/_modules/messaging/_models/msg-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/messaging/_models/msg-global-settings.interface.js +3 -0
- package/build/_modules/messaging/_models/msg-global-settings.interface.js.map +1 -0
- package/build/_modules/messaging/_services/msg-conversation.data-service.d.ts +29 -0
- package/build/_modules/messaging/_services/msg-conversation.data-service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-conversation.data-service.js +110 -0
- package/build/_modules/messaging/_services/msg-conversation.data-service.js.map +1 -0
- package/build/_modules/messaging/_services/msg-events.service.d.ts +62 -0
- package/build/_modules/messaging/_services/msg-events.service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-events.service.js +204 -0
- package/build/_modules/messaging/_services/msg-events.service.js.map +1 -0
- package/build/_modules/messaging/_services/msg-integration.control-service.d.ts +26 -0
- package/build/_modules/messaging/_services/msg-integration.control-service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-integration.control-service.js +126 -0
- package/build/_modules/messaging/_services/msg-integration.control-service.js.map +1 -0
- package/build/_modules/messaging/_services/msg-main.control-service.d.ts +62 -0
- package/build/_modules/messaging/_services/msg-main.control-service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-main.control-service.js +408 -0
- package/build/_modules/messaging/_services/msg-main.control-service.js.map +1 -0
- package/build/_modules/messaging/_services/msg-message.data-service.d.ts +29 -0
- package/build/_modules/messaging/_services/msg-message.data-service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-message.data-service.js +104 -0
- package/build/_modules/messaging/_services/msg-message.data-service.js.map +1 -0
- package/build/_modules/messaging/get-messaging-routing-module.util.d.ts +8 -0
- package/build/_modules/messaging/get-messaging-routing-module.util.d.ts.map +1 -0
- package/build/_modules/messaging/get-messaging-routing-module.util.js +21 -0
- package/build/_modules/messaging/get-messaging-routing-module.util.js.map +1 -0
- package/build/_modules/messaging/index.d.ts +12 -0
- package/build/_modules/messaging/index.d.ts.map +1 -0
- package/build/_modules/messaging/index.js +30 -0
- package/build/_modules/messaging/index.js.map +1 -0
- package/build/_modules/messaging/messaging.controller.d.ts +13 -0
- package/build/_modules/messaging/messaging.controller.d.ts.map +1 -0
- package/build/_modules/messaging/messaging.controller.js +257 -0
- package/build/_modules/messaging/messaging.controller.js.map +1 -0
- package/package.json +72 -4
- package/src/_collections/global-settings.const.ts +2 -0
- package/src/_models/interfaces/global-settings.interface.ts +20 -2
- package/src/_modules/assistant/_collections/ass-global-settings.const.ts +13 -0
- package/src/_modules/assistant/_collections/ass.util.ts +50 -0
- package/src/_modules/assistant/_models/ass-global-settings.interface.ts +15 -0
- package/src/_modules/assistant/_services/ass-io.control-service.ts +100 -0
- package/src/_modules/assistant/_services/ass-main.control-service.ts +38 -0
- package/src/_modules/assistant/_services/ass.service-base.ts +92 -0
- package/src/_modules/assistant/index.ts +19 -0
- package/src/_modules/bot/_collections/bot-default-commands.const.ts +12 -0
- package/src/_modules/bot/_collections/bot-global-settings.const.ts +39 -0
- package/src/_modules/bot/_collections/bot-operations.util.ts +149 -0
- package/src/_modules/bot/_enums/bot-provider.enum.ts +6 -0
- package/src/_modules/bot/_models/bot-channel.interface.ts +7 -0
- package/src/_modules/bot/_models/bot-command.interface.ts +8 -0
- package/src/_modules/bot/_models/bot-global-settings.interface.ts +87 -0
- package/src/_modules/bot/_models/bot-last-mention-date.interface.ts +6 -0
- package/src/_modules/bot/_models/bot-last-message-date.interface.ts +5 -0
- package/src/_modules/bot/_models/bot-message.interface.ts +14 -0
- package/src/_modules/bot/_models/bot-provider.interface.ts +80 -0
- package/src/_modules/bot/_models/bot-user.interface.ts +7 -0
- package/src/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.ts +18 -0
- package/src/_modules/bot/_modules/discord-bot/_collections/dib.util.ts +20 -0
- package/src/_modules/bot/_modules/discord-bot/_models/dib-platform.types.ts +9 -0
- package/src/_modules/bot/_modules/discord-bot/_services/dib-provider.service.ts +462 -0
- package/src/_modules/bot/_modules/discord-bot/index.ts +15 -0
- package/src/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.ts +18 -0
- package/src/_modules/bot/_modules/slack-bot/_models/slb-platform.types.ts +9 -0
- package/src/_modules/bot/_modules/slack-bot/_services/slb-provider.service.ts +152 -0
- package/src/_modules/bot/_modules/slack-bot/index.ts +14 -0
- package/src/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.ts +18 -0
- package/src/_modules/bot/_modules/teams-bot/_models/teb-platform.types.ts +9 -0
- package/src/_modules/bot/_modules/teams-bot/_services/teb-provider.service.ts +152 -0
- package/src/_modules/bot/_modules/teams-bot/index.ts +14 -0
- package/src/_modules/bot/_services/bot-commands.control-service.ts +126 -0
- package/src/_modules/bot/_services/bot-io.control-service.ts +325 -0
- package/src/_modules/bot/_services/bot-main.control-service.ts +344 -0
- package/src/_modules/bot/_services/bot-provider-factory.service.ts +30 -0
- package/src/_modules/bot/_services/bot-routines.control-service.ts +83 -0
- package/src/_modules/bot/index.ts +36 -0
- package/src/_modules/defaults/_models/default-user.data-model.ts +72 -0
- package/src/_modules/defaults/_services/default-auth.service.ts +177 -0
- package/src/_modules/defaults/_services/default-socket-events.service.ts +61 -0
- package/src/_modules/defaults/_services/default-user.data-service.ts +98 -0
- package/src/_modules/defaults/index.ts +14 -0
- package/src/_modules/messaging/_collections/msg-global-settings.const.ts +27 -0
- package/src/_modules/messaging/_collections/msg.util.ts +83 -0
- package/src/_modules/messaging/_models/msg-global-settings.interface.ts +49 -0
- package/src/_modules/messaging/_services/msg-conversation.data-service.ts +146 -0
- package/src/_modules/messaging/_services/msg-events.service.ts +267 -0
- package/src/_modules/messaging/_services/msg-integration.control-service.ts +179 -0
- package/src/_modules/messaging/_services/msg-main.control-service.ts +548 -0
- package/src/_modules/messaging/_services/msg-message.data-service.ts +129 -0
- package/src/_modules/messaging/get-messaging-routing-module.util.ts +26 -0
- package/src/_modules/messaging/index.ts +33 -0
- package/src/_modules/messaging/messaging.controller.ts +370 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { DyNTS_AuthService } from '../../../_services/core/auth.service';
|
|
3
|
+
import { DyFM_Error } from '@futdevpro/fsm-dynamo';
|
|
4
|
+
import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default Authentication Service
|
|
8
|
+
* Basic token-based authentication
|
|
9
|
+
* Can be extended for custom auth logic
|
|
10
|
+
*/
|
|
11
|
+
export class DyNTS_Default_AuthService extends DyNTS_AuthService {
|
|
12
|
+
|
|
13
|
+
static getInstance(): DyNTS_Default_AuthService {
|
|
14
|
+
return DyNTS_Default_AuthService.getSingletonInstance();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Extract user ID from request
|
|
19
|
+
* Override for custom logic
|
|
20
|
+
*/
|
|
21
|
+
getUserIdFromRequest(req: Request): string {
|
|
22
|
+
// Default: extract from auth header or query param
|
|
23
|
+
const userId = req.headers['x-user-id'] as string || req.query.userId as string;
|
|
24
|
+
|
|
25
|
+
if (!userId) {
|
|
26
|
+
throw new DyFM_Error({
|
|
27
|
+
message: 'User ID not found in request',
|
|
28
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DEF-AUTH-GUID`,
|
|
29
|
+
userMessage: 'Authentication required.',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return userId;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Extract username from request
|
|
38
|
+
* Override for custom logic
|
|
39
|
+
*/
|
|
40
|
+
getUsernameFromRequest(req: Request): string {
|
|
41
|
+
const username = req.headers['x-username'] as string || req.query.username as string;
|
|
42
|
+
|
|
43
|
+
if (!username) {
|
|
44
|
+
return 'anonymous';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return username;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Validate user token
|
|
52
|
+
* Override for custom token validation
|
|
53
|
+
*/
|
|
54
|
+
async validateToken(token: string): Promise<boolean> {
|
|
55
|
+
// Default: basic validation (can be extended)
|
|
56
|
+
return token && token.length > 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get user roles from request
|
|
61
|
+
* Override for custom role extraction
|
|
62
|
+
*/
|
|
63
|
+
getUserRolesFromRequest(req: Request): string[] {
|
|
64
|
+
const roles = req.headers['x-user-roles'] as string || req.query.roles as string;
|
|
65
|
+
|
|
66
|
+
if (!roles) {
|
|
67
|
+
return ['user']; // Default role
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(roles);
|
|
72
|
+
} catch {
|
|
73
|
+
return [roles]; // Single role as string
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Extract issuer from request
|
|
79
|
+
* Required abstract method implementation
|
|
80
|
+
*/
|
|
81
|
+
getIssuerFromRequest(req: Request): string {
|
|
82
|
+
return this.getUserIdFromRequest(req);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Authenticate token
|
|
87
|
+
* Required abstract method implementation
|
|
88
|
+
*/
|
|
89
|
+
authenticate_token = async (req: Request, res: Response): Promise<void> => {
|
|
90
|
+
try {
|
|
91
|
+
const token = req.headers.authorization?.replace('Bearer ', '') || req.query.token as string;
|
|
92
|
+
|
|
93
|
+
if (!token) {
|
|
94
|
+
res.status(401).json({ error: 'Token required' });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const isValid = await this.validateToken(token);
|
|
99
|
+
if (!isValid) {
|
|
100
|
+
res.status(401).json({ error: 'Invalid token' });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Token is valid, continue
|
|
105
|
+
res.status(200).json({ success: true });
|
|
106
|
+
} catch (error) {
|
|
107
|
+
res.status(500).json({ error: 'Authentication failed' });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Authenticate token for self operations
|
|
113
|
+
* Required abstract method implementation
|
|
114
|
+
*/
|
|
115
|
+
authenticate_tokenSelf = async (req: Request, res: Response): Promise<void> => {
|
|
116
|
+
try {
|
|
117
|
+
const userId = this.getUserIdFromRequest(req);
|
|
118
|
+
const token = req.headers.authorization?.replace('Bearer ', '') || req.query.token as string;
|
|
119
|
+
|
|
120
|
+
if (!token) {
|
|
121
|
+
res.status(401).json({ error: 'Token required' });
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const isValid = await this.validateToken(token);
|
|
126
|
+
if (!isValid) {
|
|
127
|
+
res.status(401).json({ error: 'Invalid token' });
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Add user ID to request for downstream use
|
|
132
|
+
(req as any).authenticatedUserId = userId;
|
|
133
|
+
res.status(200).json({ success: true, userId });
|
|
134
|
+
} catch (error) {
|
|
135
|
+
res.status(500).json({ error: 'Authentication failed' });
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Authenticate token with permission and usage data
|
|
141
|
+
* Required abstract method implementation
|
|
142
|
+
*/
|
|
143
|
+
authenticate_tokenPerm_accUsageData = async (req: Request, res: Response): Promise<void> => {
|
|
144
|
+
try {
|
|
145
|
+
const userId = this.getUserIdFromRequest(req);
|
|
146
|
+
const token = req.headers.authorization?.replace('Bearer ', '') || req.query.token as string;
|
|
147
|
+
|
|
148
|
+
if (!token) {
|
|
149
|
+
res.status(401).json({ error: 'Token required' });
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const isValid = await this.validateToken(token);
|
|
154
|
+
if (!isValid) {
|
|
155
|
+
res.status(401).json({ error: 'Invalid token' });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Add user data to request for downstream use
|
|
160
|
+
(req as any).authenticatedUserId = userId;
|
|
161
|
+
(req as any).userRoles = this.getUserRolesFromRequest(req);
|
|
162
|
+
(req as any).usageData = {
|
|
163
|
+
timestamp: new Date(),
|
|
164
|
+
endpoint: req.path,
|
|
165
|
+
method: req.method,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
res.status(200).json({
|
|
169
|
+
success: true,
|
|
170
|
+
userId,
|
|
171
|
+
roles: this.getUserRolesFromRequest(req)
|
|
172
|
+
});
|
|
173
|
+
} catch (error) {
|
|
174
|
+
res.status(500).json({ error: 'Authentication failed' });
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { DyNTS_Msg_Events_Service } from '../../messaging/_services/msg-events.service';
|
|
2
|
+
import { DyNTS_GlobalService } from '../../../_services/core/global.service';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Default Socket Events Service
|
|
6
|
+
* Extends messaging events service with GlobalService socket server integration
|
|
7
|
+
*/
|
|
8
|
+
export class DyNTS_Default_SocketEvents_Service extends DyNTS_Msg_Events_Service {
|
|
9
|
+
|
|
10
|
+
static override getInstance(): DyNTS_Default_SocketEvents_Service {
|
|
11
|
+
return DyNTS_Default_SocketEvents_Service.getSingletonInstance();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get socket server from GlobalService
|
|
16
|
+
* Returns null if not configured (graceful degradation)
|
|
17
|
+
*/
|
|
18
|
+
protected override getSocketServer(): any | null {
|
|
19
|
+
try {
|
|
20
|
+
// Attempt to get socket server from GlobalService if it exists
|
|
21
|
+
// This would require adding getSocketServer to GlobalService
|
|
22
|
+
// For now, return null (no real-time events)
|
|
23
|
+
return null;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
// Socket server not available - messaging still works without real-time
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Emit to specific user
|
|
32
|
+
* Override for custom user targeting
|
|
33
|
+
*/
|
|
34
|
+
emitToUser(userId: string, event: string, data: any): void {
|
|
35
|
+
try {
|
|
36
|
+
const socketServer = this.getSocketServer();
|
|
37
|
+
|
|
38
|
+
if (socketServer && socketServer.emitToUser) {
|
|
39
|
+
socketServer.emitToUser(userId, event, data);
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
// Graceful degradation - messaging still works without real-time
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Emit to room/group
|
|
48
|
+
* Override for custom room targeting
|
|
49
|
+
*/
|
|
50
|
+
emitToRoom(roomId: string, event: string, data: any): void {
|
|
51
|
+
try {
|
|
52
|
+
const socketServer = this.getSocketServer();
|
|
53
|
+
|
|
54
|
+
if (socketServer && socketServer.emitToRoom) {
|
|
55
|
+
socketServer.emitToRoom(roomId, event, data);
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
// Graceful degradation - messaging still works without real-time
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { DyFM_Error, DyFM_DBFilter } from '@futdevpro/fsm-dynamo';
|
|
2
|
+
import { DyNTS_DataService } from '../../../_services/base/data.service';
|
|
3
|
+
import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
|
|
4
|
+
import { DyNTS_Default_User, DyNTS_defaultUser_dataParams } from '../_models/default-user.data-model';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default User Data Service
|
|
8
|
+
* Handles CRUD operations for default users
|
|
9
|
+
*/
|
|
10
|
+
export class DyNTS_Default_User_DataService extends DyNTS_DataService<DyNTS_Default_User> {
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
set: {
|
|
14
|
+
user?: DyNTS_Default_User;
|
|
15
|
+
issuer: string;
|
|
16
|
+
}
|
|
17
|
+
) {
|
|
18
|
+
super(
|
|
19
|
+
new DyNTS_Default_User(set?.user),
|
|
20
|
+
DyNTS_defaultUser_dataParams,
|
|
21
|
+
set.issuer
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Find user by username
|
|
27
|
+
*/
|
|
28
|
+
async findByUsername(username: string): Promise<DyNTS_Default_User | null> {
|
|
29
|
+
try {
|
|
30
|
+
await this.dataDBService
|
|
31
|
+
.findOne({
|
|
32
|
+
username,
|
|
33
|
+
__deleted: { $exists: false }
|
|
34
|
+
} as DyFM_DBFilter<DyNTS_Default_User>)
|
|
35
|
+
.then(res => {
|
|
36
|
+
if (res) {
|
|
37
|
+
this.data = res;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return this.data._id ? this.data : null;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new DyFM_Error({
|
|
44
|
+
...this.getDefaultErrorSettings('findByUsername', error),
|
|
45
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DEF-FBU`,
|
|
46
|
+
userMessage: 'Failed to find user by username.',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Find user by email
|
|
53
|
+
*/
|
|
54
|
+
async findByEmail(email: string): Promise<DyNTS_Default_User | null> {
|
|
55
|
+
try {
|
|
56
|
+
await this.dataDBService
|
|
57
|
+
.findOne({
|
|
58
|
+
email,
|
|
59
|
+
__deleted: { $exists: false }
|
|
60
|
+
} as DyFM_DBFilter<DyNTS_Default_User>)
|
|
61
|
+
.then(res => {
|
|
62
|
+
if (res) {
|
|
63
|
+
this.data = res;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return this.data._id ? this.data : null;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
throw new DyFM_Error({
|
|
70
|
+
...this.getDefaultErrorSettings('findByEmail', error),
|
|
71
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DEF-FBE`,
|
|
72
|
+
userMessage: 'Failed to find user by email.',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Update last login timestamp
|
|
79
|
+
*/
|
|
80
|
+
async updateLastLogin(userId: string): Promise<void> {
|
|
81
|
+
try {
|
|
82
|
+
const user = await this.getDataById(userId);
|
|
83
|
+
|
|
84
|
+
if (!user) {
|
|
85
|
+
throw new Error('User not found');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
user.lastLoginAt = new Date();
|
|
89
|
+
await this.saveData(user);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
throw new DyFM_Error({
|
|
92
|
+
...this.getDefaultErrorSettings('updateLastLogin', error),
|
|
93
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DEF-ULI`,
|
|
94
|
+
userMessage: 'Failed to update last login timestamp.',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Defaults Module
|
|
3
|
+
//
|
|
4
|
+
// Provides default implementations for common services
|
|
5
|
+
// Can be extended or replaced with custom implementations
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// MODELS
|
|
9
|
+
export * from './_models/default-user.data-model';
|
|
10
|
+
|
|
11
|
+
// SERVICES
|
|
12
|
+
export * from './_services/default-user.data-service';
|
|
13
|
+
export * from './_services/default-auth.service';
|
|
14
|
+
export * from './_services/default-socket-events.service';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DyNTS_Msg_Global_Settings } from '../_models/msg-global-settings.interface';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default messaging module settings
|
|
5
|
+
*/
|
|
6
|
+
export const DyNTS_Msg_global_settings: DyNTS_Msg_Global_Settings = {
|
|
7
|
+
enableRealtimeEvents: true,
|
|
8
|
+
maxMessagesPerLoad: 50,
|
|
9
|
+
enableThreading: true,
|
|
10
|
+
enableReactions: true,
|
|
11
|
+
enableAttachments: true,
|
|
12
|
+
maxAttachmentSize: 10 * 1024 * 1024, // 10MB
|
|
13
|
+
enableMentions: true,
|
|
14
|
+
enableReadReceipts: true,
|
|
15
|
+
enableTypingIndicators: true,
|
|
16
|
+
|
|
17
|
+
integration: {
|
|
18
|
+
syncBotMessages: true,
|
|
19
|
+
syncAssistantMessages: true,
|
|
20
|
+
enableAgentProcessViz: true,
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
retry: {
|
|
24
|
+
maxRetries: 3,
|
|
25
|
+
retryDelay: 1000, // 1 second
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DyFM_Msg_Message,
|
|
3
|
+
DyFM_Msg_Conversation,
|
|
4
|
+
DyFM_Msg_Type,
|
|
5
|
+
DyFM_Msg_Status,
|
|
6
|
+
} from '@futdevpro/fsm-dynamo/messaging';
|
|
7
|
+
import { DyNTS_Bot_Message } from '../../bot/_models/bot-message.interface';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Messaging utility functions
|
|
11
|
+
*/
|
|
12
|
+
export class DyNTS_Msg_Util {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Convert bot message to messaging system message
|
|
16
|
+
*/
|
|
17
|
+
static botMessageToMsgMessage<T>(
|
|
18
|
+
botMessage: DyNTS_Bot_Message<T>,
|
|
19
|
+
conversationId: string,
|
|
20
|
+
issuer: string
|
|
21
|
+
): DyFM_Msg_Message {
|
|
22
|
+
return new DyFM_Msg_Message({
|
|
23
|
+
conversationId,
|
|
24
|
+
content: botMessage.content || '',
|
|
25
|
+
type: DyFM_Msg_Type.userToUser,
|
|
26
|
+
status: DyFM_Msg_Status.sent,
|
|
27
|
+
senderId: botMessage.authorId,
|
|
28
|
+
senderName: botMessage.authorName,
|
|
29
|
+
senderDisplayName: botMessage.authorDisplayName,
|
|
30
|
+
platformMessageId: (botMessage.rawPlatformMessage as any)?.id || botMessage.id,
|
|
31
|
+
platformChannelId: botMessage.channelId,
|
|
32
|
+
sentAt: new Date(botMessage.timestamp),
|
|
33
|
+
__createdBy: issuer,
|
|
34
|
+
__lastModifiedBy: issuer,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create AI message from assistant response
|
|
40
|
+
*/
|
|
41
|
+
static createAIMessage(
|
|
42
|
+
conversationId: string,
|
|
43
|
+
content: string,
|
|
44
|
+
aiProvider: string,
|
|
45
|
+
aiModel: string,
|
|
46
|
+
senderId: string,
|
|
47
|
+
issuer: string
|
|
48
|
+
): DyFM_Msg_Message {
|
|
49
|
+
return new DyFM_Msg_Message({
|
|
50
|
+
conversationId,
|
|
51
|
+
content,
|
|
52
|
+
type: DyFM_Msg_Type.aiToUser,
|
|
53
|
+
status: DyFM_Msg_Status.sent,
|
|
54
|
+
senderId,
|
|
55
|
+
isAIGenerated: true,
|
|
56
|
+
aiProvider,
|
|
57
|
+
aiModel,
|
|
58
|
+
sentAt: new Date(),
|
|
59
|
+
__createdBy: issuer,
|
|
60
|
+
__lastModifiedBy: issuer,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Extract mentions from message content
|
|
66
|
+
* Looks for @username or @userId patterns
|
|
67
|
+
*/
|
|
68
|
+
static extractMentions(content: string): string[] {
|
|
69
|
+
const mentionRegex = /@(\w+)/g;
|
|
70
|
+
const matches = content.match(mentionRegex);
|
|
71
|
+
return matches ? matches.map(m => m.substring(1)) : [];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Check if user has permission to access conversation
|
|
76
|
+
*/
|
|
77
|
+
static userCanAccessConversation(
|
|
78
|
+
conversation: DyFM_Msg_Conversation,
|
|
79
|
+
userId: string
|
|
80
|
+
): boolean {
|
|
81
|
+
return conversation.participants?.some(p => p.userId === userId) ?? false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging Module Global Settings
|
|
3
|
+
*/
|
|
4
|
+
export interface DyNTS_Msg_Global_Settings {
|
|
5
|
+
/** Enable real-time socket events for messages */
|
|
6
|
+
enableRealtimeEvents?: boolean;
|
|
7
|
+
|
|
8
|
+
/** Maximum messages per conversation to load */
|
|
9
|
+
maxMessagesPerLoad?: number;
|
|
10
|
+
|
|
11
|
+
/** Enable conversation threading */
|
|
12
|
+
enableThreading?: boolean;
|
|
13
|
+
|
|
14
|
+
/** Enable message reactions */
|
|
15
|
+
enableReactions?: boolean;
|
|
16
|
+
|
|
17
|
+
/** Enable file attachments */
|
|
18
|
+
enableAttachments?: boolean;
|
|
19
|
+
|
|
20
|
+
/** Maximum attachment size in bytes */
|
|
21
|
+
maxAttachmentSize?: number;
|
|
22
|
+
|
|
23
|
+
/** Enable mentions */
|
|
24
|
+
enableMentions?: boolean;
|
|
25
|
+
|
|
26
|
+
/** Enable read receipts */
|
|
27
|
+
enableReadReceipts?: boolean;
|
|
28
|
+
|
|
29
|
+
/** Enable typing indicators */
|
|
30
|
+
enableTypingIndicators?: boolean;
|
|
31
|
+
|
|
32
|
+
/** Integration settings */
|
|
33
|
+
integration?: {
|
|
34
|
+
/** Auto-sync bot messages to messaging system */
|
|
35
|
+
syncBotMessages?: boolean;
|
|
36
|
+
|
|
37
|
+
/** Auto-sync assistant messages to messaging system */
|
|
38
|
+
syncAssistantMessages?: boolean;
|
|
39
|
+
|
|
40
|
+
/** Enable agent process visualization */
|
|
41
|
+
enableAgentProcessViz?: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Retry settings for failed messages */
|
|
45
|
+
retry?: {
|
|
46
|
+
maxRetries?: number;
|
|
47
|
+
retryDelay?: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { DyFM_Error, DyFM_DBFilter } from '@futdevpro/fsm-dynamo';
|
|
2
|
+
import {
|
|
3
|
+
DyFM_Msg_Conversation,
|
|
4
|
+
DyFM_msgConversation_dataParams,
|
|
5
|
+
DyFM_Msg_Participant,
|
|
6
|
+
} from '@futdevpro/fsm-dynamo/messaging';
|
|
7
|
+
|
|
8
|
+
import { DyNTS_DataService } from '../../../_services/base/data.service';
|
|
9
|
+
import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Conversation Data Service
|
|
13
|
+
* Handles CRUD operations for conversations
|
|
14
|
+
*/
|
|
15
|
+
export class DyNTS_Msg_Conversation_DataService extends DyNTS_DataService<DyFM_Msg_Conversation> {
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
set: {
|
|
19
|
+
conversation?: DyFM_Msg_Conversation;
|
|
20
|
+
issuer: string;
|
|
21
|
+
}
|
|
22
|
+
) {
|
|
23
|
+
super(
|
|
24
|
+
new DyFM_Msg_Conversation(set?.conversation),
|
|
25
|
+
DyFM_msgConversation_dataParams,
|
|
26
|
+
set.issuer
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get conversations for a user
|
|
32
|
+
*/
|
|
33
|
+
async getUserConversations(userId: string): Promise<DyFM_Msg_Conversation[]> {
|
|
34
|
+
try {
|
|
35
|
+
await this.dataDBService
|
|
36
|
+
.find({
|
|
37
|
+
'participants.userId': userId,
|
|
38
|
+
__deleted: { $exists: false },
|
|
39
|
+
} as DyFM_DBFilter<DyFM_Msg_Conversation>)
|
|
40
|
+
.then((res: DyFM_Msg_Conversation[]) => {
|
|
41
|
+
this.dataList = res.sort((a, b) => (b.lastMessageAt?.getTime() || 0) - (a.lastMessageAt?.getTime() || 0));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return this.dataList;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new DyFM_Error({
|
|
47
|
+
...this.getDefaultErrorSettings('getUserConversations', error),
|
|
48
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-MSG-GUC`,
|
|
49
|
+
userMessage: 'Failed to retrieve user conversations.',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Add participant to conversation
|
|
56
|
+
*/
|
|
57
|
+
async addParticipant(
|
|
58
|
+
conversationId: string,
|
|
59
|
+
participant: DyFM_Msg_Participant
|
|
60
|
+
): Promise<void> {
|
|
61
|
+
try {
|
|
62
|
+
const conversation = await this.getDataById(conversationId);
|
|
63
|
+
|
|
64
|
+
if (!conversation) {
|
|
65
|
+
throw new Error('Conversation not found');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!conversation.participants) {
|
|
69
|
+
conversation.participants = [];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check if participant already exists
|
|
73
|
+
const exists = conversation.participants.some(
|
|
74
|
+
p => p.userId === participant.userId
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (!exists) {
|
|
78
|
+
conversation.participants.push(participant);
|
|
79
|
+
await this.saveData(conversation);
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw new DyFM_Error({
|
|
83
|
+
...this.getDefaultErrorSettings('addParticipant', error),
|
|
84
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-MSG-AP`,
|
|
85
|
+
userMessage: 'Failed to add participant to conversation.',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Remove participant from conversation
|
|
92
|
+
*/
|
|
93
|
+
async removeParticipant(
|
|
94
|
+
conversationId: string,
|
|
95
|
+
userId: string
|
|
96
|
+
): Promise<void> {
|
|
97
|
+
try {
|
|
98
|
+
const conversation = await this.getDataById(conversationId);
|
|
99
|
+
|
|
100
|
+
if (!conversation) {
|
|
101
|
+
throw new Error('Conversation not found');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
conversation.participants = conversation.participants?.filter(
|
|
105
|
+
p => p.userId !== userId
|
|
106
|
+
) || [];
|
|
107
|
+
|
|
108
|
+
await this.saveData(conversation);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
throw new DyFM_Error({
|
|
111
|
+
...this.getDefaultErrorSettings('removeParticipant', error),
|
|
112
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-MSG-RP`,
|
|
113
|
+
userMessage: 'Failed to remove participant from conversation.',
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Update last message info
|
|
120
|
+
*/
|
|
121
|
+
async updateLastMessage(
|
|
122
|
+
conversationId: string,
|
|
123
|
+
messageId: string,
|
|
124
|
+
messagePreview: string
|
|
125
|
+
): Promise<void> {
|
|
126
|
+
try {
|
|
127
|
+
const conversation = await this.getDataById(conversationId);
|
|
128
|
+
|
|
129
|
+
if (!conversation) {
|
|
130
|
+
throw new Error('Conversation not found');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
conversation.lastMessageId = messageId;
|
|
134
|
+
conversation.lastMessageAt = new Date();
|
|
135
|
+
conversation.lastMessagePreview = messagePreview;
|
|
136
|
+
|
|
137
|
+
await this.saveData(conversation);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
throw new DyFM_Error({
|
|
140
|
+
...this.getDefaultErrorSettings('updateLastMessage', error),
|
|
141
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-MSG-ULM`,
|
|
142
|
+
userMessage: 'Failed to update conversation last message.',
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|