@phonghq/go-chat 1.0.23 → 1.0.25
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 +1 -1
- package/dist/assets/icons/IconCloseCircle.vue.d.ts +2 -0
- package/dist/assets/icons/IconSetting.vue.d.ts +2 -0
- package/dist/chat/App.vue.d.ts +2 -0
- package/dist/chat/page/home/ChatList.vue.d.ts +6 -3
- package/dist/chat/page/home/ChatMessage.vue.d.ts +2 -0
- package/dist/chat/page/home/ChatMessageItem.vue.d.ts +18 -0
- package/dist/chat/page/home/Home.vue.d.ts +4 -0
- package/dist/chat/page/setting/Setting.vue.d.ts +2 -0
- package/dist/components/chat/call/Calling.vue.d.ts +2 -0
- package/dist/components/chat/common/switch/SwitchBase.vue.d.ts +14 -0
- package/dist/components/chat/common/tab/TabBase.vue.d.ts +30 -0
- package/dist/components/chat/select/SelectBase.vue.d.ts +2 -0
- package/dist/components/common/drawer/DrawerBase.vue.d.ts +1 -1
- package/dist/components/common/drawer/DrawerBaseCustom.vue.d.ts +1 -0
- package/dist/composable/useCallHelper.d.ts +2 -0
- package/dist/composable/useListConversations.d.ts +48 -0
- package/dist/constant/color.d.ts +2 -2
- package/dist/go-chat.es.js +28838 -28734
- package/dist/go-chat.umd.js +14 -14
- package/dist/style.css +1 -1
- package/dist/test/assets/icons/IconCloseCircle.vue.js +36 -0
- package/dist/test/assets/icons/IconSetting.vue.js +33 -0
- package/dist/test/chat/App.vue.js +191 -90
- package/dist/test/chat/page/customer-detail/CustomerDetail.vue.js +0 -3
- package/dist/test/chat/page/home/ChatList.vue.js +225 -137
- package/dist/test/chat/page/home/ChatMessage.vue.js +45 -181
- package/dist/test/chat/page/home/ChatMessageItem.vue.js +335 -0
- package/dist/test/chat/page/home/Home.vue.js +38 -65
- package/dist/test/chat/page/home/HomeHeader.vue.js +18 -18
- package/dist/test/chat/page/home/InputChat.vue.js +62 -34
- package/dist/test/chat/page/setting/Setting.vue.js +125 -0
- package/dist/test/components/chat/call/Calling.vue.js +36 -24
- package/dist/test/components/chat/common/switch/SwitchBase.vue.js +70 -0
- package/dist/test/components/chat/common/tab/TabBase.vue.js +85 -0
- package/dist/test/components/chat/select/SelectBase.vue.js +26 -18
- package/dist/test/components/common/drawer/DrawerBaseCustom.vue.js +9 -4
- package/dist/test/composable/useDigibot.js +2 -1
- package/dist/test/composable/useInitData.js +4 -7
- package/dist/test/composable/useListConversations.js +124 -0
- package/dist/test/composable/usePlivo.js +18 -6
- package/dist/test/constant/color.js +4 -2
- package/dist/test/types/chat/call.js +4 -1
- package/dist/test/utils/chat/auth.js +15 -0
- package/dist/test/utils/chat/conversation.js +57 -0
- package/dist/test/utils/chat/phone-string.js +1 -1
- package/dist/types/chat/auth.d.ts +2 -0
- package/dist/types/chat/call.d.ts +3 -0
- package/dist/types/chat/global.d.ts +1 -0
- package/dist/types/conversation.d.ts +3 -1
- package/dist/types/message.d.ts +6 -0
- package/dist/utils/chat/auth.d.ts +5 -0
- package/dist/utils/chat/conversation.d.ts +7 -0
- package/dist/utils/chat/phone-string.d.ts +1 -1
- package/dist/utils/chat/user.d.ts +2 -0
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ import { PLIVO_CALL_STATUS } from '../types/chat/call';
|
|
|
2
2
|
export function usePlivo(callback) {
|
|
3
3
|
var options = {
|
|
4
4
|
debug: 'ALL',
|
|
5
|
-
permOnClick: true,
|
|
6
5
|
deviceParams: {
|
|
7
6
|
micEnabled: true,
|
|
8
7
|
audioConstraints: { audio: true, video: false }
|
|
@@ -25,18 +24,21 @@ export function usePlivo(callback) {
|
|
|
25
24
|
plivoBrowserSdk.client.on('onCallFailed', (data, callInfo) => {
|
|
26
25
|
handleCallFailed(data, callInfo);
|
|
27
26
|
});
|
|
28
|
-
plivoBrowserSdk.client.on('
|
|
27
|
+
plivoBrowserSdk.client.on('onIncomingCallCanceled', (callInfo) => {
|
|
28
|
+
handleIncomingCallCanceled(callInfo);
|
|
29
|
+
});
|
|
30
|
+
// plivoBrowserSdk.client.on('onCalling', (data: any) => console.log('onCallFailed', data))
|
|
29
31
|
plivoBrowserSdk?.client?.on?.('onIncomingCall', (callerID, extraHeaders, callInfo) => {
|
|
30
32
|
handleIncomingCall(callInfo);
|
|
31
33
|
});
|
|
32
34
|
plivoBrowserSdk.client.on('onCallRemoteRinging', (data) => handleCallRemoteRinging(data));
|
|
35
|
+
plivoBrowserSdk.client.on('onMediaPermission', (e) => handleMediaPermission(e));
|
|
33
36
|
// plivoBrowserSdk?.client?.on?.('onReady', () => console.log('Ready'))
|
|
34
37
|
// plivoBrowserSdk?.client?.on?.('onLoginFailed', () => console.log('Login failed'))
|
|
35
38
|
// plivoBrowserSdk?.client?.on?.('remoteAudioStatus', () => console.log('remoteAudioStatus'))
|
|
36
39
|
await plivoBrowserSdk?.client?.login('webcall003079673454891827', '123456abcA!');
|
|
37
|
-
const speaker = document.getElementById(
|
|
38
|
-
if (speaker)
|
|
39
|
-
plivoBrowserSdk?.client?.setAudioElement(speaker);
|
|
40
|
+
// const speaker = document.getElementById('go-chat-remote-audio')
|
|
41
|
+
// if (speaker) plivoBrowserSdk?.client?.setAudioElement(speaker)
|
|
40
42
|
console.log('Registered with token');
|
|
41
43
|
}
|
|
42
44
|
catch (err) {
|
|
@@ -47,7 +49,6 @@ export function usePlivo(callback) {
|
|
|
47
49
|
const data = {
|
|
48
50
|
phone: _getPhone(call.src)
|
|
49
51
|
};
|
|
50
|
-
console.log(call);
|
|
51
52
|
callback(PLIVO_CALL_STATUS.RINGING, data);
|
|
52
53
|
CallUuid = call?.callUUID;
|
|
53
54
|
};
|
|
@@ -63,6 +64,7 @@ export function usePlivo(callback) {
|
|
|
63
64
|
}
|
|
64
65
|
};
|
|
65
66
|
const handleCallTerminated = (data, callInfo) => {
|
|
67
|
+
console.log(data, callInfo);
|
|
66
68
|
if (CallUuid === callInfo.callUUID) {
|
|
67
69
|
callback(PLIVO_CALL_STATUS.CALL_END, { message: data?.reason });
|
|
68
70
|
CallUuid = '';
|
|
@@ -123,9 +125,19 @@ export function usePlivo(callback) {
|
|
|
123
125
|
}
|
|
124
126
|
};
|
|
125
127
|
const handleCallFailed = (data, callInfo) => {
|
|
128
|
+
console.log('handleCallFailed', data);
|
|
126
129
|
if (custom_reject)
|
|
127
130
|
custom_reject?.(data);
|
|
128
131
|
callback(PLIVO_CALL_STATUS.CALL_END, { message: data });
|
|
132
|
+
if (data == 'User Denied Media Access') {
|
|
133
|
+
alert('Microphone access is blocked. Please enable the microphone permission to make a call.');
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const handleIncomingCallCanceled = (callInfo) => {
|
|
137
|
+
callback(PLIVO_CALL_STATUS.CALL_END, { reason: callInfo.reason ?? '' });
|
|
138
|
+
};
|
|
139
|
+
const handleMediaPermission = (e) => {
|
|
140
|
+
console.log('MediaPermission', e);
|
|
129
141
|
};
|
|
130
142
|
return {
|
|
131
143
|
plivoLogin,
|
|
@@ -8,9 +8,11 @@ var Color;
|
|
|
8
8
|
Color["Primary"] = "#0051E6";
|
|
9
9
|
Color["Primary_Hover"] = "#699FF5";
|
|
10
10
|
Color["Primary_RGB"] = "41, 121, 255";
|
|
11
|
-
|
|
11
|
+
// Error = '#ff3b3b',
|
|
12
|
+
Color["Error"] = "#EF4444";
|
|
12
13
|
Color["Error_Hover"] = "#FF8A75";
|
|
13
|
-
|
|
14
|
+
// Success = '#1DA91D',
|
|
15
|
+
Color["Success"] = "#22C55E";
|
|
14
16
|
Color["Success_Hover"] = "#5FD9A0";
|
|
15
17
|
Color["Success_Bg"] = "#E9FFE4";
|
|
16
18
|
Color["Warning"] = "#f3a22c";
|
|
@@ -33,6 +33,20 @@ export const getProfile = async () => {
|
|
|
33
33
|
const res = await axios.get('/api/v1/message/user/me');
|
|
34
34
|
localStorage.setItem('chat_user', JSON.stringify(res));
|
|
35
35
|
dataProfile.value = res;
|
|
36
|
+
// dataProfile.value = Object.fromEntries(
|
|
37
|
+
// Object.entries(res).filter(([key]) => !['tenant_phone'].includes(key))
|
|
38
|
+
// ) as IResProfile
|
|
39
|
+
return res;
|
|
40
|
+
};
|
|
41
|
+
export const checkTenantPhone = async () => {
|
|
42
|
+
const id = localStorage.getItem('chat_id');
|
|
43
|
+
const res = await axios.get(`/api/v1/message/tenant/get-info?tenant_name=${id}`);
|
|
44
|
+
if (res.error || !res?.data)
|
|
45
|
+
throw new Error(res.error);
|
|
46
|
+
if (dataProfile.value)
|
|
47
|
+
dataProfile.value.tenant_phone = res?.data?.go_chat_phone ?? '';
|
|
48
|
+
if (dataProfile.value)
|
|
49
|
+
dataProfile.value.tenant_phone_limit = Number(res?.data?.go_chat_phone_limit ?? 0);
|
|
36
50
|
return res;
|
|
37
51
|
};
|
|
38
52
|
export const submitTenantPhone = async (body) => {
|
|
@@ -48,6 +62,7 @@ export const logout = async () => {
|
|
|
48
62
|
localStorage.removeItem('chat_domain');
|
|
49
63
|
localStorage.removeItem('chat_id');
|
|
50
64
|
try {
|
|
65
|
+
gapMiniAppSdk?.getInstance()?.closeApp?.();
|
|
51
66
|
if (gapMiniAppSdk?.getInstance()?.getBridge()) {
|
|
52
67
|
gapMiniAppSdk?.getInstance()?.closeApp();
|
|
53
68
|
}
|
|
@@ -1,7 +1,64 @@
|
|
|
1
1
|
import axios from '../../plugins/axios';
|
|
2
|
+
import { getCountUnread } from '../../utils/chat/message';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import { DATE_FORMATS, TIME_ZONE_UTC } from '../../constant/datetime';
|
|
5
|
+
import { dataProfile } from '../../utils/chat/auth';
|
|
6
|
+
import { publishMessage } from '../../plugins/mqtt';
|
|
7
|
+
import { TOPIC_HOME } from '../../constant/mqtt';
|
|
2
8
|
export const getConversation = async (param) => {
|
|
3
9
|
const res = await axios.get('/api/v1/message/conversation/get-conversation', {
|
|
4
10
|
params: param
|
|
5
11
|
});
|
|
6
12
|
return res;
|
|
7
13
|
};
|
|
14
|
+
export const publicTopicConversationUpdate = async (data) => {
|
|
15
|
+
const res = await getCountUnread({
|
|
16
|
+
conversation_id: data.infoUser?.conversation_id ?? 0,
|
|
17
|
+
receiver_id: Number(data.infoUser?.id)
|
|
18
|
+
});
|
|
19
|
+
let last_message = data.message ?? '';
|
|
20
|
+
if (data.isSendImg)
|
|
21
|
+
last_message = `You sent images`;
|
|
22
|
+
else if (data.isCall != undefined) {
|
|
23
|
+
if (data.isCall == 'call') {
|
|
24
|
+
last_message = `You sent call`;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
last_message = `${data.infoUser?.username ?? ''} sent call`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const current = dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']);
|
|
31
|
+
const dataMessageForReceiver = {
|
|
32
|
+
id: data.infoUser?.conversation_id ?? 0,
|
|
33
|
+
receiver_id: Number(dataProfile.value?.id ?? 0),
|
|
34
|
+
username: dataProfile.value?.username ?? '',
|
|
35
|
+
phone: dataProfile.value?.phone ?? '',
|
|
36
|
+
avatar: dataProfile.value?.avatar ?? '',
|
|
37
|
+
last_message,
|
|
38
|
+
last_message_time: current,
|
|
39
|
+
created_at: current,
|
|
40
|
+
updated_at: current,
|
|
41
|
+
unread_count: (res?.unread_count ?? 0) + 1,
|
|
42
|
+
status: 1,
|
|
43
|
+
color: dataProfile.value?.color ?? '',
|
|
44
|
+
is_call: dataProfile.value?.color ?? '',
|
|
45
|
+
is_unknown: 0
|
|
46
|
+
};
|
|
47
|
+
publishMessage(`${TOPIC_HOME[0] + Number(data.infoUser?.id)}`, JSON.stringify(dataMessageForReceiver));
|
|
48
|
+
const dataMessageMyself = {
|
|
49
|
+
id: data.infoUser?.conversation_id ?? 0,
|
|
50
|
+
receiver_id: Number(dataProfile.value?.id ?? 0),
|
|
51
|
+
username: data.infoUser?.username ?? '',
|
|
52
|
+
phone: data.infoUser?.phone ?? '',
|
|
53
|
+
avatar: data.infoUser?.avatar ?? '',
|
|
54
|
+
last_message,
|
|
55
|
+
last_message_time: current,
|
|
56
|
+
created_at: current,
|
|
57
|
+
updated_at: current,
|
|
58
|
+
unread_count: 0,
|
|
59
|
+
status: 1,
|
|
60
|
+
color: data.infoUser?.color,
|
|
61
|
+
is_unknown: data.infoUser?.is_unknown ?? 0,
|
|
62
|
+
};
|
|
63
|
+
publishMessage(`${TOPIC_HOME[0] + Number(dataProfile.value?.id)}`, JSON.stringify(dataMessageMyself));
|
|
64
|
+
};
|
|
@@ -10,5 +10,8 @@ export declare const PLIVO_CALL_STATUS: {
|
|
|
10
10
|
readonly CALL_START: "in-progress";
|
|
11
11
|
readonly CALL_END: "completed";
|
|
12
12
|
readonly NO_ANSWER: "no-answer";
|
|
13
|
+
readonly CANCEL: "cancel";
|
|
14
|
+
readonly TIME_OUT: "timeout";
|
|
15
|
+
readonly BUSY: "busy";
|
|
13
16
|
};
|
|
14
17
|
export type PlivoCallStatusType = (typeof PLIVO_CALL_STATUS)[keyof typeof PLIVO_CALL_STATUS];
|
|
@@ -2,7 +2,7 @@ export type IConversation = {
|
|
|
2
2
|
id: number;
|
|
3
3
|
receiver_id: number;
|
|
4
4
|
username: string | null;
|
|
5
|
-
|
|
5
|
+
phone: string;
|
|
6
6
|
avatar: string | null;
|
|
7
7
|
last_message: string;
|
|
8
8
|
last_message_time: string;
|
|
@@ -11,8 +11,10 @@ export type IConversation = {
|
|
|
11
11
|
unread_count: number;
|
|
12
12
|
status: number;
|
|
13
13
|
color: string;
|
|
14
|
+
is_unknown: number;
|
|
14
15
|
};
|
|
15
16
|
export type IParamGetConversation = {
|
|
16
17
|
page?: number;
|
|
17
18
|
search?: string;
|
|
19
|
+
is_unknown?: number;
|
|
18
20
|
};
|
package/dist/types/message.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type IResUser = {
|
|
|
9
9
|
color: string;
|
|
10
10
|
status: number;
|
|
11
11
|
last_offline_at: string;
|
|
12
|
+
is_unknown: number;
|
|
12
13
|
};
|
|
13
14
|
export type IResMessage = {
|
|
14
15
|
id: number | string;
|
|
@@ -16,6 +17,11 @@ export type IResMessage = {
|
|
|
16
17
|
sender_id: number;
|
|
17
18
|
receiver_id: number;
|
|
18
19
|
message: string | null;
|
|
20
|
+
message_uuid?: string | null;
|
|
21
|
+
is_call?: number | null;
|
|
22
|
+
duration?: number | null;
|
|
23
|
+
record_url?: string | null;
|
|
24
|
+
call_status?: string | null;
|
|
19
25
|
created_at: string;
|
|
20
26
|
attachments: IAttachment[];
|
|
21
27
|
state?: MessageStateType;
|
|
@@ -14,6 +14,8 @@ export declare const dataProfile: import("vue").Ref<{
|
|
|
14
14
|
username: string;
|
|
15
15
|
tenant_id: string | null;
|
|
16
16
|
phone: string;
|
|
17
|
+
tenant_phone: string;
|
|
18
|
+
tenant_phone_limit: number;
|
|
17
19
|
avatar: string | null;
|
|
18
20
|
user_type: "customer" | "tenant";
|
|
19
21
|
color: string;
|
|
@@ -22,6 +24,8 @@ export declare const dataProfile: import("vue").Ref<{
|
|
|
22
24
|
username: string;
|
|
23
25
|
tenant_id: string | null;
|
|
24
26
|
phone: string;
|
|
27
|
+
tenant_phone: string;
|
|
28
|
+
tenant_phone_limit: number;
|
|
25
29
|
avatar: string | null;
|
|
26
30
|
user_type: "customer" | "tenant";
|
|
27
31
|
color: string;
|
|
@@ -41,6 +45,7 @@ export declare const setDataLogin: (id: string, token: string, domain: string) =
|
|
|
41
45
|
export declare const loginTenant: (body: IBodyLoginTenant) => Promise<any>;
|
|
42
46
|
export declare const loginLink: (params: IPramsLoginLink) => Promise<any>;
|
|
43
47
|
export declare const getProfile: () => Promise<IResProfile>;
|
|
48
|
+
export declare const checkTenantPhone: () => Promise<any>;
|
|
44
49
|
export declare const submitTenantPhone: (body: {
|
|
45
50
|
phone: string;
|
|
46
51
|
tenant_id: string;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { IConversation, IParamGetConversation } from '../../types/conversation';
|
|
2
2
|
import type { DataWithMetaResponse } from '../../types/global';
|
|
3
|
+
import type { IResUser } from '../../types/message';
|
|
3
4
|
export declare const getConversation: (param: IParamGetConversation) => Promise<DataWithMetaResponse<IConversation[]>>;
|
|
5
|
+
export declare const publicTopicConversationUpdate: (data: {
|
|
6
|
+
infoUser: IResUser | null;
|
|
7
|
+
isSendImg?: boolean;
|
|
8
|
+
message?: string;
|
|
9
|
+
isCall?: string;
|
|
10
|
+
}) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const formatPhone10number: (phone: string, dial
|
|
1
|
+
export declare const formatPhone10number: (phone: string, dial?: string) => string;
|
|
@@ -10,6 +10,7 @@ export declare const user: import("vue").Ref<{
|
|
|
10
10
|
color: string;
|
|
11
11
|
status: number;
|
|
12
12
|
last_offline_at: string;
|
|
13
|
+
is_unknown: number;
|
|
13
14
|
} | null, IResUser | {
|
|
14
15
|
id: string;
|
|
15
16
|
username: string;
|
|
@@ -20,6 +21,7 @@ export declare const user: import("vue").Ref<{
|
|
|
20
21
|
color: string;
|
|
21
22
|
status: number;
|
|
22
23
|
last_offline_at: string;
|
|
24
|
+
is_unknown: number;
|
|
23
25
|
} | null>;
|
|
24
26
|
export declare const userHistory: import("vue").Ref<{
|
|
25
27
|
checkin: {
|