@phonghq/go-chat 1.0.24 → 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/dist/assets/icons/IconCloseCircle.vue.d.ts +2 -0
- package/dist/chat/page/home/ChatList.vue.d.ts +5 -2
- package/dist/chat/page/home/ChatMessage.vue.d.ts +2 -0
- package/dist/chat/page/home/ChatMessageItem.vue.d.ts +10 -3
- package/dist/chat/page/home/Home.vue.d.ts +1 -0
- package/dist/chat/page/setting/Setting.vue.d.ts +2 -0
- package/dist/components/chat/call/Calling.vue.d.ts +2 -2
- 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 +4 -2
- package/dist/go-chat.es.js +10481 -10545
- package/dist/go-chat.umd.js +13 -13
- package/dist/style.css +1 -1
- package/dist/test/assets/icons/IconCloseCircle.vue.js +36 -0
- package/dist/test/chat/App.vue.js +97 -21
- package/dist/test/chat/page/customer-detail/CustomerDetail.vue.js +0 -3
- package/dist/test/chat/page/home/ChatList.vue.js +20 -34
- package/dist/test/chat/page/home/ChatMessage.vue.js +30 -21
- package/dist/test/chat/page/home/ChatMessageItem.vue.js +51 -37
- package/dist/test/chat/page/home/Home.vue.js +27 -60
- package/dist/test/chat/page/home/HomeHeader.vue.js +0 -6
- package/dist/test/chat/page/home/InputChat.vue.js +0 -1
- package/dist/test/chat/page/setting/Setting.vue.js +125 -0
- package/dist/test/components/chat/call/Calling.vue.js +21 -6
- package/dist/test/components/chat/select/SelectBase.vue.js +13 -3
- 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 +0 -6
- package/dist/test/composable/useListConversations.js +6 -4
- package/dist/test/composable/usePlivo.js +9 -3
- package/dist/test/types/chat/call.js +3 -1
- package/dist/test/utils/chat/auth.js +4 -3
- package/dist/test/utils/chat/conversation.js +57 -0
- package/dist/types/chat/call.d.ts +2 -0
- package/dist/types/chat/global.d.ts +1 -0
- package/dist/types/conversation.d.ts +2 -1
- package/dist/types/message.d.ts +1 -0
- package/dist/utils/chat/conversation.d.ts +7 -0
- package/dist/utils/chat/user.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|
2
2
|
import IconPhone from '../../../assets/icons/call/IconPhone.vue';
|
|
3
3
|
import { dataProfile } from '../../../utils/chat/auth.js';
|
|
4
|
-
import { useCallHelper } from '../../../composable/useCallHelper';
|
|
5
4
|
import IconPhoneCancel from '../../../assets/icons/call/IconPhoneCancel.vue';
|
|
6
5
|
import { downloadRecord } from '../../../utils/chat/call';
|
|
7
6
|
import DrawerBaseCustom from '../../../components/common/drawer/DrawerBaseCustom.vue';
|
|
@@ -15,7 +14,16 @@ import { PLIVO_CALL_STATUS } from '../../../types/chat/call';
|
|
|
15
14
|
import IconMic from '../../../assets/icons/call/IconMic.vue';
|
|
16
15
|
const props = withDefaults(defineProps(), {});
|
|
17
16
|
const emit = defineEmits();
|
|
18
|
-
const {
|
|
17
|
+
// const {
|
|
18
|
+
// // call,
|
|
19
|
+
// // end,
|
|
20
|
+
// // handleMedia,
|
|
21
|
+
// // startIncomingCall,
|
|
22
|
+
// // handleCallAnswer,
|
|
23
|
+
// // callAnswer,
|
|
24
|
+
// // uuid,
|
|
25
|
+
// // startPeerConnection
|
|
26
|
+
// } = useCallHelper()
|
|
19
27
|
const handlePlivoCallBack = (status, data) => {
|
|
20
28
|
if (status == PLIVO_CALL_STATUS.RINGING) {
|
|
21
29
|
getUserOffer(data?.phone ?? '');
|
|
@@ -29,7 +37,6 @@ const handlePlivoCallBack = (status, data) => {
|
|
|
29
37
|
else if (status == PLIVO_CALL_STATUS.CALL_END) {
|
|
30
38
|
errorMessage.value = data?.message ?? '';
|
|
31
39
|
const closeModal = data?.reason == 'ORIGINATOR_CANCEL';
|
|
32
|
-
emit('endCall', userRemoter.value);
|
|
33
40
|
endCall({ closeModal });
|
|
34
41
|
callStatus.value = status;
|
|
35
42
|
}
|
|
@@ -48,7 +55,9 @@ const STATUS_LABEL = computed(() => {
|
|
|
48
55
|
[PLIVO_CALL_STATUS.CALL_START]: '',
|
|
49
56
|
[PLIVO_CALL_STATUS.CALL_END]: errorMessage.value || 'Call Ended',
|
|
50
57
|
[PLIVO_CALL_STATUS.NO_ANSWER]: 'No Answer',
|
|
51
|
-
[PLIVO_CALL_STATUS.CANCEL]: ''
|
|
58
|
+
[PLIVO_CALL_STATUS.CANCEL]: '',
|
|
59
|
+
[PLIVO_CALL_STATUS.TIME_OUT]: '',
|
|
60
|
+
[PLIVO_CALL_STATUS.BUSY]: ''
|
|
52
61
|
};
|
|
53
62
|
});
|
|
54
63
|
const label = computed(() => STATUS_LABEL.value[callStatus.value] ?? '');
|
|
@@ -66,7 +75,9 @@ let timeOut = null;
|
|
|
66
75
|
let callType = 'call';
|
|
67
76
|
let uuidEnd = '';
|
|
68
77
|
onMounted(async () => {
|
|
69
|
-
|
|
78
|
+
if (dataProfile.value?.tenant_phone) {
|
|
79
|
+
await plivoLogin('');
|
|
80
|
+
}
|
|
70
81
|
});
|
|
71
82
|
onUnmounted(() => {
|
|
72
83
|
// removeHandleWebSK('call-message')
|
|
@@ -87,7 +98,7 @@ function startTimer() {
|
|
|
87
98
|
}, 1000);
|
|
88
99
|
}
|
|
89
100
|
function endCall(option) {
|
|
90
|
-
if (option?.closeModal
|
|
101
|
+
if (option?.closeModal) {
|
|
91
102
|
drawerVisible.value = false;
|
|
92
103
|
drawerVisibleRef.value?.close();
|
|
93
104
|
}
|
|
@@ -101,6 +112,8 @@ function endCall(option) {
|
|
|
101
112
|
clearInterval(timer);
|
|
102
113
|
if (timeOut)
|
|
103
114
|
clearTimeout(timeOut);
|
|
115
|
+
emit('endCall', userRemoter.value, callType);
|
|
116
|
+
callType = '';
|
|
104
117
|
}
|
|
105
118
|
const open = () => {
|
|
106
119
|
drawerVisible.value = true;
|
|
@@ -232,6 +245,7 @@ const __VLS_0 = __VLS_asFunctionalComponent(DrawerBaseCustom, new DrawerBaseCust
|
|
|
232
245
|
width: (500),
|
|
233
246
|
disabledClose: (__VLS_ctx.disable),
|
|
234
247
|
responsive: (__VLS_ctx.responsive),
|
|
248
|
+
absolute: true,
|
|
235
249
|
}));
|
|
236
250
|
const __VLS_1 = __VLS_0({
|
|
237
251
|
...{ 'onAfterClose': {} },
|
|
@@ -239,6 +253,7 @@ const __VLS_1 = __VLS_0({
|
|
|
239
253
|
width: (500),
|
|
240
254
|
disabledClose: (__VLS_ctx.disable),
|
|
241
255
|
responsive: (__VLS_ctx.responsive),
|
|
256
|
+
absolute: true,
|
|
242
257
|
}, ...__VLS_functionalComponentArgsRest(__VLS_0));
|
|
243
258
|
let __VLS_3;
|
|
244
259
|
let __VLS_4;
|
|
@@ -6,7 +6,17 @@ const open = ref(false);
|
|
|
6
6
|
const selectedLabel = computed(() => {
|
|
7
7
|
return props.options.find(o => o.value === props.modelValue)?.label ?? '';
|
|
8
8
|
});
|
|
9
|
+
const positionClass = computed(() => {
|
|
10
|
+
let result = '';
|
|
11
|
+
if (props.placement === 'bottom')
|
|
12
|
+
return 'top-2 translate-y-full';
|
|
13
|
+
else
|
|
14
|
+
return '-top-4 -translate-y-full';
|
|
15
|
+
return '';
|
|
16
|
+
});
|
|
9
17
|
function toggle() {
|
|
18
|
+
if (props.disabled)
|
|
19
|
+
return;
|
|
10
20
|
open.value = !open.value;
|
|
11
21
|
}
|
|
12
22
|
function select(option) {
|
|
@@ -38,11 +48,12 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
|
38
48
|
// @ts-ignore
|
|
39
49
|
[toggle,];
|
|
40
50
|
__VLS_asFunctionalElement(__VLS_elements.ul, __VLS_elements.ul)({
|
|
41
|
-
...{ class: "w-max absolute -
|
|
51
|
+
...{ class: "w-max absolute -translate-y-full left-0 z-10 mt-1 max-h-48 overflow-auto rounded-md shadow-custom bg-white shadow-lg" },
|
|
52
|
+
...{ class: (__VLS_ctx.positionClass) },
|
|
42
53
|
});
|
|
43
54
|
__VLS_asFunctionalDirective(__VLS_directives.vShow)(null, { ...__VLS_directiveBindingRestFields, value: (__VLS_ctx.open) }, null, null);
|
|
44
55
|
// @ts-ignore
|
|
45
|
-
[open,];
|
|
56
|
+
[open, positionClass,];
|
|
46
57
|
for (const [option, idx] of __VLS_getVForSourceType((__VLS_ctx.options))) {
|
|
47
58
|
// @ts-ignore
|
|
48
59
|
[options,];
|
|
@@ -66,7 +77,6 @@ var __VLS_0 = {};
|
|
|
66
77
|
/** @type {__VLS_StyleScopedClasses['w-full']} */ ;
|
|
67
78
|
/** @type {__VLS_StyleScopedClasses['w-max']} */ ;
|
|
68
79
|
/** @type {__VLS_StyleScopedClasses['absolute']} */ ;
|
|
69
|
-
/** @type {__VLS_StyleScopedClasses['-top-4']} */ ;
|
|
70
80
|
/** @type {__VLS_StyleScopedClasses['-translate-y-full']} */ ;
|
|
71
81
|
/** @type {__VLS_StyleScopedClasses['left-0']} */ ;
|
|
72
82
|
/** @type {__VLS_StyleScopedClasses['z-10']} */ ;
|
|
@@ -51,11 +51,11 @@ let __VLS_components;
|
|
|
51
51
|
let __VLS_directives;
|
|
52
52
|
/** @type {__VLS_StyleScopedClasses['drawer-box']} */ ;
|
|
53
53
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
54
|
-
...{ class: "
|
|
55
|
-
...{ class: (
|
|
54
|
+
...{ class: "top-0 bottom-0 right-0 left-0 z-[1500] drawer" },
|
|
55
|
+
...{ class: ({ 'opacity-1': __VLS_ctx.show, 'pointer-events-none opacity-0 delay-300': !__VLS_ctx.show, 'absolute': __VLS_ctx.absolute, 'fixed': !__VLS_ctx.absolute }) },
|
|
56
56
|
});
|
|
57
57
|
// @ts-ignore
|
|
58
|
-
[show,];
|
|
58
|
+
[show, show, absolute, absolute,];
|
|
59
59
|
if (!__VLS_ctx.disabledClose) {
|
|
60
60
|
// @ts-ignore
|
|
61
61
|
[disabledClose,];
|
|
@@ -84,13 +84,18 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
|
84
84
|
...{ class: "flex p-4 content" },
|
|
85
85
|
});
|
|
86
86
|
__VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({});
|
|
87
|
-
/** @type {__VLS_StyleScopedClasses['absolute']} */ ;
|
|
88
87
|
/** @type {__VLS_StyleScopedClasses['top-0']} */ ;
|
|
89
88
|
/** @type {__VLS_StyleScopedClasses['bottom-0']} */ ;
|
|
90
89
|
/** @type {__VLS_StyleScopedClasses['right-0']} */ ;
|
|
91
90
|
/** @type {__VLS_StyleScopedClasses['left-0']} */ ;
|
|
92
91
|
/** @type {__VLS_StyleScopedClasses['z-[1500]']} */ ;
|
|
93
92
|
/** @type {__VLS_StyleScopedClasses['drawer']} */ ;
|
|
93
|
+
/** @type {__VLS_StyleScopedClasses['opacity-1']} */ ;
|
|
94
|
+
/** @type {__VLS_StyleScopedClasses['pointer-events-none']} */ ;
|
|
95
|
+
/** @type {__VLS_StyleScopedClasses['opacity-0']} */ ;
|
|
96
|
+
/** @type {__VLS_StyleScopedClasses['delay-300']} */ ;
|
|
97
|
+
/** @type {__VLS_StyleScopedClasses['absolute']} */ ;
|
|
98
|
+
/** @type {__VLS_StyleScopedClasses['fixed']} */ ;
|
|
94
99
|
/** @type {__VLS_StyleScopedClasses['absolute']} */ ;
|
|
95
100
|
/** @type {__VLS_StyleScopedClasses['w-full']} */ ;
|
|
96
101
|
/** @type {__VLS_StyleScopedClasses['h-full']} */ ;
|
|
@@ -3,7 +3,7 @@ export const digibotData = {
|
|
|
3
3
|
id: -98,
|
|
4
4
|
receiver_id: 101,
|
|
5
5
|
username: 'Gocheckin AI',
|
|
6
|
-
|
|
6
|
+
phone: '',
|
|
7
7
|
avatar: '',
|
|
8
8
|
last_message: '',
|
|
9
9
|
last_message_time: '',
|
|
@@ -12,6 +12,7 @@ export const digibotData = {
|
|
|
12
12
|
unread_count: 0,
|
|
13
13
|
status: 1,
|
|
14
14
|
color: '#4F46E5',
|
|
15
|
+
is_unknown: 0
|
|
15
16
|
};
|
|
16
17
|
export const digibotId = -98;
|
|
17
18
|
export function useDigibot() {
|
|
@@ -36,14 +36,8 @@ export function useInitData() {
|
|
|
36
36
|
if (dataProfile.value?.user_type == 'tenant') {
|
|
37
37
|
await checkTenantPhone();
|
|
38
38
|
}
|
|
39
|
-
// await Promise.all([ getProfile(), checkTenantPhone()])
|
|
40
|
-
// await getWebSocket()
|
|
41
|
-
// initWebSocket()
|
|
42
39
|
unsubscribeFromTopic(TOPIC_DETAIL_CALL + dataProfile.value?.id);
|
|
43
40
|
subscribeToTopic(TOPIC_DETAIL_CALL + dataProfile.value?.id);
|
|
44
|
-
// if((!res?.phone && res.tenant_id && !props.isLib)) {
|
|
45
|
-
// router.push({name: 'tenant-phone'})
|
|
46
|
-
// }
|
|
47
41
|
if (response == 'mobile') {
|
|
48
42
|
routerPush(PAGE.CHAT_LIST);
|
|
49
43
|
}
|
|
@@ -24,11 +24,11 @@ export const useListConversations = (is_unknown) => {
|
|
|
24
24
|
const handleDisconnectMqtt = () => {
|
|
25
25
|
TOPIC_HOME.forEach((item) => {
|
|
26
26
|
unsubscribeFromTopic(item + dataProfile.value?.id);
|
|
27
|
-
removeHandleMqttMessage('chat-list-' + item);
|
|
27
|
+
removeHandleMqttMessage('chat-list-' + item + '-' + is_unknown);
|
|
28
28
|
});
|
|
29
29
|
if (dataProfile.value?.user_type == 'tenant') {
|
|
30
30
|
subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id);
|
|
31
|
-
removeHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER);
|
|
31
|
+
removeHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
const handleConnectMqtt = async () => {
|
|
@@ -37,10 +37,10 @@ export const useListConversations = (is_unknown) => {
|
|
|
37
37
|
await connectMqtt();
|
|
38
38
|
TOPIC_HOME.forEach((item) => {
|
|
39
39
|
subscribeToTopic(item + dataProfile.value?.id);
|
|
40
|
-
addHandleMqttMessage('chat-list-' + item, item + dataProfile.value?.id, mqttMessageHandler);
|
|
40
|
+
addHandleMqttMessage('chat-list-' + item + '-' + is_unknown, item + dataProfile.value?.id, mqttMessageHandler);
|
|
41
41
|
});
|
|
42
42
|
subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id);
|
|
43
|
-
addHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER, TOPIC_STATUS_USER + dataProfile.value?.id, mqttMessageHandler);
|
|
43
|
+
addHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown, TOPIC_STATUS_USER + dataProfile.value?.id, mqttMessageHandler);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
catch (error) {
|
|
@@ -48,6 +48,8 @@ export const useListConversations = (is_unknown) => {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
const mqttMessageHandler = (topic, data) => {
|
|
51
|
+
if ((data.is_unknown ?? 0) != is_unknown)
|
|
52
|
+
return;
|
|
51
53
|
getDataMqtt();
|
|
52
54
|
if (topic === TOPIC_HOME[0] + dataProfile.value?.id) {
|
|
53
55
|
const index = listConversations.value.findIndex((item) => item.id === data.id);
|
|
@@ -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 }
|
|
@@ -28,11 +27,12 @@ export function usePlivo(callback) {
|
|
|
28
27
|
plivoBrowserSdk.client.on('onIncomingCallCanceled', (callInfo) => {
|
|
29
28
|
handleIncomingCallCanceled(callInfo);
|
|
30
29
|
});
|
|
31
|
-
plivoBrowserSdk.client.on('onCalling', (data) => console.log('onCallFailed', data))
|
|
30
|
+
// plivoBrowserSdk.client.on('onCalling', (data: any) => console.log('onCallFailed', data))
|
|
32
31
|
plivoBrowserSdk?.client?.on?.('onIncomingCall', (callerID, extraHeaders, callInfo) => {
|
|
33
32
|
handleIncomingCall(callInfo);
|
|
34
33
|
});
|
|
35
34
|
plivoBrowserSdk.client.on('onCallRemoteRinging', (data) => handleCallRemoteRinging(data));
|
|
35
|
+
plivoBrowserSdk.client.on('onMediaPermission', (e) => handleMediaPermission(e));
|
|
36
36
|
// plivoBrowserSdk?.client?.on?.('onReady', () => console.log('Ready'))
|
|
37
37
|
// plivoBrowserSdk?.client?.on?.('onLoginFailed', () => console.log('Login failed'))
|
|
38
38
|
// plivoBrowserSdk?.client?.on?.('remoteAudioStatus', () => console.log('remoteAudioStatus'))
|
|
@@ -49,7 +49,6 @@ export function usePlivo(callback) {
|
|
|
49
49
|
const data = {
|
|
50
50
|
phone: _getPhone(call.src)
|
|
51
51
|
};
|
|
52
|
-
console.log(call);
|
|
53
52
|
callback(PLIVO_CALL_STATUS.RINGING, data);
|
|
54
53
|
CallUuid = call?.callUUID;
|
|
55
54
|
};
|
|
@@ -126,13 +125,20 @@ export function usePlivo(callback) {
|
|
|
126
125
|
}
|
|
127
126
|
};
|
|
128
127
|
const handleCallFailed = (data, callInfo) => {
|
|
128
|
+
console.log('handleCallFailed', data);
|
|
129
129
|
if (custom_reject)
|
|
130
130
|
custom_reject?.(data);
|
|
131
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
|
+
}
|
|
132
135
|
};
|
|
133
136
|
const handleIncomingCallCanceled = (callInfo) => {
|
|
134
137
|
callback(PLIVO_CALL_STATUS.CALL_END, { reason: callInfo.reason ?? '' });
|
|
135
138
|
};
|
|
139
|
+
const handleMediaPermission = (e) => {
|
|
140
|
+
console.log('MediaPermission', e);
|
|
141
|
+
};
|
|
136
142
|
return {
|
|
137
143
|
plivoLogin,
|
|
138
144
|
plivoCallAnswer,
|
|
@@ -41,11 +41,12 @@ export const getProfile = async () => {
|
|
|
41
41
|
export const checkTenantPhone = async () => {
|
|
42
42
|
const id = localStorage.getItem('chat_id');
|
|
43
43
|
const res = await axios.get(`/api/v1/message/tenant/get-info?tenant_name=${id}`);
|
|
44
|
-
|
|
44
|
+
if (res.error || !res?.data)
|
|
45
|
+
throw new Error(res.error);
|
|
45
46
|
if (dataProfile.value)
|
|
46
|
-
dataProfile.value.tenant_phone = res?.go_chat_phone ?? '';
|
|
47
|
+
dataProfile.value.tenant_phone = res?.data?.go_chat_phone ?? '';
|
|
47
48
|
if (dataProfile.value)
|
|
48
|
-
dataProfile.value.tenant_phone_limit = Number(res?.go_chat_phone_limit ?? 0);
|
|
49
|
+
dataProfile.value.tenant_phone_limit = Number(res?.data?.go_chat_phone_limit ?? 0);
|
|
49
50
|
return res;
|
|
50
51
|
};
|
|
51
52
|
export const submitTenantPhone = async (body) => {
|
|
@@ -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
|
+
};
|
|
@@ -11,5 +11,7 @@ export declare const PLIVO_CALL_STATUS: {
|
|
|
11
11
|
readonly CALL_END: "completed";
|
|
12
12
|
readonly NO_ANSWER: "no-answer";
|
|
13
13
|
readonly CANCEL: "cancel";
|
|
14
|
+
readonly TIME_OUT: "timeout";
|
|
15
|
+
readonly BUSY: "busy";
|
|
14
16
|
};
|
|
15
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,6 +11,7 @@ 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;
|
package/dist/types/message.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -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: {
|