robbyson-frontend-library 1.0.82 → 1.0.84
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/dist/constants/chat.constants.js +21 -14
- package/dist/types/chat/chat.types.js +24 -25
- package/dist/utils/chat.utils.js +90 -0
- package/dist/utils/index.js +1 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/interfaces/services_dtos_tree_dto.IAttributesFilterTreeDTO.html +1 -0
- package/docs/interfaces/services_dtos_tree_dto.ICallSimulationProcessTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.ICompleteSimulationTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IConfirmateSimulationTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IFavoriteIndicatorTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IGetProfileTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IGetResultsToExportTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IGetSimulatedResultsTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IGetSimulationTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IGroupByAttributesTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IHandleSearchUser.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IInsertSimulationTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.IMembersBroadcast.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.ISaveSimulationTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.ISelectedDateTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.ISelectedGroups.html +1 -1
- package/docs/interfaces/services_dtos_tree_dto.ISetBreadcrumpTreeDTO.html +2 -2
- package/docs/interfaces/services_dtos_tree_dto.ISetGroups.html +2 -2
- package/docs/interfaces/services_tree_service_interface.ITreeService.html +2 -2
- package/docs/modules/services_dtos_tree_dto.html +2 -1
- package/package.json +1 -1
- package/src/constants/chat.constants.ts +11 -4
- package/src/models/angel-friend-status.model.ts +2 -2
- package/src/models/chat.model.ts +3 -3
- package/src/models/message.model.ts +1 -0
- package/src/models/user-list.model.ts +2 -2
- package/src/repositories/index.d.ts +2 -2
- package/src/services/angel-friend.service.interface.ts +1 -0
- package/src/services/chat.service.interface.ts +26 -6
- package/src/services/dtos/chat.dto.ts +33 -8
- package/src/states/chat-container/chat-app.state.interface.ts +2 -4
- package/src/types/chat/chat.types.ts +53 -52
- package/src/utils/chat.utils.ts +132 -0
- package/src/utils/index.ts +1 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>services/dtos/tree.dto | Robbyson Frontend Library</title><meta name="description" content="Documentation for Robbyson Frontend Library"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">Robbyson Frontend Library</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">Robbyson Frontend Library</a></li><li><a href="services_dtos_tree_dto.html">services/dtos/tree.dto</a></li></ul><h1>Module services/dtos/tree.dto</h1></div><aside class="tsd-sources"><ul><li>Defined in src/services/dtos/tree.dto.ts:1</li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><h3 class="tsd-index-heading uppercase">Index</h3><section class="tsd-index-section"><h3 class="tsd-index-heading">Interfaces</h3><div class="tsd-index-list"><a href="../interfaces/services_dtos_tree_dto.
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>services/dtos/tree.dto | Robbyson Frontend Library</title><meta name="description" content="Documentation for Robbyson Frontend Library"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">Robbyson Frontend Library</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">Robbyson Frontend Library</a></li><li><a href="services_dtos_tree_dto.html">services/dtos/tree.dto</a></li></ul><h1>Module services/dtos/tree.dto</h1></div><aside class="tsd-sources"><ul><li>Defined in src/services/dtos/tree.dto.ts:1</li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><h3 class="tsd-index-heading uppercase">Index</h3><section class="tsd-index-section"><h3 class="tsd-index-heading">Interfaces</h3><div class="tsd-index-list"><a href="../interfaces/services_dtos_tree_dto.IAttributesFilterTreeDTO.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>IAttributes<wbr/>Filter<wbr/>TreeDTO</span></a>
|
|
2
|
+
<a href="../interfaces/services_dtos_tree_dto.IBreadcrumbData.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>IBreadcrumb<wbr/>Data</span></a>
|
|
2
3
|
<a href="../interfaces/services_dtos_tree_dto.ICallSimulationProcessTreeDTO.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>ICall<wbr/>Simulation<wbr/>Process<wbr/>TreeDTO</span></a>
|
|
3
4
|
<a href="../interfaces/services_dtos_tree_dto.ICompleteSimulationTreeDTO.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>IComplete<wbr/>Simulation<wbr/>TreeDTO</span></a>
|
|
4
5
|
<a href="../interfaces/services_dtos_tree_dto.IConfirmateSimulationTreeDTO.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>IConfirmate<wbr/>Simulation<wbr/>TreeDTO</span></a>
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export enum
|
|
1
|
+
export enum TYPE_CHAT {
|
|
2
2
|
CHAT = "chat",
|
|
3
3
|
GROUP = "group",
|
|
4
4
|
GROUPS = "groups",
|
|
5
5
|
CHATBOT = "chat-bot",
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export enum
|
|
8
|
+
export enum CHAT_CLASSIFICATION {
|
|
9
9
|
TREE_MESSAGE = "tree-message",
|
|
10
10
|
ANGEL_FRIEND = "angel-friend",
|
|
11
11
|
}
|
|
@@ -24,9 +24,16 @@ const ALLOWED_EXTENSIONS = new Set([
|
|
|
24
24
|
"pptx",
|
|
25
25
|
]);
|
|
26
26
|
|
|
27
|
+
export enum MEETINGS_SIDEBAR_OPTIONS {
|
|
28
|
+
PARTICIPANTS = "participants",
|
|
29
|
+
CHAT = "chat",
|
|
30
|
+
MENU = "menu",
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
export const ChatConstants = {
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
TYPE_CHAT,
|
|
35
|
+
CHAT_CLASSIFICATION,
|
|
30
36
|
ALLOWED_EXTENSIONS,
|
|
31
37
|
IMAGE_EXTENSIONS,
|
|
38
|
+
MEETINGS_SIDEBAR_OPTIONS,
|
|
32
39
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseRepositoryModel } from "./base.repository.model";
|
|
2
2
|
import { IProfileImageProps } from "../components/profile-image/profile-image.interface";
|
|
3
3
|
import { IBaseComponentProp } from "../components/base-component.prop.interface";
|
|
4
|
-
import {
|
|
4
|
+
import { CHAT_CLASSIFICATION } from "../constants";
|
|
5
5
|
|
|
6
6
|
export class AngelFriendStatusModel extends BaseRepositoryModel {
|
|
7
7
|
configuration: IConfiguration;
|
|
@@ -186,7 +186,7 @@ export interface IAngelFriendProfileImageProps
|
|
|
186
186
|
extends IProfileImageProps,
|
|
187
187
|
IBaseComponentProp {
|
|
188
188
|
robbysonUserId?: number;
|
|
189
|
-
classification?:
|
|
189
|
+
classification?: CHAT_CLASSIFICATION | "";
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
export interface INotification {
|
package/src/models/chat.model.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CHAT_CLASSIFICATION, TYPE_CHAT } from "../constants";
|
|
2
2
|
import { UserListModel } from "./user-list.model";
|
|
3
3
|
|
|
4
4
|
export class ChatModel {
|
|
@@ -9,7 +9,7 @@ export class ChatModel {
|
|
|
9
9
|
name: string;
|
|
10
10
|
names?: string[];
|
|
11
11
|
temporary?: boolean;
|
|
12
|
-
type?:
|
|
12
|
+
type?: TYPE_CHAT;
|
|
13
13
|
users?: ChatUser[];
|
|
14
14
|
_id: string;
|
|
15
15
|
id?: string;
|
|
@@ -22,7 +22,7 @@ export class ChatModel {
|
|
|
22
22
|
admin?: boolean;
|
|
23
23
|
active?: boolean;
|
|
24
24
|
deleted?: boolean;
|
|
25
|
-
classification?:
|
|
25
|
+
classification?: CHAT_CLASSIFICATION;
|
|
26
26
|
isUserActive?: boolean;
|
|
27
27
|
lastUpdatedBy?: string;
|
|
28
28
|
lastUpdatedAt?: Date;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CHAT_CLASSIFICATION } from "../constants";
|
|
2
2
|
import { BaseRepositoryModel } from "./base.repository.model";
|
|
3
3
|
import { ChatUser } from "./chat.model";
|
|
4
4
|
|
|
@@ -26,7 +26,7 @@ export class UserListModel extends BaseRepositoryModel {
|
|
|
26
26
|
profileImage?: string;
|
|
27
27
|
users?: ChatUser[];
|
|
28
28
|
countNotRead?: number;
|
|
29
|
-
classification?:
|
|
29
|
+
classification?: CHAT_CLASSIFICATION;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
interface System {
|
|
@@ -21,7 +21,7 @@ export * from "./configuration.repository.interface";
|
|
|
21
21
|
export * from "./hierarchy.repository.interface";
|
|
22
22
|
export * from "./profile.repository.interface";
|
|
23
23
|
export * from "./tips.repository.interface";
|
|
24
|
-
export * from "./goal.repository.interface"
|
|
24
|
+
export * from "./goal.repository.interface";
|
|
25
25
|
export * from "./campaign.repository.interface";
|
|
26
26
|
export * from "./indicator.repository.interface";
|
|
27
27
|
export * from "./currency.repository.interface";
|
|
@@ -33,4 +33,4 @@ export * from "./module.repository.interface";
|
|
|
33
33
|
export * from "./portal-dashboard.repository.interface";
|
|
34
34
|
export * from "./socket.repository.interface";
|
|
35
35
|
export * from "./sounds.repository.interface";
|
|
36
|
-
export * from "./contractor.repository.interface";
|
|
36
|
+
export * from "./contractor.repository.interface";
|
|
@@ -50,13 +50,22 @@ export interface IChatService {
|
|
|
50
50
|
getMemberSidebar(): ChatDTO.IMemberSidebar;
|
|
51
51
|
setMemberSidebar(data: ChatDTO.IMemberSidebar): void;
|
|
52
52
|
getMessages(
|
|
53
|
-
|
|
53
|
+
chat: ChatModel,
|
|
54
54
|
params: ChatDTO.IGetMessagesDTO
|
|
55
|
-
): Promise<
|
|
55
|
+
): Promise<ChatDTO.IChatFormattedMessage[]>;
|
|
56
56
|
decryptConversationMessage(text: string, chat: ChatModel): string;
|
|
57
57
|
clearMessages(message: ChatDTO.IClearMessages): void;
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
setMessageError(conversationId: string, temp_id: string): void;
|
|
59
|
+
sendMessage(
|
|
60
|
+
newMessage: ChatDTO.INewMessageInterface,
|
|
61
|
+
temp_id: string
|
|
62
|
+
): Promise<void>;
|
|
63
|
+
sendFile(
|
|
64
|
+
file: File,
|
|
65
|
+
fileExtension: string,
|
|
66
|
+
newMessage: ChatDTO.INewMessageInterface,
|
|
67
|
+
temp_id: string
|
|
68
|
+
): Promise<void>;
|
|
60
69
|
clearConversation(conversationId: string): Promise<void>;
|
|
61
70
|
setFavoriteMessage(
|
|
62
71
|
conversationId: string,
|
|
@@ -76,8 +85,14 @@ export interface IChatService {
|
|
|
76
85
|
user: UserDTO.GetUserDTO
|
|
77
86
|
): Promise<void>;
|
|
78
87
|
addMessage(message: ChatDTO.ISubscribeMessage): void;
|
|
79
|
-
updateUsers(message: {
|
|
80
|
-
|
|
88
|
+
updateUsers(message: {
|
|
89
|
+
conversation_id: string;
|
|
90
|
+
identification: string;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
updateGroup(message: {
|
|
93
|
+
conversation_id: string;
|
|
94
|
+
identification: string;
|
|
95
|
+
}): Promise<void>;
|
|
81
96
|
getConversationSidebar(): ChatDTO.IConversationDTO;
|
|
82
97
|
setConversationSidebar(payload: ChatDTO.IConversationDTO): void;
|
|
83
98
|
sendBroadcast(
|
|
@@ -104,4 +119,9 @@ export interface IChatService {
|
|
|
104
119
|
avoidCheckUserInCall?: boolean
|
|
105
120
|
): Promise<void>;
|
|
106
121
|
updateMessage(payload: MessageModel): Promise<MessageModel>;
|
|
122
|
+
getStateMessages(conversationId: string): ChatDTO.IStateMessages;
|
|
123
|
+
canSendMessages(chat: ChatModel): Promise<boolean>;
|
|
124
|
+
canSendFiles(canSendMessages: boolean): boolean;
|
|
125
|
+
isChatPage(conversationId?: string): boolean;
|
|
126
|
+
getCurrentConversations(search?: string): ChatModel[];
|
|
107
127
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CHAT_CLASSIFICATION, TYPE_CHAT } from "../../constants";
|
|
2
2
|
import { ChatModel, MessageModel, UserListModel } from "../../models";
|
|
3
3
|
import { GetUserDTO } from "./user.dto";
|
|
4
4
|
|
|
@@ -22,7 +22,7 @@ export interface ICreateConversationDTO {
|
|
|
22
22
|
temporary?: boolean;
|
|
23
23
|
photo?: string;
|
|
24
24
|
admin?: boolean;
|
|
25
|
-
classification?:
|
|
25
|
+
classification?: CHAT_CLASSIFICATION;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface IUpdateGroupDTO {
|
|
@@ -32,7 +32,7 @@ export interface IUpdateGroupDTO {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface IUpdateClassificationDTO {
|
|
35
|
-
classification:
|
|
35
|
+
classification: CHAT_CLASSIFICATION;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface IChatPermissions {
|
|
@@ -68,14 +68,14 @@ export interface RequestPayload {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export interface IGetMessagesDTO {
|
|
71
|
-
page
|
|
72
|
-
per
|
|
71
|
+
page: number;
|
|
72
|
+
per: number;
|
|
73
73
|
search?: string;
|
|
74
74
|
name?: string;
|
|
75
75
|
identification?: string;
|
|
76
76
|
classification?: string;
|
|
77
77
|
favorite?: boolean;
|
|
78
|
-
type?:
|
|
78
|
+
type?: TYPE_CHAT;
|
|
79
79
|
append?: boolean;
|
|
80
80
|
direction?: string;
|
|
81
81
|
}
|
|
@@ -125,7 +125,7 @@ export interface IChatBotFormattedMessage {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
export interface IChatFormattedMessage extends MessageModel {
|
|
128
|
-
|
|
128
|
+
temp_id?: string;
|
|
129
129
|
uncryptedText?: string;
|
|
130
130
|
content: string;
|
|
131
131
|
from: "me" | "other";
|
|
@@ -161,7 +161,8 @@ export interface IConversationDTO extends Partial<ChatModel> {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
export interface IChatMessages {
|
|
164
|
-
data:
|
|
164
|
+
data: IChatFormattedMessage[];
|
|
165
|
+
hasMoreResults: boolean;
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
export interface IChatListSidebar {
|
|
@@ -186,6 +187,29 @@ export interface ISubscribeMessage {
|
|
|
186
187
|
conversation?: ChatModel;
|
|
187
188
|
}
|
|
188
189
|
|
|
190
|
+
export interface ISetChatMessages {
|
|
191
|
+
conversations?: ChatModel[];
|
|
192
|
+
chatMessages: { [conversationId: string]: IChatMessages };
|
|
193
|
+
countNotRead?: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface INewChatMessage {
|
|
197
|
+
conversations: ChatModel[];
|
|
198
|
+
chatMessages: { [conversationId: string]: IChatMessages };
|
|
199
|
+
smallChats?: ISmallChat[];
|
|
200
|
+
countNotRead?: number;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface IStateMessages {
|
|
204
|
+
messages: IChatFormattedMessage[];
|
|
205
|
+
hasMoreResults: boolean;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface INewMessageInterface {
|
|
209
|
+
text: string;
|
|
210
|
+
chat: ChatModel;
|
|
211
|
+
}
|
|
212
|
+
|
|
189
213
|
export interface IUpdatedUsers {
|
|
190
214
|
conversation_id: string;
|
|
191
215
|
user: ChatModel;
|
|
@@ -198,4 +222,5 @@ export interface IUpdatedGroup {
|
|
|
198
222
|
|
|
199
223
|
export interface IClearMessages {
|
|
200
224
|
conversation_id: string;
|
|
225
|
+
identification: string;
|
|
201
226
|
}
|
|
@@ -3,11 +3,9 @@ import { ChatDTO } from "../../services";
|
|
|
3
3
|
|
|
4
4
|
export interface IChatApp {
|
|
5
5
|
activeConversations: {
|
|
6
|
-
conversation_id: string
|
|
6
|
+
conversation_id: string;
|
|
7
7
|
}[];
|
|
8
|
-
chatListSideBar:
|
|
9
|
-
isOpen: boolean;
|
|
10
|
-
};
|
|
8
|
+
chatListSideBar: ChatDTO.IChatListSidebar;
|
|
11
9
|
smallChats: ChatDTO.ISmallChat[];
|
|
12
10
|
profileSideBar: {
|
|
13
11
|
isOpen: boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TYPE_CHAT } from "../../constants";
|
|
2
2
|
|
|
3
3
|
export enum Classification {
|
|
4
|
-
tree_message =
|
|
5
|
-
angel_friend =
|
|
6
|
-
}
|
|
4
|
+
tree_message = "tree-message",
|
|
5
|
+
angel_friend = "angel-friend",
|
|
6
|
+
}
|
|
7
7
|
|
|
8
8
|
export enum MessagesType {
|
|
9
|
-
ALL =
|
|
10
|
-
FAVORITE =
|
|
9
|
+
ALL = "all",
|
|
10
|
+
FAVORITE = "fav",
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export type Parameters = {
|
|
@@ -18,8 +18,8 @@ export type Parameters = {
|
|
|
18
18
|
identification?: string;
|
|
19
19
|
classification?: string;
|
|
20
20
|
favorite?: boolean;
|
|
21
|
-
type?:
|
|
22
|
-
}
|
|
21
|
+
type?: TYPE_CHAT;
|
|
22
|
+
};
|
|
23
23
|
|
|
24
24
|
export type PaginationParams = {
|
|
25
25
|
pages: number[];
|
|
@@ -28,19 +28,19 @@ export type PaginationParams = {
|
|
|
28
28
|
per: number;
|
|
29
29
|
markPositionId?: number;
|
|
30
30
|
favorite?: boolean;
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
|
|
33
33
|
export type SearchMessageDTO = {
|
|
34
34
|
page?: number;
|
|
35
35
|
per?: number;
|
|
36
36
|
searchMessage: string;
|
|
37
37
|
pagesParam?: number[];
|
|
38
|
-
}
|
|
38
|
+
};
|
|
39
39
|
|
|
40
40
|
export type ColorsGroup = {
|
|
41
41
|
primary: string;
|
|
42
42
|
secondary: string;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
|
|
45
45
|
export type UserChatDTO = {
|
|
46
46
|
name?: string;
|
|
@@ -77,13 +77,13 @@ export type User = {
|
|
|
77
77
|
color?: string;
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
export type ConversationWindowSize =
|
|
80
|
+
export type ConversationWindowSize = "minimized" | "normal" | "fullscreen";
|
|
81
81
|
|
|
82
82
|
export type Conversation = {
|
|
83
83
|
_id: string;
|
|
84
84
|
name: string;
|
|
85
85
|
description: string;
|
|
86
|
-
type:
|
|
86
|
+
type: TYPE_CHAT;
|
|
87
87
|
colors: ColorsGroup;
|
|
88
88
|
users: User[];
|
|
89
89
|
countNotRead: number;
|
|
@@ -93,34 +93,34 @@ export type Conversation = {
|
|
|
93
93
|
windowSize: ConversationWindowSize;
|
|
94
94
|
opened: boolean;
|
|
95
95
|
openedAt: Date;
|
|
96
|
-
}
|
|
96
|
+
};
|
|
97
97
|
|
|
98
98
|
export type ConversationDTO = {
|
|
99
99
|
name?: string;
|
|
100
100
|
description?: string;
|
|
101
|
-
type?:
|
|
101
|
+
type?: TYPE_CHAT;
|
|
102
102
|
users?: UserChatDTO[];
|
|
103
103
|
temporary?: boolean;
|
|
104
104
|
photo?: string;
|
|
105
|
-
}
|
|
105
|
+
};
|
|
106
106
|
|
|
107
107
|
export type UpdateGroupDTO = {
|
|
108
108
|
name?: string;
|
|
109
109
|
description?: string;
|
|
110
110
|
photo?: string;
|
|
111
|
-
}
|
|
111
|
+
};
|
|
112
112
|
|
|
113
113
|
export type Conversations = {
|
|
114
114
|
data: Conversation[];
|
|
115
115
|
meta: Meta;
|
|
116
|
-
}
|
|
116
|
+
};
|
|
117
117
|
|
|
118
|
-
export type File ={
|
|
118
|
+
export type File = {
|
|
119
119
|
fileName: string;
|
|
120
120
|
attachment: string;
|
|
121
121
|
publicUrl: string;
|
|
122
122
|
fileType: string;
|
|
123
|
-
}
|
|
123
|
+
};
|
|
124
124
|
|
|
125
125
|
export type Message = {
|
|
126
126
|
conversation_id: string;
|
|
@@ -130,15 +130,15 @@ export type Message = {
|
|
|
130
130
|
_id?: string;
|
|
131
131
|
message_id?: string;
|
|
132
132
|
receiver?: string;
|
|
133
|
-
favorite?: boolean
|
|
134
|
-
hidden?: boolean
|
|
135
|
-
temp?: boolean
|
|
133
|
+
favorite?: boolean;
|
|
134
|
+
hidden?: boolean;
|
|
135
|
+
temp?: boolean;
|
|
136
136
|
temp_id?: string;
|
|
137
137
|
readAt?: Date;
|
|
138
138
|
sendedAt?: Date;
|
|
139
139
|
sentAt?: Date;
|
|
140
140
|
file?: File;
|
|
141
|
-
}
|
|
141
|
+
};
|
|
142
142
|
|
|
143
143
|
export type MessageDTO = {
|
|
144
144
|
conversation_id?: string;
|
|
@@ -148,9 +148,9 @@ export type MessageDTO = {
|
|
|
148
148
|
receivedAt?: Date;
|
|
149
149
|
temp_id?: string;
|
|
150
150
|
temp?: boolean;
|
|
151
|
-
file?: File
|
|
151
|
+
file?: File;
|
|
152
152
|
_id?: string;
|
|
153
|
-
}
|
|
153
|
+
};
|
|
154
154
|
|
|
155
155
|
export type Meta = {
|
|
156
156
|
page?: number;
|
|
@@ -159,12 +159,12 @@ export type Meta = {
|
|
|
159
159
|
totalDocs?: number;
|
|
160
160
|
type?: string;
|
|
161
161
|
favorite?: boolean;
|
|
162
|
-
}
|
|
162
|
+
};
|
|
163
163
|
|
|
164
164
|
export type Messages = {
|
|
165
165
|
data: Message[];
|
|
166
166
|
meta: Meta;
|
|
167
|
-
}
|
|
167
|
+
};
|
|
168
168
|
export interface State {
|
|
169
169
|
data: {
|
|
170
170
|
isChatListVisible: boolean;
|
|
@@ -186,27 +186,28 @@ export interface State {
|
|
|
186
186
|
isLoading: boolean;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
export const SET_CHAT_LIST_VISIBILITY =
|
|
190
|
-
export const SET_SEARCH_MESSAGE =
|
|
191
|
-
export const SET_MARK_POSITION_ID =
|
|
192
|
-
export const CLEAR_SEARCH_MESSAGE =
|
|
193
|
-
export const OPEN_CONVERSATION =
|
|
194
|
-
export const CLOSE_CONVERSATION =
|
|
195
|
-
export const SUCCESS_CONVERSATIONS =
|
|
196
|
-
export const SUCCESS_CONVERSATION =
|
|
197
|
-
export const SUCCESS_MESSAGES =
|
|
198
|
-
export const ADD_MESSAGE =
|
|
199
|
-
export const UPDATE_CONVERSATION =
|
|
200
|
-
export const UPDATE_USERS =
|
|
201
|
-
export const UPDATE_MESSAGES =
|
|
202
|
-
export const UPDATE_MESSAGE =
|
|
203
|
-
export const UPDATE_MESSAGE_BY_MESSAGE_ID =
|
|
204
|
-
export const UPDATE_GROUP =
|
|
205
|
-
export const UPDATE_COUNT_NOT_READ_CONVERSATION =
|
|
206
|
-
|
|
207
|
-
export const
|
|
208
|
-
export const
|
|
209
|
-
export const
|
|
210
|
-
export const
|
|
211
|
-
export const
|
|
212
|
-
export const
|
|
189
|
+
export const SET_CHAT_LIST_VISIBILITY = "chat/SET_CHAT_LIST_VISIBILITY";
|
|
190
|
+
export const SET_SEARCH_MESSAGE = "chat/SET_SEARCH_MESSAGE";
|
|
191
|
+
export const SET_MARK_POSITION_ID = "chat/SET_MARK_POSITION_ID";
|
|
192
|
+
export const CLEAR_SEARCH_MESSAGE = "chat/CLEAR_SEARCH_MESSAGE";
|
|
193
|
+
export const OPEN_CONVERSATION = "chat/OPEN_CONVERSATION";
|
|
194
|
+
export const CLOSE_CONVERSATION = "chat/CLOSE_CONVERSATION";
|
|
195
|
+
export const SUCCESS_CONVERSATIONS = "chat/SUCCESS_CONVERSATIONS";
|
|
196
|
+
export const SUCCESS_CONVERSATION = "chat/SUCCESS_CONVERSATION";
|
|
197
|
+
export const SUCCESS_MESSAGES = "chat/SUCCESS_MESSAGES";
|
|
198
|
+
export const ADD_MESSAGE = "chat/ADD_MESSAGE";
|
|
199
|
+
export const UPDATE_CONVERSATION = "chat/UPDATE_CONVERSATION";
|
|
200
|
+
export const UPDATE_USERS = "chat/UPDATE_USERS";
|
|
201
|
+
export const UPDATE_MESSAGES = "chat/UPDATE_MESSAGES";
|
|
202
|
+
export const UPDATE_MESSAGE = "chat/UPDATE_MESSAGE";
|
|
203
|
+
export const UPDATE_MESSAGE_BY_MESSAGE_ID = "chat/UPDATE_MESSAGE_BY_MESSAGE_ID";
|
|
204
|
+
export const UPDATE_GROUP = "chat/UPDATE_GROUP";
|
|
205
|
+
export const UPDATE_COUNT_NOT_READ_CONVERSATION =
|
|
206
|
+
"chat/UPDATE_COUNT_NOT_READ_CONVERSATION";
|
|
207
|
+
export const UPDATE_CONVERSATIONS = "chat/UPDATE_CONVERSATIONS";
|
|
208
|
+
export const SET_FILTERS = "chat/SET_FILTERS";
|
|
209
|
+
export const HAS_ERROR = "chat/HAS_ERROR";
|
|
210
|
+
export const IS_LOADING = "chat/IS_LOADING";
|
|
211
|
+
export const LOGOUT = "chat/LOGOUT";
|
|
212
|
+
export const SET_CONTAINER_OPEN = "chat/SET_CONTAINER_OPEN";
|
|
213
|
+
export const SET_CHAT_MODAL_PREVIEW = "chat/SET_CHAT_MODAL_PREVIEW";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { ChatDTO } from "../services";
|
|
2
|
+
import { ChatModel } from "../models";
|
|
3
|
+
import { ChatConstants } from "../constants";
|
|
4
|
+
import _ from "lodash";
|
|
5
|
+
|
|
6
|
+
function getCanSendToSuperiors(
|
|
7
|
+
chat: ChatModel,
|
|
8
|
+
chatPermissions: ChatDTO.IChatPermissions,
|
|
9
|
+
quitedGroup: boolean,
|
|
10
|
+
identification: string,
|
|
11
|
+
userHierarchy: number
|
|
12
|
+
): boolean {
|
|
13
|
+
if (
|
|
14
|
+
quitedGroup ||
|
|
15
|
+
!chatPermissions.canSendToSuperiors ||
|
|
16
|
+
chatPermissions.canSend
|
|
17
|
+
) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (chat.users) {
|
|
22
|
+
for (const user of chat.users) {
|
|
23
|
+
if (
|
|
24
|
+
identification !== user.identification &&
|
|
25
|
+
user.active &&
|
|
26
|
+
!user.deleted &&
|
|
27
|
+
user.isUserActive &&
|
|
28
|
+
user.hierarchyLevel
|
|
29
|
+
) {
|
|
30
|
+
if (userHierarchy && userHierarchy < user.hierarchyLevel) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getIsParentImmediateInChatAndCanSend(
|
|
41
|
+
chat: ChatModel,
|
|
42
|
+
chatPermissions: ChatDTO.IChatPermissions,
|
|
43
|
+
quitedGroup: boolean,
|
|
44
|
+
parentImmediate: string
|
|
45
|
+
): boolean {
|
|
46
|
+
if (
|
|
47
|
+
quitedGroup ||
|
|
48
|
+
!chatPermissions.canSendToParentImmediate ||
|
|
49
|
+
chatPermissions.canSend ||
|
|
50
|
+
!parentImmediate ||
|
|
51
|
+
!chat.users
|
|
52
|
+
) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return chat.users.some(
|
|
57
|
+
(user) =>
|
|
58
|
+
user.identification === parentImmediate &&
|
|
59
|
+
user.active &&
|
|
60
|
+
!user.deleted &&
|
|
61
|
+
user.isUserActive
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function checkNotInGroup(chat: ChatModel, identification: string): boolean {
|
|
66
|
+
const user = chat.users?.find(
|
|
67
|
+
(user) => user.identification === identification
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const quitedGroup =
|
|
71
|
+
chat.type !== ChatConstants.TYPE_CHAT.GROUP
|
|
72
|
+
? false
|
|
73
|
+
: !user?.active || user.deleted;
|
|
74
|
+
|
|
75
|
+
return quitedGroup;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function checkIfUserIsSingleAdmin(
|
|
79
|
+
identification: string,
|
|
80
|
+
group?: ChatModel
|
|
81
|
+
): boolean {
|
|
82
|
+
if (!group || !group.users || group.users.length === 0 || !identification)
|
|
83
|
+
return false;
|
|
84
|
+
|
|
85
|
+
let isAdmin = false;
|
|
86
|
+
let adminCount = 0;
|
|
87
|
+
|
|
88
|
+
for (const user of group.users) {
|
|
89
|
+
if (user.identification === identification) {
|
|
90
|
+
isAdmin = user.admin;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (user.admin) {
|
|
94
|
+
adminCount++;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return isAdmin && adminCount === 1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function getChatName(chat: ChatModel): string {
|
|
102
|
+
return chat.type !== ChatConstants.TYPE_CHAT.GROUP
|
|
103
|
+
? _.startCase(chat.name?.toLowerCase())
|
|
104
|
+
: chat.name;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function getPlaceholderMessage(
|
|
108
|
+
canSendMessages: boolean,
|
|
109
|
+
isActive: boolean
|
|
110
|
+
): string {
|
|
111
|
+
if (!isActive) return "inactive_user";
|
|
112
|
+
|
|
113
|
+
if (!canSendMessages) return "chat_type_your_message_no_permission";
|
|
114
|
+
|
|
115
|
+
return "chat_type_your_message";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function generateMessageTempId(): string {
|
|
119
|
+
const timestamp = Date.now().toString(36);
|
|
120
|
+
const randomNum = Math.random().toString(36).substring(2, 8);
|
|
121
|
+
return `${timestamp}-${randomNum}`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export const ChatUtils = {
|
|
125
|
+
getCanSendToSuperiors,
|
|
126
|
+
getIsParentImmediateInChatAndCanSend,
|
|
127
|
+
checkNotInGroup,
|
|
128
|
+
checkIfUserIsSingleAdmin,
|
|
129
|
+
getChatName,
|
|
130
|
+
getPlaceholderMessage,
|
|
131
|
+
generateMessageTempId,
|
|
132
|
+
};
|
package/src/utils/index.ts
CHANGED