@subiz/widget-v4 4.1.199 → 4.1.200
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/assets/less/message.less +1 -1
- package/assets/less/widget_header.less +0 -1
- package/compiled_src/chatbox/Event.js +1 -1
- package/compiled_src/chatbox/Events.js +2 -1
- package/compiled_src/lib.js +1 -0
- package/compiled_src/plugin.js +1 -0
- package/compiled_src/store/store.js +3 -0
- package/compiled_src/util/common.js +27 -14
- package/compiled_src/util/common.test.js +43 -133
- package/dist/132.js +21 -21
- package/dist/185.js +49 -49
- package/dist/{19c2dc9a6ec.132.js → 19c2dd58182.132.js} +1 -1
- package/dist/19c2dd58182.185.js +1 -0
- package/dist/19c2dd58182.278.js +1 -0
- package/dist/19c2dd58182.339.js +1 -0
- package/dist/19c2dd58182.459.js +1 -0
- package/dist/19c2dd58182.app.js +1 -0
- package/dist/{19c2dc9a6ec.chat.html → 19c2dd58182.chat.html} +1 -1
- package/dist/19c2dd58182.chat.js +1 -0
- package/dist/{19c2dc9a6ec.form.html → 19c2dd58182.form.html} +1 -1
- package/dist/{19c2dc9a6ec.form.js → 19c2dd58182.form.js} +1 -1
- package/dist/{19c2dc9a6ec.index.html → 19c2dd58182.index.html} +1 -1
- package/dist/{19c2dc9a6ec.library.html → 19c2dd58182.library.html} +1 -1
- package/dist/19c2dd58182.library.js +1 -0
- package/dist/{19c2dc9a6ec.preview.html → 19c2dd58182.preview.html} +1 -1
- package/dist/19c2dd58182.preview.js +1 -0
- package/dist/19c2dd58182.webview.js +1 -0
- package/dist/459.js +11 -11
- package/dist/74.js +1 -0
- package/dist/HASH +1 -1
- package/dist/assets/img/rating--poor.2938a25.svg +12 -0
- package/dist/screenshoot.js +3050 -3043
- package/package.json +10 -9
- package/src/chatbox/Event.js +1 -1
- package/src/chatbox/Events.js +2 -1
- package/src/chatbox/Widget.js +1 -0
- package/src/lib.js +2 -0
- package/src/plugin.js +1 -0
- package/src/store/store.js +3 -0
- package/src/util/common.js +31 -16
- package/src/util/common.test.js +108 -193
- package/dist/19c2dc9a6ec.185.js +0 -1
- package/dist/19c2dc9a6ec.278.js +0 -1
- package/dist/19c2dc9a6ec.339.js +0 -1
- package/dist/19c2dc9a6ec.459.js +0 -1
- package/dist/19c2dc9a6ec.app.js +0 -1
- package/dist/19c2dc9a6ec.chat.js +0 -1
- package/dist/19c2dc9a6ec.library.js +0 -1
- package/dist/19c2dc9a6ec.preview.js +0 -1
- package/dist/19c2dc9a6ec.webview.js +0 -1
- package/dist/DEVHASH +0 -1
- /package/dist/{19c2dc9a6ec.127.js → 19c2dd58182.127.js} +0 -0
- /package/dist/{19c2dc9a6ec.27.js → 19c2dd58182.27.js} +0 -0
- /package/dist/{19c2dc9a6ec.490.js → 19c2dd58182.490.js} +0 -0
- /package/dist/{19c2dc9a6ec.74.js → 19c2dd58182.74.js} +0 -0
- /package/dist/{19c2dc9a6ec.997.js → 19c2dd58182.997.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.200",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -13,26 +13,27 @@
|
|
|
13
13
|
"@subiz/flow": "^1.1.0",
|
|
14
14
|
"@subiz/wsclient": "^4.0.34",
|
|
15
15
|
"cookie_js": "1.4.2",
|
|
16
|
-
"core-js": "^3.
|
|
16
|
+
"core-js": "^3.49.0",
|
|
17
17
|
"css-loader": "5.2.7",
|
|
18
18
|
"file-loader": "^6.2.0",
|
|
19
|
-
"less": "^4.
|
|
20
|
-
"less-loader": "^12.3.
|
|
19
|
+
"less": "^4.6.4",
|
|
20
|
+
"less-loader": "^12.3.2",
|
|
21
21
|
"preact": "10.19.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"tape": "^5.9.0",
|
|
24
25
|
"@babel/cli": "^7.28.6",
|
|
25
26
|
"@babel/core": "^7.29.0",
|
|
26
27
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
27
28
|
"@babel/plugin-transform-react-jsx": "^7.28.6",
|
|
28
|
-
"@babel/preset-env": "^7.29.
|
|
29
|
-
"babel-loader": "^10.
|
|
29
|
+
"@babel/preset-env": "^7.29.2",
|
|
30
|
+
"babel-loader": "^10.1.1",
|
|
30
31
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
31
32
|
"html-webpack-plugin": "^5.6.6",
|
|
32
|
-
"puppeteer": "^24.
|
|
33
|
-
"webpack": "^5.105.
|
|
33
|
+
"puppeteer": "^24.40.0",
|
|
34
|
+
"webpack": "^5.105.4",
|
|
34
35
|
"webpack-bundle-analyzer": "^5.2.0",
|
|
35
|
-
"webpack-cli": "^
|
|
36
|
+
"webpack-cli": "^7.0.2",
|
|
36
37
|
"webpack-dev-server": "^5.2.3"
|
|
37
38
|
}
|
|
38
39
|
}
|
package/src/chatbox/Event.js
CHANGED
|
@@ -451,7 +451,7 @@ export default class Event extends Com {
|
|
|
451
451
|
<div class='message-event-action-btn-svg dislike' />
|
|
452
452
|
</div>
|
|
453
453
|
</div>
|
|
454
|
-
{sb.get(this.props.event, 'is_end') && (
|
|
454
|
+
{sb.get(this.props.event, 'is_end') && !this.props.isConvoEnded && (
|
|
455
455
|
<div class='message-event-actions-static'>
|
|
456
456
|
<div class={likecls} onClick={() => this.onSendReaction(hasLike ? 'remove_like' : 'like')}>
|
|
457
457
|
<div class='message-event-action-btn-svg like' />
|
package/src/chatbox/Events.js
CHANGED
|
@@ -148,7 +148,7 @@ export default class Events extends Com {
|
|
|
148
148
|
events.push(fakeev)
|
|
149
149
|
|
|
150
150
|
let $events = sb.map(events, (ev) => {
|
|
151
|
-
let isLast = ev.is_last_message_send
|
|
151
|
+
let isLast = ev.is_last_message_send && sb.get(convo, 'state') !== 'ended'
|
|
152
152
|
return (
|
|
153
153
|
<Event
|
|
154
154
|
isLast={isLast}
|
|
@@ -160,6 +160,7 @@ export default class Events extends Com {
|
|
|
160
160
|
onPostback={this.props.onPostback}
|
|
161
161
|
onFocusSourceEventFromQuote={this.onFocusSourceEventFromQuote}
|
|
162
162
|
ref={(ele) => this.setEventChildRef(ele, ev.ev.id)}
|
|
163
|
+
isConvoEnded={sb.get(convo, 'state') === 'ended'}
|
|
163
164
|
event={ev}
|
|
164
165
|
t={this.props.t}
|
|
165
166
|
key={ev.ev.id}
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -70,6 +70,7 @@ export default class Widget extends Com {
|
|
|
70
70
|
|
|
71
71
|
console.log('check ev pass condition', ev)
|
|
72
72
|
if (!messageSentDict[ev.id]) {
|
|
73
|
+
let accid = sb.get(this.props.store.matchAccount(), 'id')
|
|
73
74
|
this.props.store.sendBugReport(
|
|
74
75
|
'[WIDGET ' + accid + '] Missing agent message sent evid ' + ev.id + ', cid ' + sb.convoOfEv(ev),
|
|
75
76
|
)
|
package/src/lib.js
CHANGED
|
@@ -84,6 +84,8 @@ class Widget {
|
|
|
84
84
|
let ref = param.ref
|
|
85
85
|
|
|
86
86
|
let user = await this.store.init(accid, undefined, ref, param)
|
|
87
|
+
|
|
88
|
+
if (this.store.isDead()) return user
|
|
87
89
|
sb.setTimeout(() => window.postMessage({type: 'widget_loaded', account_id: accid}, '*'), 0) // send to chrome extension
|
|
88
90
|
|
|
89
91
|
// add container to client site
|
package/src/plugin.js
CHANGED
|
@@ -12,6 +12,7 @@ function Plugin(plugin, store, $container, lib) {
|
|
|
12
12
|
if (!$container) throw '$div must is a valid html node'
|
|
13
13
|
var $div = document.createElement('div')
|
|
14
14
|
$div.id = plugin.id
|
|
15
|
+
if (store.isDead()) return
|
|
15
16
|
let acc = store.matchAccount()
|
|
16
17
|
$div.setAttribute('sbz-plugin-type', plugin.type)
|
|
17
18
|
$div.setAttribute('sbz-plugin-account-id', acc.id)
|
package/src/store/store.js
CHANGED
package/src/util/common.js
CHANGED
|
@@ -950,22 +950,8 @@ export function checkRunConditions(freq, conds, lastrun, store) {
|
|
|
950
950
|
var cond = conds[i]
|
|
951
951
|
switch (cond.key) {
|
|
952
952
|
case 'url':
|
|
953
|
-
|
|
954
|
-
if (
|
|
955
|
-
let found = find(exclude_urls, (url) => {
|
|
956
|
-
return norm(window.location.href).indexOf(norm(url)) > -1
|
|
957
|
-
})
|
|
958
|
-
if (found) return false
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
// ignore empty url
|
|
962
|
-
let urls = filter(cond.urls, (url) => norm(url))
|
|
963
|
-
if (size(urls) > 0) {
|
|
964
|
-
let found = find(urls, (url) => {
|
|
965
|
-
return norm(window.location.href).indexOf(norm(url)) > -1
|
|
966
|
-
})
|
|
967
|
-
if (!found) return false
|
|
968
|
-
}
|
|
953
|
+
// url = qlhd.minvoice.com.vn, exclude_urls ["minvoice.com.vn","minvoice.net","hdt.minvoice.com.vn"], urls ["qlhd.minvoice.com.vn"] => must pass
|
|
954
|
+
if (!checkUrlCondition(cond, window.location.href)) return false
|
|
969
955
|
break
|
|
970
956
|
case 'url_path':
|
|
971
957
|
let excludePaths = filter(cond.exclude_url_paths, (url) => norm(url))
|
|
@@ -1616,3 +1602,32 @@ function isEmptyAttachment(msg) {
|
|
|
1616
1602
|
) == 0
|
|
1617
1603
|
)
|
|
1618
1604
|
}
|
|
1605
|
+
export function checkUrlCondition(cond, href) {
|
|
1606
|
+
// url = qlhd.minvoice.com.vn, exclude_urls ["minvoice.com.vn","minvoice.net","hdt.minvoice.com.vn"], urls ["qlhd.minvoice.com.vn"] => must pass
|
|
1607
|
+
let exclude_urls = filter(cond.exclude_urls, (url) => norm(url))
|
|
1608
|
+
let foundExclude = false
|
|
1609
|
+
let excludeLen = 0
|
|
1610
|
+
map(exclude_urls, (url) => {
|
|
1611
|
+
if (norm(href).indexOf(url) > -1) {
|
|
1612
|
+
if (excludeLen < size(url)) excludeLen = size(url)
|
|
1613
|
+
foundExclude = true
|
|
1614
|
+
}
|
|
1615
|
+
})
|
|
1616
|
+
|
|
1617
|
+
// ignore empty url
|
|
1618
|
+
let includeLen = 0
|
|
1619
|
+
let urls = filter(cond.urls, (url) => norm(url))
|
|
1620
|
+
let foundInclude = size(urls) == 0
|
|
1621
|
+
map(urls, (url) => {
|
|
1622
|
+
if (norm(href).indexOf(url) > -1) {
|
|
1623
|
+
if (includeLen < size(url)) includeLen = size(url)
|
|
1624
|
+
foundInclude = true
|
|
1625
|
+
}
|
|
1626
|
+
})
|
|
1627
|
+
if (foundExclude) {
|
|
1628
|
+
if (excludeLen >= includeLen) return false
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
if (!foundInclude) return false
|
|
1632
|
+
return true
|
|
1633
|
+
}
|
package/src/util/common.test.js
CHANGED
|
@@ -1,157 +1,72 @@
|
|
|
1
|
+
import {createRequire} from 'module'
|
|
2
|
+
const require = createRequire(import.meta.url)
|
|
3
|
+
global.require = require
|
|
4
|
+
global.XMLHttpRequest = {
|
|
5
|
+
prototype: {
|
|
6
|
+
open: function () {},
|
|
7
|
+
},
|
|
8
|
+
}
|
|
9
|
+
global.document = {
|
|
10
|
+
JSON: JSON,
|
|
11
|
+
// document.documentElement.appendChild
|
|
12
|
+
// f.contentDocument.createElement
|
|
13
|
+
body: {
|
|
14
|
+
appendChild: function () {},
|
|
15
|
+
},
|
|
16
|
+
documentElement: {
|
|
17
|
+
appendChild: function () {},
|
|
18
|
+
},
|
|
19
|
+
createElement: function () {
|
|
20
|
+
return {
|
|
21
|
+
contentWindow: global,
|
|
22
|
+
contentDocument: global.document,
|
|
23
|
+
style: {display: false},
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}
|
|
1
27
|
const test = require('tape')
|
|
2
28
|
const util = require('./common.js')
|
|
3
29
|
|
|
4
|
-
test('util.
|
|
30
|
+
test('util.checkUrlCondition', (t) => {
|
|
5
31
|
var tcs = [
|
|
6
32
|
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
desc: 'an email',
|
|
13
|
-
event: {
|
|
14
|
-
type: 'message_sent',
|
|
15
|
-
data: {
|
|
16
|
-
message: {
|
|
17
|
-
fields: [
|
|
18
|
-
{ key: 'from', value: '"thanh"' },
|
|
19
|
-
{ key: 'to', value: '"van"' },
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
text: 'sent an email',
|
|
25
|
-
},
|
|
26
|
-
{ desc: 'empty msg', event: {}, text: '' },
|
|
27
|
-
{
|
|
28
|
-
desc: 'markdown',
|
|
29
|
-
event: {
|
|
30
|
-
type: 'message_sent',
|
|
31
|
-
data: {
|
|
32
|
-
message: {
|
|
33
|
-
format: 'markdown',
|
|
34
|
-
text: 'xin chao',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
text: 'sent a message',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
desc: 'html',
|
|
42
|
-
event: {
|
|
43
|
-
type: 'message_sent',
|
|
44
|
-
data: {
|
|
45
|
-
message: {
|
|
46
|
-
format: 'html',
|
|
47
|
-
text: '<b>xin chao</b>',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
text: 'sent a message',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
desc: 'multiple attachemnts',
|
|
55
|
-
event: {
|
|
56
|
-
type: 'message_sent',
|
|
57
|
-
data: {
|
|
58
|
-
message: {
|
|
59
|
-
attachments: [{}, {}, {}],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
text: 'sent a message with 3 attachments',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
desc: 'text with attachment',
|
|
67
|
-
event: {
|
|
68
|
-
type: 'message_sent',
|
|
69
|
-
data: {
|
|
70
|
-
message: {
|
|
71
|
-
type: 'text',
|
|
72
|
-
text: 'xin chao',
|
|
73
|
-
attachments: [{}],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
text: 'sent a message with 1 attachments',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
desc: '1 attachment no type',
|
|
81
|
-
event: {
|
|
82
|
-
type: 'message_sent',
|
|
83
|
-
data: {
|
|
84
|
-
message: {
|
|
85
|
-
attachments: [{}],
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
text: 'sent an attachment',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
desc: 'audio ',
|
|
93
|
-
event: {
|
|
94
|
-
type: 'message_sent',
|
|
95
|
-
data: {
|
|
96
|
-
message: {
|
|
97
|
-
attachments: [{ mimetype: 'audio/mp3' }],
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
text: 'sent an audio',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
desc: 'video',
|
|
105
|
-
event: {
|
|
106
|
-
type: 'message_sent',
|
|
107
|
-
data: {
|
|
108
|
-
message: {
|
|
109
|
-
attachments: [{ mimetype: 'video/ogg' }],
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
text: 'sent a video',
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
desc: 'image',
|
|
117
|
-
event: {
|
|
118
|
-
type: 'message_sent',
|
|
119
|
-
data: {
|
|
120
|
-
message: {
|
|
121
|
-
attachments: [{ mimetype: 'image/jpeg' }],
|
|
122
|
-
},
|
|
123
|
-
},
|
|
33
|
+
name: 'minvoice',
|
|
34
|
+
cond: {
|
|
35
|
+
key: 'url',
|
|
36
|
+
urls: ['qlhd.minvoice.com.vn'],
|
|
37
|
+
exclude_urls: ['minvoice.com.vn', 'minvoice.net', 'hdt.minvoice.com.vn'],
|
|
124
38
|
},
|
|
125
|
-
|
|
39
|
+
href: 'https://qlhd.minvoice.com.vn/#/login',
|
|
40
|
+
pass: true,
|
|
126
41
|
},
|
|
127
42
|
]
|
|
128
43
|
|
|
129
|
-
tcs.map(tc => {
|
|
44
|
+
tcs.map((tc) => {
|
|
130
45
|
// if (tc.desc !== 'multiple attachemnts') return
|
|
131
|
-
var out = util.
|
|
132
|
-
t.equal(out, tc.
|
|
46
|
+
var out = util.checkUrlCondition(tc.cond, tc.href)
|
|
47
|
+
t.equal(out, tc.pass)
|
|
133
48
|
})
|
|
134
49
|
t.end()
|
|
135
50
|
})
|
|
136
51
|
|
|
137
|
-
test('util.randomString', t => {
|
|
52
|
+
test('util.randomString', (t) => {
|
|
138
53
|
t.equal(10, util.randomString(10).length)
|
|
139
54
|
t.equal(11, util.randomString(11).length)
|
|
140
55
|
t.equal(12, util.randomString(12).length)
|
|
141
56
|
t.end()
|
|
142
57
|
})
|
|
143
58
|
|
|
144
|
-
test('convert message event first msg send', t => {
|
|
59
|
+
test('convert message event first msg send', (t) => {
|
|
145
60
|
var events = [
|
|
146
|
-
{
|
|
147
|
-
{
|
|
148
|
-
{
|
|
61
|
+
{by: {id: 1}, type: 'message_sent', created: 1100},
|
|
62
|
+
{by: {id: 1}, type: 'message_sent', created: 1200},
|
|
63
|
+
{by: {id: 1}, type: 'message_sent', created: 1300},
|
|
149
64
|
]
|
|
150
65
|
|
|
151
66
|
var expect = [
|
|
152
|
-
{
|
|
153
|
-
{
|
|
154
|
-
{
|
|
67
|
+
{by: {id: 1}, type: 'message_sent', created: 1100, mode: 'lead', show_time: true},
|
|
68
|
+
{by: {id: 1}, type: 'message_sent', created: 1200, mode: 'follow', show_time: false},
|
|
69
|
+
{by: {id: 1}, type: 'message_sent', created: 1300, mode: 'follow', show_time: false},
|
|
155
70
|
]
|
|
156
71
|
|
|
157
72
|
util.convertMessageEvent(events, 0)
|
|
@@ -162,33 +77,33 @@ test('convert message event first msg send', t => {
|
|
|
162
77
|
t.end()
|
|
163
78
|
})
|
|
164
79
|
|
|
165
|
-
test('convert message event message tag', t => {
|
|
80
|
+
test('convert message event message tag', (t) => {
|
|
166
81
|
var events = [
|
|
167
|
-
{
|
|
168
|
-
{
|
|
169
|
-
{
|
|
170
|
-
{
|
|
171
|
-
{
|
|
82
|
+
{type: 'conversation_state_updated'},
|
|
83
|
+
{type: 'conversation_tagged'},
|
|
84
|
+
{type: 'conversation_tagged'},
|
|
85
|
+
{type: 'conversation_tagged'},
|
|
86
|
+
{type: 'conversation_state_updated'},
|
|
172
87
|
]
|
|
173
88
|
|
|
174
89
|
var expect = [
|
|
175
|
-
{
|
|
176
|
-
{
|
|
177
|
-
{
|
|
178
|
-
{
|
|
179
|
-
{
|
|
90
|
+
{type: 'conversation_state_updated'},
|
|
91
|
+
{type: 'conversation_tagged', mode: 'hide'},
|
|
92
|
+
{type: 'conversation_tagged', mode: 'hide'},
|
|
93
|
+
{type: 'conversation_tagged', mode: 'combine'},
|
|
94
|
+
{type: 'conversation_state_updated'},
|
|
180
95
|
]
|
|
181
96
|
|
|
182
97
|
events.map((_, i) => util.convertMessageEvent(events, i))
|
|
183
98
|
|
|
184
99
|
t.equal(JSON.stringify(events), JSON.stringify(expect))
|
|
185
100
|
|
|
186
|
-
var events = [{
|
|
101
|
+
var events = [{type: 'conversation_tagged'}, {type: 'conversation_tagged'}, {type: 'conversation_tagged'}]
|
|
187
102
|
|
|
188
103
|
var expect = [
|
|
189
|
-
{
|
|
190
|
-
{
|
|
191
|
-
{
|
|
104
|
+
{type: 'conversation_tagged', mode: 'hide'},
|
|
105
|
+
{type: 'conversation_tagged', mode: 'hide'},
|
|
106
|
+
{type: 'conversation_tagged', mode: 'combine'},
|
|
192
107
|
]
|
|
193
108
|
|
|
194
109
|
events.map((_, i) => util.convertMessageEvent(events, i))
|
|
@@ -196,25 +111,25 @@ test('convert message event message tag', t => {
|
|
|
196
111
|
t.end()
|
|
197
112
|
})
|
|
198
113
|
|
|
199
|
-
test('convert message event message tag, msg_sent mixup', t => {
|
|
114
|
+
test('convert message event message tag, msg_sent mixup', (t) => {
|
|
200
115
|
var events = [
|
|
201
|
-
{
|
|
202
|
-
{
|
|
203
|
-
{
|
|
204
|
-
{
|
|
205
|
-
{
|
|
206
|
-
{
|
|
207
|
-
{
|
|
116
|
+
{type: 'conversation_state_updated'},
|
|
117
|
+
{type: 'conversation_tagged'},
|
|
118
|
+
{by: {id: 1}, type: 'message_sent'},
|
|
119
|
+
{by: {id: 2}, type: 'message_sent'},
|
|
120
|
+
{type: 'conversation_tagged'},
|
|
121
|
+
{type: 'conversation_tagged'},
|
|
122
|
+
{type: 'conversation_state_updated'},
|
|
208
123
|
]
|
|
209
124
|
|
|
210
125
|
var expect = [
|
|
211
|
-
{
|
|
212
|
-
{
|
|
213
|
-
{
|
|
214
|
-
{
|
|
215
|
-
{
|
|
216
|
-
{
|
|
217
|
-
{
|
|
126
|
+
{type: 'conversation_state_updated'},
|
|
127
|
+
{type: 'conversation_tagged', mode: 'combine'},
|
|
128
|
+
{by: {id: 1}, type: 'message_sent', mode: 'lead', show_time: false},
|
|
129
|
+
{by: {id: 2}, type: 'message_sent', mode: 'lead', show_time: false},
|
|
130
|
+
{type: 'conversation_tagged', mode: 'hide'},
|
|
131
|
+
{type: 'conversation_tagged', mode: 'combine'},
|
|
132
|
+
{type: 'conversation_state_updated'},
|
|
218
133
|
]
|
|
219
134
|
|
|
220
135
|
events.map((_, i) => util.convertMessageEvent(events, i))
|
|
@@ -223,49 +138,49 @@ test('convert message event message tag, msg_sent mixup', t => {
|
|
|
223
138
|
t.end()
|
|
224
139
|
})
|
|
225
140
|
|
|
226
|
-
test('test insert message', t => {
|
|
141
|
+
test('test insert message', (t) => {
|
|
227
142
|
var events = [
|
|
228
|
-
{
|
|
229
|
-
{
|
|
230
|
-
{
|
|
231
|
-
{
|
|
232
|
-
{
|
|
233
|
-
{
|
|
234
|
-
{
|
|
143
|
+
{type: 'conversation_state_updated'},
|
|
144
|
+
{id: 1, type: 'conversation_tagged'},
|
|
145
|
+
{by: {id: 1}, type: 'message_sent'},
|
|
146
|
+
{by: {id: 2}, type: 'message_sent'},
|
|
147
|
+
{type: 'conversation_tagged'},
|
|
148
|
+
{type: 'conversation_tagged'},
|
|
149
|
+
{type: 'conversation_state_updated'},
|
|
235
150
|
]
|
|
236
151
|
|
|
237
152
|
events.map((_, i) => util.convertMessageEvent(events, i))
|
|
238
153
|
|
|
239
|
-
events.splice(2, 0, {
|
|
154
|
+
events.splice(2, 0, {id: 2, type: 'conversation_tagged'})
|
|
240
155
|
util.convertUpdatedOrDeletedMessageEvent(events, 2)
|
|
241
156
|
var expect = [
|
|
242
|
-
{
|
|
243
|
-
{
|
|
244
|
-
{
|
|
245
|
-
{
|
|
246
|
-
{
|
|
247
|
-
{
|
|
248
|
-
{
|
|
249
|
-
{
|
|
157
|
+
{type: 'conversation_state_updated'},
|
|
158
|
+
{id: 1, type: 'conversation_tagged', mode: 'hide'},
|
|
159
|
+
{id: 2, type: 'conversation_tagged', mode: 'combine'},
|
|
160
|
+
{by: {id: 1}, type: 'message_sent', mode: 'lead', show_time: false},
|
|
161
|
+
{by: {id: 2}, type: 'message_sent', mode: 'lead', show_time: false},
|
|
162
|
+
{type: 'conversation_tagged', mode: 'hide'},
|
|
163
|
+
{type: 'conversation_tagged', mode: 'combine'},
|
|
164
|
+
{type: 'conversation_state_updated'},
|
|
250
165
|
]
|
|
251
166
|
|
|
252
167
|
t.equal(JSON.stringify(events), JSON.stringify(expect))
|
|
253
168
|
t.end()
|
|
254
169
|
})
|
|
255
170
|
|
|
256
|
-
test('mapizeDeep a map', t => {
|
|
171
|
+
test('mapizeDeep a map', (t) => {
|
|
257
172
|
var topicM = {
|
|
258
|
-
|
|
173
|
+
0: {
|
|
259
174
|
topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxnairroppcktrg',
|
|
260
175
|
read: false,
|
|
261
176
|
updated: 1570586074000,
|
|
262
177
|
},
|
|
263
|
-
|
|
178
|
+
1: {
|
|
264
179
|
topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxmkozwryrgjvag',
|
|
265
180
|
read: false,
|
|
266
181
|
updated: 1570551305000,
|
|
267
182
|
},
|
|
268
|
-
|
|
183
|
+
2: {
|
|
269
184
|
topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlvkqgspihkfzsnm',
|
|
270
185
|
read: false,
|
|
271
186
|
updated: 1570289320000,
|
|
@@ -294,24 +209,24 @@ test('mapizeDeep a map', t => {
|
|
|
294
209
|
t.end()
|
|
295
210
|
})
|
|
296
211
|
|
|
297
|
-
test('mapize a map', t => {
|
|
212
|
+
test('mapize a map', (t) => {
|
|
298
213
|
var topicM = {
|
|
299
|
-
|
|
300
|
-
|
|
214
|
+
0: {topic: 't1', updated: 157},
|
|
215
|
+
1: {topic: 't2', updated: 158},
|
|
301
216
|
}
|
|
302
217
|
|
|
303
218
|
var out = util.mapize(topicM, 'topic')
|
|
304
|
-
t.deepEqual(out, {
|
|
219
|
+
t.deepEqual(out, {t1: {topic: 't1', updated: 157}, t2: {topic: 't2', updated: 158}})
|
|
305
220
|
t.end()
|
|
306
221
|
})
|
|
307
222
|
|
|
308
|
-
test('mapize', t => {
|
|
223
|
+
test('mapize', (t) => {
|
|
309
224
|
var arr = [
|
|
310
|
-
{
|
|
311
|
-
{
|
|
312
|
-
{
|
|
313
|
-
{
|
|
314
|
-
{
|
|
225
|
+
{id: 0, value: 0},
|
|
226
|
+
{id: 1, value: 1},
|
|
227
|
+
{id: 2, value: 2},
|
|
228
|
+
{id: 3, value: 3},
|
|
229
|
+
{id: 4, value: 4},
|
|
315
230
|
]
|
|
316
231
|
var m = util.mapize(arr, 'id')
|
|
317
232
|
for (var i = 0; i < arr.length; i++) {
|
|
@@ -320,12 +235,12 @@ test('mapize', t => {
|
|
|
320
235
|
t.end()
|
|
321
236
|
})
|
|
322
237
|
|
|
323
|
-
test('convo id from topic', t => {
|
|
238
|
+
test('convo id from topic', (t) => {
|
|
324
239
|
t.equal('csqldpucwamyuaetjf', util.convoIdFromTopic('account.acqcsmrppbftadjzxnvo.conversation.csqldpucwamyuaetjf'))
|
|
325
240
|
t.end()
|
|
326
241
|
})
|
|
327
242
|
|
|
328
|
-
test('user of convo', t => {
|
|
243
|
+
test('user of convo', (t) => {
|
|
329
244
|
var convo = {
|
|
330
245
|
id: 'csqlmhetrpccwprnms',
|
|
331
246
|
account_id: 'acqcsmrppbftadjzxnvo',
|