quickblox-react-ui-kit 0.2.3 → 0.2.5
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/README.md +3 -2
- package/dist/CommonTypes/FunctionResult.d.ts +5 -1
- package/dist/Data/DefaultConfigurations.d.ts +2 -2
- package/dist/Data/repository/DialogsRepository.d.ts +1 -0
- package/dist/Data/repository/EventMessagesRepository.d.ts +1 -0
- package/dist/Data/repository/MessagesRepository.d.ts +2 -2
- package/dist/Domain/entity/NotificationTypes.d.ts +1 -0
- package/dist/Domain/repository/IDialogsRepository.d.ts +1 -0
- package/dist/Domain/repository/IMessagesRepository.d.ts +2 -2
- package/dist/Domain/use_cases/CreateDialogUseCase.d.ts +2 -1
- package/dist/Domain/use_cases/LeaveDialogUseCase.d.ts +2 -1
- package/dist/Domain/use_cases/RemoveUsersFromTheDialogUseCase.d.ts +2 -1
- package/dist/Domain/use_cases/SubscribeToDialogEventsUseCase.d.ts +1 -0
- package/dist/Domain/use_cases/UpdateDialogUseCase.d.ts +2 -1
- package/dist/Domain/use_cases/ai/AIAnswerAssistUseCase.d.ts +13 -0
- package/dist/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.d.ts +13 -0
- package/dist/Domain/use_cases/ai/AITranslateUseCase.d.ts +14 -0
- package/dist/Domain/use_cases/ai/AITranslateWithProxyUseCase.d.ts +14 -0
- package/dist/Presentation/Views/Base/BaseViewModel.d.ts +3 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +4 -1
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +3 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +5 -13
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.d.ts +8 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.d.ts +3 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +12 -3
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesView.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesViewModel.d.ts +2 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.d.ts +8 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.d.ts +7 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.d.ts +4 -0
- package/dist/QBconfig.d.ts +14 -3
- package/dist/index-ui.d.ts +5 -1
- package/dist/index-ui.js +410 -61
- package/dist/utils/utils.d.ts +9 -0
- package/global.d.ts +12 -4
- package/package.json +5 -1
- package/src/App.tsx +1 -1
- package/src/CommonTypes/FunctionResult.ts +6 -1
- package/src/Data/DefaultConfigurations.ts +155 -19
- package/src/Data/repository/DialogsRepository.ts +4 -0
- package/src/Data/repository/EventMessagesRepository.ts +34 -0
- package/src/Data/repository/MessagesRepository.ts +16 -10
- package/src/Data/source/exception/MapperDTOException.ts +3 -0
- package/src/Data/source/remote/RemoteDataSource.ts +134 -112
- package/src/Domain/entity/NotificationTypes.ts +2 -0
- package/src/Domain/repository/IDialogsRepository.ts +2 -0
- package/src/Domain/repository/IMessagesRepository.ts +2 -2
- package/src/Domain/use_cases/CreateDialogUseCase.ts +8 -1
- package/src/Domain/use_cases/GetAllDialogsUseCaseWithMock.ts +1 -0
- package/src/Domain/use_cases/LeaveDialogUseCase.ts +8 -1
- package/src/Domain/use_cases/RemoveUsersFromTheDialogUseCase.ts +40 -17
- package/src/Domain/use_cases/SendTextMessageUseCase.ts +3 -2
- package/src/Domain/use_cases/SubscribeToDialogEventsUseCase.ts +21 -0
- package/src/Domain/use_cases/UpdateDialogUseCase.ts +8 -1
- package/src/Domain/use_cases/ai/AIAnswerAssistUseCase.ts +69 -0
- package/src/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.ts +71 -0
- package/src/Domain/use_cases/ai/AIRephraseUseCase.ts +38 -36
- package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +25 -21
- package/src/Domain/use_cases/ai/AITranslateUseCase.ts +76 -0
- package/src/Domain/use_cases/ai/AITranslateWithProxyUseCase.ts +79 -0
- package/src/Domain/use_cases/base/Subscribable/SubscriptionPerformer.ts +7 -10
- package/src/Presentation/Views/Base/BaseViewModel.ts +3 -0
- package/src/Presentation/Views/Dialogs/Dialogs.scss +3 -0
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +1 -1
- package/src/Presentation/Views/Dialogs/useDialogsViewModel.ts +109 -48
- package/src/Presentation/assets/styles/_variables.scss +19 -0
- package/src/Presentation/components/UI/Buttons/MainButton/MainButton.scss +9 -0
- package/src/Presentation/components/UI/Dialogs/EditDialog/EditDialog.scss +3 -0
- package/src/Presentation/components/UI/Dialogs/InviteMembers/InviteMembers.scss +3 -0
- package/src/Presentation/components/UI/Dialogs/MembersList/MembersList.scss +3 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +7 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +10 -4
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +29 -15
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +10 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +10 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +17 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.tsx +16 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +13 -12
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.tsx +13 -12
- package/src/Presentation/components/UI/Dialogs/MessagesView/AudioAttachmentComponent/AudioAttachmentComponent.tsx +1 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.scss +76 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.tsx +40 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.scss +26 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.tsx +25 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ImageAttachmentComponent/ImageAttachmentComponent.tsx +8 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.tsx +6 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +5 -7
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +138 -405
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +14 -26
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +658 -429
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesViewModel.ts +2 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.tsx +1 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.scss +23 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.tsx +17 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.scss +21 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.tsx +17 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +124 -83
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.scss +62 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.tsx +25 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.scss +61 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.tsx +32 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.scss +29 -3
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.tsx +55 -4
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.scss +40 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.tsx +26 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.scss +62 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.tsx +25 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.svg +5 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.tsx +50 -0
- package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +3 -15
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/useQbInitializedDataContext.ts +15 -14
- package/src/QBconfig.ts +156 -10
- package/src/index-ui.ts +8 -1
- package/src/index.scss +0 -1
- package/src/package_artan_react_ui.json +13 -9
- package/src/package_original.json +5 -1
- package/src/utils/utils.ts +63 -0
- package/src/Presentation/assets/styles/_reset-styles.scss +0 -435
|
@@ -149,6 +149,8 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
149
149
|
this.fileDTOMapper = new FileDTOMapper();
|
|
150
150
|
this._needInit = true;
|
|
151
151
|
this._authProcessed = false;
|
|
152
|
+
this.subscriptionOnSystemMessages[NotificationTypes.REMOVE_USER] =
|
|
153
|
+
new SubscriptionPerformer<RemoteMessageDTO>();
|
|
152
154
|
this.subscriptionOnSystemMessages[NotificationTypes.UPDATE_DIALOG] =
|
|
153
155
|
new SubscriptionPerformer<RemoteMessageDTO>();
|
|
154
156
|
this.subscriptionOnSystemMessages[NotificationTypes.DELETE_LEAVE_DIALOG] =
|
|
@@ -270,6 +272,9 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
270
272
|
let SystemMessageType: string = NotificationTypes.NEW_DIALOG;
|
|
271
273
|
|
|
272
274
|
switch (notificationType) {
|
|
275
|
+
case NotificationTypes.REMOVE_USER:
|
|
276
|
+
SystemMessageType = NotificationTypes.REMOVE_USER;
|
|
277
|
+
break;
|
|
273
278
|
case NotificationTypes.DELETE_LEAVE_DIALOG:
|
|
274
279
|
SystemMessageType = NotificationTypes.DELETE_LEAVE_DIALOG;
|
|
275
280
|
break;
|
|
@@ -348,26 +353,13 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
348
353
|
message.extension.notification_type || NotificationTypes.UPDATE_DIALOG;
|
|
349
354
|
resultMessage.dialogId = message?.extension?.dialog_id || '';
|
|
350
355
|
|
|
351
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
352
|
-
function getEventNameFromNotification(notification_type: string) {
|
|
353
|
-
let EventName = SubscriptionPerformer.DEFAULT_SUBSCRIPTION_NAME;
|
|
354
|
-
|
|
355
|
-
if (
|
|
356
|
-
notification_type === NotificationTypes.UPDATE_DIALOG ||
|
|
357
|
-
notification_type === NotificationTypes.NEW_DIALOG
|
|
358
|
-
) {
|
|
359
|
-
EventName = 'UPDATE_DIALOG_LIST_INFO';
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
return EventName;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
356
|
this.subscriptionOnSystemMessages[
|
|
366
357
|
resultMessage.notification_type
|
|
367
358
|
].informSubscribers(resultMessage, EventMessageType.SystemMessage);
|
|
368
359
|
};
|
|
369
360
|
|
|
370
|
-
|
|
361
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
362
|
+
function QBChatXMPPMessageToRemoteMessageDTO(message: QBChatXMPPMessage) {
|
|
371
363
|
const resultMessage = new RemoteMessageDTO();
|
|
372
364
|
|
|
373
365
|
resultMessage.id = message.id;
|
|
@@ -413,28 +405,104 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
413
405
|
// нужно получить реализовать так как при обработке onDeliveredStatusListener
|
|
414
406
|
const dialogId = message.dialog_id || message.extension.dialog_id || '-1';
|
|
415
407
|
|
|
416
|
-
//
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
// );
|
|
421
|
-
// const current = dialogs && dialogs.length > 0 ? dialogs[0] : undefined;
|
|
422
|
-
|
|
408
|
+
//
|
|
409
|
+
qbChatGetMessagesExtended(dialogId, {
|
|
410
|
+
_id: message.id,
|
|
411
|
+
})
|
|
423
412
|
// eslint-disable-next-line promise/always-return
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
413
|
+
.then((qbMessages: GetMessagesResult) => {
|
|
414
|
+
///
|
|
415
|
+
qbMessages.items.map(async (currentItem) => {
|
|
416
|
+
const dtoMessage: RemoteMessageDTO =
|
|
417
|
+
await this.messageDTOMapper.toTDO<
|
|
418
|
+
QBChatMessage,
|
|
419
|
+
RemoteMessageDTO
|
|
420
|
+
>(currentItem);
|
|
421
|
+
|
|
422
|
+
dtoMessage.dialogId = dialogId;
|
|
423
|
+
|
|
424
|
+
this.subscriptionOnChatMessages.informSubscribers(
|
|
425
|
+
dtoMessage,
|
|
426
|
+
EventMessageType.RegularMessage,
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
return dtoMessage;
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
///
|
|
433
|
+
})
|
|
434
|
+
.catch();
|
|
435
|
+
//
|
|
436
|
+
// // eslint-disable-next-line promise/catch-or-return,@typescript-eslint/no-unused-vars,promise/always-return
|
|
437
|
+
// QBGetDialogById(dialogId).then((result) => {
|
|
438
|
+
// // const dialogs: QBChatDialog[] | undefined = result?.items.filter(
|
|
439
|
+
// // (v) => v._id === dialogId,
|
|
440
|
+
// // );
|
|
441
|
+
// // const current = dialogs && dialogs.length > 0 ? dialogs[0] : undefined;
|
|
442
|
+
//
|
|
443
|
+
// // eslint-disable-next-line promise/always-return
|
|
444
|
+
// // if (current && current.type === DialogType.group)
|
|
445
|
+
// // eslint-disable-next-line no-lone-blocks
|
|
446
|
+
// {
|
|
447
|
+
// // const messageId = message.id;
|
|
448
|
+
// const resultMessage = QBChatXMPPMessageToRemoteMessageDTO(message);
|
|
449
|
+
//
|
|
450
|
+
// this.subscriptionOnChatMessages.informSubscribers(
|
|
451
|
+
// resultMessage,
|
|
452
|
+
// EventMessageType.RegularMessage,
|
|
453
|
+
// );
|
|
454
|
+
// }
|
|
455
|
+
//
|
|
456
|
+
// //
|
|
457
|
+
// });
|
|
458
|
+
};
|
|
459
|
+
QB.chat.onDeliveredStatusListener = (messageId, dialogId, userId) => {
|
|
460
|
+
console.log(
|
|
461
|
+
`EVENT: receive delivered message id: ${messageId}, dialogid: ${dialogId} userid: ${userId}`,
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
QBGetDialogById(dialogId)
|
|
465
|
+
.then((result) => {
|
|
466
|
+
//
|
|
467
|
+
const dialogs: QBChatDialog[] | undefined = result?.items.filter(
|
|
468
|
+
(v) => v._id === dialogId,
|
|
433
469
|
);
|
|
434
|
-
|
|
470
|
+
const current =
|
|
471
|
+
dialogs && dialogs.length > 0 ? dialogs[0] : undefined;
|
|
435
472
|
|
|
436
|
-
|
|
437
|
-
|
|
473
|
+
// eslint-disable-next-line promise/always-return
|
|
474
|
+
if (current && current.type === DialogType.private) {
|
|
475
|
+
//
|
|
476
|
+
qbChatGetMessagesExtended(dialogId, {
|
|
477
|
+
_id: messageId,
|
|
478
|
+
})
|
|
479
|
+
// eslint-disable-next-line promise/always-return
|
|
480
|
+
.then((qbMessages: GetMessagesResult) => {
|
|
481
|
+
///
|
|
482
|
+
qbMessages.items.map(async (currentItem) => {
|
|
483
|
+
const dtoMessage: RemoteMessageDTO =
|
|
484
|
+
await this.messageDTOMapper.toTDO<
|
|
485
|
+
QBChatMessage,
|
|
486
|
+
RemoteMessageDTO
|
|
487
|
+
>(currentItem);
|
|
488
|
+
|
|
489
|
+
dtoMessage.dialogId = dialogId;
|
|
490
|
+
|
|
491
|
+
this.subscriptionOnChatMessages.informSubscribers(
|
|
492
|
+
dtoMessage,
|
|
493
|
+
EventMessageType.RegularMessage,
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
return dtoMessage;
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
///
|
|
500
|
+
})
|
|
501
|
+
.catch();
|
|
502
|
+
//
|
|
503
|
+
}
|
|
504
|
+
})
|
|
505
|
+
.catch();
|
|
438
506
|
};
|
|
439
507
|
QB.chat.onMessageTypingListener = (isTyping, userId, dialogId) => {
|
|
440
508
|
console.log(
|
|
@@ -492,54 +560,6 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
492
560
|
);
|
|
493
561
|
};
|
|
494
562
|
|
|
495
|
-
QB.chat.onDeliveredStatusListener = (messageId, dialogId, userId) => {
|
|
496
|
-
console.log(
|
|
497
|
-
`EVENT: receive delivered message id: ${messageId}, dialogid: ${dialogId} userid: ${userId}`,
|
|
498
|
-
);
|
|
499
|
-
|
|
500
|
-
QBGetDialogById(dialogId)
|
|
501
|
-
.then((result) => {
|
|
502
|
-
//
|
|
503
|
-
const dialogs: QBChatDialog[] | undefined = result?.items.filter(
|
|
504
|
-
(v) => v._id === dialogId,
|
|
505
|
-
);
|
|
506
|
-
const current =
|
|
507
|
-
dialogs && dialogs.length > 0 ? dialogs[0] : undefined;
|
|
508
|
-
|
|
509
|
-
// eslint-disable-next-line promise/always-return
|
|
510
|
-
if (current && current.type === DialogType.private) {
|
|
511
|
-
//
|
|
512
|
-
qbChatGetMessagesExtended(dialogId, {
|
|
513
|
-
_id: messageId,
|
|
514
|
-
})
|
|
515
|
-
// eslint-disable-next-line promise/always-return
|
|
516
|
-
.then((qbMessages: GetMessagesResult) => {
|
|
517
|
-
///
|
|
518
|
-
qbMessages.items.map(async (currentItem) => {
|
|
519
|
-
const dtoMessage: RemoteMessageDTO =
|
|
520
|
-
await this.messageDTOMapper.toTDO<
|
|
521
|
-
QBChatMessage,
|
|
522
|
-
RemoteMessageDTO
|
|
523
|
-
>(currentItem);
|
|
524
|
-
|
|
525
|
-
dtoMessage.dialogId = dialogId;
|
|
526
|
-
|
|
527
|
-
this.subscriptionOnChatMessages.informSubscribers(
|
|
528
|
-
dtoMessage,
|
|
529
|
-
EventMessageType.RegularMessage,
|
|
530
|
-
);
|
|
531
|
-
|
|
532
|
-
return dtoMessage;
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
///
|
|
536
|
-
})
|
|
537
|
-
.catch();
|
|
538
|
-
//
|
|
539
|
-
}
|
|
540
|
-
})
|
|
541
|
-
.catch();
|
|
542
|
-
};
|
|
543
563
|
QB.chat.onReadStatusListener = (messageId, dialogId, userId) => {
|
|
544
564
|
console.log(
|
|
545
565
|
`EVENT: receive read message id: ${messageId}, dialogid: ${dialogId} userid: ${userId}`,
|
|
@@ -1153,32 +1173,32 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1153
1173
|
*/
|
|
1154
1174
|
// notification_type: 3,
|
|
1155
1175
|
// dialog_updated_at: Date.now() / 1000,
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
switch (dto.notification_type) {
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
}
|
|
1176
|
+
const messageText = dto.message;
|
|
1177
|
+
|
|
1178
|
+
// switch (dto.notification_type) {
|
|
1179
|
+
// case NotificationTypes.DELETE_LEAVE_DIALOG: {
|
|
1180
|
+
// messageText = `${
|
|
1181
|
+
// this.authInformation?.userName || 'owner'
|
|
1182
|
+
// } has left the chat.`;
|
|
1183
|
+
// break;
|
|
1184
|
+
// }
|
|
1185
|
+
// case NotificationTypes.NEW_DIALOG: {
|
|
1186
|
+
// messageText = `${
|
|
1187
|
+
// this.authInformation?.userName || 'owner'
|
|
1188
|
+
// } create the chat`;
|
|
1189
|
+
// break;
|
|
1190
|
+
// }
|
|
1191
|
+
// case NotificationTypes.UPDATE_DIALOG: {
|
|
1192
|
+
// messageText = `${
|
|
1193
|
+
// this.authInformation?.userName || 'owner'
|
|
1194
|
+
// } update the chat`;
|
|
1195
|
+
// break;
|
|
1196
|
+
// }
|
|
1197
|
+
// default: {
|
|
1198
|
+
// messageText = dto.message;
|
|
1199
|
+
// break;
|
|
1200
|
+
// }
|
|
1201
|
+
// }
|
|
1182
1202
|
const qbEntity: QBChatNewMessage = {
|
|
1183
1203
|
type: dto.dialog_type === DialogType.private ? 'chat' : 'groupchat',
|
|
1184
1204
|
body: messageText,
|
|
@@ -1207,10 +1227,10 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1207
1227
|
qbEntity.extension.attachments?.push(chatMessageAttachment);
|
|
1208
1228
|
});
|
|
1209
1229
|
}
|
|
1210
|
-
let
|
|
1230
|
+
let qbMessageId: QBChatMessage['_id'];
|
|
1211
1231
|
|
|
1212
1232
|
if (dto.dialog_type === DialogType.private) {
|
|
1213
|
-
|
|
1233
|
+
qbMessageId = await QBChatSendMessage(dto.recipient_id, qbEntity);
|
|
1214
1234
|
} else {
|
|
1215
1235
|
await QBJoinGroupDialog(dto.dialogId).catch(() => {
|
|
1216
1236
|
throw new RemoteDataSourceException(
|
|
@@ -1220,10 +1240,10 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1220
1240
|
});
|
|
1221
1241
|
const dialogJid = QB.chat.helpers.getRoomJidFromDialogId(dto.dialogId);
|
|
1222
1242
|
|
|
1223
|
-
|
|
1243
|
+
qbMessageId = await QBChatSendMessage(dialogJid, qbEntity);
|
|
1224
1244
|
}
|
|
1225
1245
|
|
|
1226
|
-
if (
|
|
1246
|
+
if (qbMessageId === null || qbMessageId === undefined) {
|
|
1227
1247
|
return Promise.reject(
|
|
1228
1248
|
new RemoteDataSourceException(
|
|
1229
1249
|
INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_MESSAGE,
|
|
@@ -1232,6 +1252,8 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1232
1252
|
);
|
|
1233
1253
|
}
|
|
1234
1254
|
console.log('regular message was sent');
|
|
1255
|
+
// eslint-disable-next-line no-param-reassign
|
|
1256
|
+
dto.id = qbMessageId;
|
|
1235
1257
|
|
|
1236
1258
|
return Promise.resolve(dto);
|
|
1237
1259
|
}
|
|
@@ -3,9 +3,9 @@ import { PaginatedResult, Pagination } from './Pagination';
|
|
|
3
3
|
import { DialogEntity } from '../entity/DialogEntity'
|
|
4
4
|
|
|
5
5
|
export interface IMessagesRepository {
|
|
6
|
-
saveMessageToLocal(message: MessageEntity): Promise<
|
|
6
|
+
saveMessageToLocal(message: MessageEntity): Promise<MessageEntity>;
|
|
7
7
|
|
|
8
|
-
sendMessageToRemote(message: MessageEntity): Promise<
|
|
8
|
+
sendMessageToRemote(message: MessageEntity): Promise<MessageEntity>;
|
|
9
9
|
|
|
10
10
|
getMessagesFromLocal(dialogId: string): Promise<Array<MessageEntity>>;
|
|
11
11
|
|
|
@@ -15,16 +15,20 @@ export class CreateDialogUseCase implements IUseCase<void, DialogEntity> {
|
|
|
15
15
|
|
|
16
16
|
private newDialog: GroupDialogEntity;
|
|
17
17
|
|
|
18
|
+
private textInformationMessage: string;
|
|
19
|
+
|
|
18
20
|
// todo: delete synUseCase: BaseUseCase<boolean>, use only dialogRepository
|
|
19
21
|
constructor(
|
|
20
22
|
eventMessagesRepository: EventMessagesRepository,
|
|
21
23
|
dialogRepository: DialogsRepository,
|
|
22
24
|
newDialog: GroupDialogEntity,
|
|
25
|
+
textInformationMessage: string,
|
|
23
26
|
) {
|
|
24
27
|
console.log('CONSTRUCTOR CreateDialogUseCase');
|
|
25
28
|
this.dialogRepository = dialogRepository;
|
|
26
29
|
this.newDialog = newDialog;
|
|
27
30
|
this.eventMessagesRepository = eventMessagesRepository;
|
|
31
|
+
this.textInformationMessage = textInformationMessage;
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
async execute(): Promise<DialogEntity> {
|
|
@@ -60,7 +64,10 @@ export class CreateDialogUseCase implements IUseCase<void, DialogEntity> {
|
|
|
60
64
|
remoteMessageDTO.dialogId = result.id;
|
|
61
65
|
remoteMessageDTO.notification_type = NotificationTypes.NEW_DIALOG;
|
|
62
66
|
remoteMessageDTO.date_sent = Date.now() / 1000;
|
|
63
|
-
remoteMessageDTO.message =
|
|
67
|
+
remoteMessageDTO.message =
|
|
68
|
+
this.textInformationMessage && this.textInformationMessage.length > 0
|
|
69
|
+
? this.textInformationMessage
|
|
70
|
+
: `User ${this.newDialog.ownerId} create new dialog ${this.newDialog.name}`;
|
|
64
71
|
|
|
65
72
|
this.eventMessagesRepository.dispatchEvent<RemoteMessageDTO>(
|
|
66
73
|
EventMessageType.RegularMessage,
|
|
@@ -21,6 +21,7 @@ export class GetAllDialogsUseCaseWithMock
|
|
|
21
21
|
const fromRemote: PaginatedResult<DialogEntity> =
|
|
22
22
|
await this.dialogRepository.getDialogsFromRemote(this.pagination);
|
|
23
23
|
|
|
24
|
+
this.dialogRepository.release();
|
|
24
25
|
await Promise.all(
|
|
25
26
|
fromRemote.ResultData.map(async (entity) => {
|
|
26
27
|
// eslint-disable-next-line no-return-await
|
|
@@ -27,17 +27,21 @@ export class LeaveDialogUseCase implements IUseCase<void, boolean> {
|
|
|
27
27
|
|
|
28
28
|
private leaveType: DialogLeaveTypeArcheType;
|
|
29
29
|
|
|
30
|
+
private textInformationMessage: string;
|
|
31
|
+
|
|
30
32
|
constructor(
|
|
31
33
|
eventMessagesRepository: EventMessagesRepository,
|
|
32
34
|
dialogRepository: DialogsRepository,
|
|
33
35
|
dialog: DialogEntity,
|
|
34
36
|
leaveType: DialogLeaveTypeArcheType,
|
|
37
|
+
textInformationMessage: string,
|
|
35
38
|
) {
|
|
36
39
|
console.log('CONSTRUCTOR LeaveDialogUseCase');
|
|
37
40
|
this.eventMessagesRepository = eventMessagesRepository;
|
|
38
41
|
this.dialogRepository = dialogRepository;
|
|
39
42
|
this.dialogToLeave = dialog;
|
|
40
43
|
this.leaveType = leaveType;
|
|
44
|
+
this.textInformationMessage = textInformationMessage;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
async execute(): Promise<boolean> {
|
|
@@ -59,7 +63,10 @@ export class LeaveDialogUseCase implements IUseCase<void, boolean> {
|
|
|
59
63
|
remoteMessageDTO.dialogId = this.dialogToLeave.id;
|
|
60
64
|
remoteMessageDTO.notification_type = NotificationTypes.DELETE_LEAVE_DIALOG;
|
|
61
65
|
remoteMessageDTO.date_sent = Date.now();
|
|
62
|
-
remoteMessageDTO.message =
|
|
66
|
+
remoteMessageDTO.message =
|
|
67
|
+
this.textInformationMessage && this.textInformationMessage.length > 0
|
|
68
|
+
? this.textInformationMessage
|
|
69
|
+
: `User ${this.dialogToLeave.ownerId} has left dialog.`;
|
|
63
70
|
|
|
64
71
|
this.eventMessagesRepository.dispatchEvent<RemoteMessageDTO>(
|
|
65
72
|
EventMessageType.RegularMessage,
|
|
@@ -21,17 +21,21 @@ export class RemoveUsersFromTheDialogUseCase
|
|
|
21
21
|
|
|
22
22
|
private usersIds: Array<number>;
|
|
23
23
|
|
|
24
|
+
private textInformationMessage: string;
|
|
25
|
+
|
|
24
26
|
constructor(
|
|
25
27
|
eventMessagesRepository: EventMessagesRepository,
|
|
26
28
|
dialogRepository: DialogsRepository,
|
|
27
29
|
dialog: DialogEntity,
|
|
28
30
|
usersIds: Array<number>,
|
|
31
|
+
textInformationMessage: string,
|
|
29
32
|
) {
|
|
30
33
|
console.log('CONSTRUCTOR LeaveDialogUseCase');
|
|
31
34
|
this.eventMessagesRepository = eventMessagesRepository;
|
|
32
35
|
this.dialogRepository = dialogRepository;
|
|
33
36
|
this.dialogToLeave = dialog;
|
|
34
37
|
this.usersIds = usersIds;
|
|
38
|
+
this.textInformationMessage = textInformationMessage;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
async execute(): Promise<boolean> {
|
|
@@ -53,13 +57,25 @@ export class RemoveUsersFromTheDialogUseCase
|
|
|
53
57
|
remoteMessageDTO.dialogId = this.dialogToLeave.id;
|
|
54
58
|
remoteMessageDTO.notification_type = NotificationTypes.DELETE_LEAVE_DIALOG;
|
|
55
59
|
remoteMessageDTO.date_sent = Date.now();
|
|
56
|
-
remoteMessageDTO.message =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
remoteMessageDTO.message =
|
|
61
|
+
this.textInformationMessage && this.textInformationMessage.length > 0
|
|
62
|
+
? this.textInformationMessage
|
|
63
|
+
: `User ${this.dialogToLeave.ownerId} delete other users from dialog.`;
|
|
64
|
+
|
|
65
|
+
const updatedRecivers: number[] = [];
|
|
66
|
+
|
|
67
|
+
receivers.forEach((item) => {
|
|
68
|
+
if (!this.usersIds.includes(item)) {
|
|
69
|
+
updatedRecivers.push(item);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// send visual message
|
|
74
|
+
// this.eventMessagesRepository.dispatchEvent<RemoteMessageDTO>(
|
|
75
|
+
// EventMessageType.RegularMessage,
|
|
76
|
+
// remoteMessageDTO,
|
|
77
|
+
// updatedRecivers,
|
|
78
|
+
// );
|
|
63
79
|
//
|
|
64
80
|
|
|
65
81
|
await this.dialogRepository
|
|
@@ -81,21 +97,28 @@ export class RemoveUsersFromTheDialogUseCase
|
|
|
81
97
|
console.log('try to delete dialog in local');
|
|
82
98
|
|
|
83
99
|
remoteMessageDTO.dialogId = this.dialogToLeave.id;
|
|
84
|
-
remoteMessageDTO.notification_type =
|
|
85
|
-
NotificationTypes.DELETE_LEAVE_DIALOG;
|
|
86
|
-
|
|
87
|
-
await this.dialogRepository.deleteDialogFromLocal(this.dialogToLeave.id);
|
|
88
|
-
this.eventMessagesRepository.dispatchEvent<RemoteMessageDTO>(
|
|
89
|
-
EventMessageType.LocalMessage,
|
|
90
|
-
remoteMessageDTO,
|
|
91
|
-
[],
|
|
92
|
-
);
|
|
100
|
+
remoteMessageDTO.notification_type = NotificationTypes.REMOVE_USER;
|
|
93
101
|
|
|
94
102
|
this.eventMessagesRepository.dispatchEvent<RemoteMessageDTO>(
|
|
95
103
|
EventMessageType.SystemMessage,
|
|
96
104
|
remoteMessageDTO,
|
|
97
|
-
receivers,
|
|
105
|
+
[...this.usersIds], // receivers,
|
|
98
106
|
);
|
|
107
|
+
|
|
108
|
+
//
|
|
109
|
+
remoteMessageDTO.notification_type = NotificationTypes.UPDATE_DIALOG;
|
|
110
|
+
|
|
111
|
+
if (updatedRecivers) {
|
|
112
|
+
if (updatedRecivers.length > 0) {
|
|
113
|
+
this.eventMessagesRepository.dispatchEvent<RemoteMessageDTO>(
|
|
114
|
+
EventMessageType.SystemMessage,
|
|
115
|
+
remoteMessageDTO,
|
|
116
|
+
updatedRecivers,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//
|
|
99
122
|
}
|
|
100
123
|
|
|
101
124
|
return resultOperation;
|
|
@@ -19,8 +19,9 @@ export class SendTextMessageUseCase implements IUseCase<void, MessageEntity> {
|
|
|
19
19
|
async execute(): Promise<MessageEntity> {
|
|
20
20
|
console.log('execute SendTextMessageUseCase');
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const sentMessage: MessageEntity =
|
|
23
|
+
await this.messagesRepository.sendMessageToRemote(this.messageToSend);
|
|
23
24
|
|
|
24
|
-
return Promise.resolve(
|
|
25
|
+
return Promise.resolve(sentMessage);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -51,6 +51,12 @@ export class SubscribeToDialogEventsUseCase extends BaseUseCase<
|
|
|
51
51
|
this.EVENT_NAME,
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
+
this.eventMessagesRepository.subscribeOnSystemMessaging(
|
|
55
|
+
NotificationTypes.REMOVE_USER,
|
|
56
|
+
this.removeUserDialogEventHandler.bind(this),
|
|
57
|
+
this.EVENT_NAME,
|
|
58
|
+
);
|
|
59
|
+
|
|
54
60
|
this.eventMessagesRepository.subscribeOnSystemMessaging(
|
|
55
61
|
NotificationTypes.UPDATE_DIALOG,
|
|
56
62
|
this.updateDialogEventHandler.bind(this),
|
|
@@ -124,6 +130,21 @@ export class SubscribeToDialogEventsUseCase extends BaseUseCase<
|
|
|
124
130
|
this.informSubscribers(messageInfo);
|
|
125
131
|
}
|
|
126
132
|
|
|
133
|
+
removeUserDialogEventHandler(messageEntity: MessageEntity): void {
|
|
134
|
+
console.log(
|
|
135
|
+
'execute removeUserDialogEventHandler in SubscribeToDialogEventsUseCase:',
|
|
136
|
+
JSON.stringify(messageEntity),
|
|
137
|
+
);
|
|
138
|
+
const messageInfo: DialogEventInfo = {
|
|
139
|
+
messageInfo: messageEntity,
|
|
140
|
+
notificationTypes: NotificationTypes.REMOVE_USER,
|
|
141
|
+
eventMessageType: EventMessageType.SystemMessage,
|
|
142
|
+
messageStatus: undefined,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
this.informSubscribers(messageInfo);
|
|
146
|
+
}
|
|
147
|
+
|
|
127
148
|
newDialogEventHandler(messageEntity: MessageEntity): void {
|
|
128
149
|
console.log(
|
|
129
150
|
'execute newDialogEventHandler in SubscribeToDialogEventsUseCase:',
|
|
@@ -14,15 +14,19 @@ export class UpdateDialogUseCase implements IUseCase<void, DialogEntity> {
|
|
|
14
14
|
|
|
15
15
|
private updateDialog: GroupDialogEntity;
|
|
16
16
|
|
|
17
|
+
private textInformationMessage: string;
|
|
18
|
+
|
|
17
19
|
constructor(
|
|
18
20
|
eventMessagesRepository: EventMessagesRepository,
|
|
19
21
|
dialogRepository: DialogsRepository,
|
|
20
22
|
updateDialog: GroupDialogEntity,
|
|
23
|
+
textInformationMessage: string,
|
|
21
24
|
) {
|
|
22
25
|
console.log('CONSTRUCTOR UpdateDialogUseCase');
|
|
23
26
|
this.dialogRepository = dialogRepository;
|
|
24
27
|
this.updateDialog = updateDialog;
|
|
25
28
|
this.eventMessagesRepository = eventMessagesRepository;
|
|
29
|
+
this.textInformationMessage = textInformationMessage;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
async execute(): Promise<DialogEntity> {
|
|
@@ -37,7 +41,10 @@ export class UpdateDialogUseCase implements IUseCase<void, DialogEntity> {
|
|
|
37
41
|
remoteMessageDTO.dialogId = result.id;
|
|
38
42
|
remoteMessageDTO.notification_type = NotificationTypes.UPDATE_DIALOG;
|
|
39
43
|
remoteMessageDTO.date_sent = Date.now();
|
|
40
|
-
remoteMessageDTO.message =
|
|
44
|
+
remoteMessageDTO.message =
|
|
45
|
+
this.textInformationMessage && this.textInformationMessage.length > 0
|
|
46
|
+
? this.textInformationMessage
|
|
47
|
+
: `User ${this.updateDialog.ownerId} has updated dialog ${this.updateDialog.name}`;
|
|
41
48
|
|
|
42
49
|
this.eventMessagesRepository.dispatchEvent<RemoteMessageDTO>(
|
|
43
50
|
EventMessageType.RegularMessage,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// eslint-disable-next-line import/extensions
|
|
2
|
+
import { QBAIAnswerAssistant } from 'qb-ai-answer-assistant';
|
|
3
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
4
|
+
import { IUseCase } from '../base/IUseCase';
|
|
5
|
+
|
|
6
|
+
export class AIAnswerAssistUseCase implements IUseCase<void, string> {
|
|
7
|
+
private textToSend: string;
|
|
8
|
+
|
|
9
|
+
private dialogMessages: IChatMessage[];
|
|
10
|
+
|
|
11
|
+
private servername: string;
|
|
12
|
+
|
|
13
|
+
private api: string;
|
|
14
|
+
|
|
15
|
+
private port: string;
|
|
16
|
+
|
|
17
|
+
private sessionToken: string;
|
|
18
|
+
|
|
19
|
+
private openAIModel: string;
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
textToSend: string,
|
|
23
|
+
dialogMessages: IChatMessage[],
|
|
24
|
+
servername: string,
|
|
25
|
+
api: string,
|
|
26
|
+
port: string,
|
|
27
|
+
sessionToken: string,
|
|
28
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
29
|
+
) {
|
|
30
|
+
console.log('CONSTRUCTOR AIRephraseUseCase');
|
|
31
|
+
this.api = api;
|
|
32
|
+
this.openAIModel = openAIModel;
|
|
33
|
+
this.port = port;
|
|
34
|
+
this.sessionToken = sessionToken;
|
|
35
|
+
this.textToSend = textToSend;
|
|
36
|
+
this.servername = servername;
|
|
37
|
+
this.dialogMessages = dialogMessages;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async execute(): Promise<string> {
|
|
41
|
+
console.log('execute AIRephraseUseCase');
|
|
42
|
+
const settings =
|
|
43
|
+
QBAIAnswerAssistant.createDefaultAIAnswerAssistantSettings();
|
|
44
|
+
|
|
45
|
+
settings.apiKey = this.sessionToken;
|
|
46
|
+
// settings.organization = 'Quickblox';
|
|
47
|
+
settings.model = this.openAIModel;
|
|
48
|
+
|
|
49
|
+
return QBAIAnswerAssistant.createAnswer(
|
|
50
|
+
this.textToSend,
|
|
51
|
+
this.dialogMessages,
|
|
52
|
+
settings,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// const prompt = AIUtils.createAnswerAssistPrompt(this.textToSend);
|
|
56
|
+
//
|
|
57
|
+
// //
|
|
58
|
+
// return AISource.getData(
|
|
59
|
+
// prompt,
|
|
60
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
61
|
+
// this.dialogMessages,
|
|
62
|
+
// this.servername,
|
|
63
|
+
// this.api,
|
|
64
|
+
// this.port,
|
|
65
|
+
// this.sessionToken,
|
|
66
|
+
// this.openAIModel,
|
|
67
|
+
// );
|
|
68
|
+
}
|
|
69
|
+
}
|