@tiledesk/tiledesk-server 2.1.4-0.3 → 2.1.4-0.31
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/.circleci/config.yml +44 -0
- package/.github/workflows/docker-community-push-latest.yml +22 -0
- package/.github/workflows/{docker-image-push.yml → docker-image-en-tag-push.yml} +1 -1
- package/.github/workflows/docker-image-tag-community-tag-push.yml +21 -0
- package/.github/workflows/{docker-push-latest.yml → docker-push-en-push-latest.yml} +1 -1
- package/CHANGELOG.md +3 -0
- package/Dockerfile +1 -1
- package/Dockerfile-en +1 -1
- package/app.js +9 -1
- package/channels/chat21/chat21Handler.js +48 -5
- package/channels/chat21/package-lock.json +3013 -0
- package/models/faq_kb.js +5 -0
- package/models/message.js +10 -4
- package/models/messageConstants.js +6 -0
- package/package.json +4 -4
- package/pubmodules/emailNotification/requestNotification.js +96 -31
- package/pubmodules/pubModulesManager.js +66 -13
- package/pubmodules/rules/conciergeBot.js +56 -49
- package/routes/auth.js +4 -3
- package/routes/campaigns.js +117 -25
- package/routes/faq_kb.js +9 -2
- package/routes/messagesRoot.js +73 -16
- package/routes/project_user.js +36 -1
- package/routes/request.js +85 -37
- package/routes/requestUtilRoot.js +30 -0
- package/services/departmentService.js +9 -5
- package/services/emailService.js +41 -7
- package/services/faqBotHandler.js +8 -1
- package/services/messageService.js +57 -9
- package/services/modulesManager.js +86 -23
- package/services/requestService.js +8 -4
- package/test/messageRootRoute.js +188 -0
- package/websocket/webSocketServer.js +5 -4
@@ -0,0 +1,44 @@
|
|
1
|
+
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
2
|
+
# See: https://circleci.com/docs/2.0/configuration-reference
|
3
|
+
version: 2.1
|
4
|
+
|
5
|
+
orbs:
|
6
|
+
# The Node.js orb contains a set of prepackaged CircleCI configuration you can utilize
|
7
|
+
# Orbs reduce the amount of configuration required for common tasks.
|
8
|
+
# See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/node
|
9
|
+
node: circleci/node@4.1
|
10
|
+
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
# Below is the definition of your job to build and test your app, you can rename and customize it as you want.
|
14
|
+
build-and-test:
|
15
|
+
# These next lines define a Docker executor: https://circleci.com/docs/2.0/executor-types/
|
16
|
+
# You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
|
17
|
+
# A list of available CircleCI Docker Convenience Images are available here: https://circleci.com/developer/images/image/cimg/node
|
18
|
+
docker:
|
19
|
+
- image: cimg/node:15.1
|
20
|
+
# Then run your tests!
|
21
|
+
# CircleCI will report the results back to your VCS provider.
|
22
|
+
steps:
|
23
|
+
# Checkout the code as the first step.
|
24
|
+
- checkout
|
25
|
+
# Next, the node orb's install-packages step will install the dependencies from a package.json.
|
26
|
+
# The orb install-packages step will also automatically cache them for faster future runs.
|
27
|
+
- node/install-packages
|
28
|
+
# If you are using yarn instead npm, remove the line above and uncomment the two lines below.
|
29
|
+
# - node/install-packages:
|
30
|
+
# pkg-manager: yarn
|
31
|
+
- run:
|
32
|
+
name: Run tests
|
33
|
+
command: npm test
|
34
|
+
|
35
|
+
workflows:
|
36
|
+
# Below is the definition of your workflow.
|
37
|
+
# Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the build-and-test job above.
|
38
|
+
# CircleCI will run this workflow on every commit.
|
39
|
+
# For more details on extending your workflow, see the configuration docs: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
40
|
+
sample:
|
41
|
+
jobs:
|
42
|
+
- build-and-test
|
43
|
+
# For running simple node tests, you could optionally use the node/test job from the orb to replicate and replace the job above in fewer lines.
|
44
|
+
# - node/test
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Docker Image Community latest CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
push_to_registry:
|
11
|
+
name: Push Docker image to Docker Hub
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
name: Check out the repo
|
17
|
+
- uses: docker/build-push-action@v1
|
18
|
+
with:
|
19
|
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
20
|
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
21
|
+
repository: tiledesk/tiledesk-server
|
22
|
+
tags: latest
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Publish Docker Community image tags
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- '**' # Push events to every tag including hierarchical tags like
|
7
|
+
jobs:
|
8
|
+
|
9
|
+
push_to_registry:
|
10
|
+
name: Push Docker image to Docker Hub
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- name: Check out the repo
|
14
|
+
uses: actions/checkout@v2
|
15
|
+
- name: Push to Docker Hub
|
16
|
+
uses: docker/build-push-action@v1
|
17
|
+
with:
|
18
|
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
19
|
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
20
|
+
repository: tiledesk/tiledesk-server
|
21
|
+
tag_with_ref: true
|
package/CHANGELOG.md
CHANGED
package/Dockerfile
CHANGED
package/Dockerfile-en
CHANGED
package/app.js
CHANGED
@@ -99,6 +99,8 @@ var cacheUtil = require("./utils/cacheUtil");
|
|
99
99
|
var images = require('./routes/images');
|
100
100
|
var files = require('./routes/files');
|
101
101
|
var campaigns = require('./routes/campaigns');
|
102
|
+
var requestUtilRoot = require('./routes/requestUtilRoot');
|
103
|
+
|
102
104
|
|
103
105
|
var bootDataLoader = require('./services/bootDataLoader');
|
104
106
|
var settingDataLoader = require('./services/settingDataLoader');
|
@@ -133,6 +135,11 @@ try {
|
|
133
135
|
}
|
134
136
|
|
135
137
|
|
138
|
+
//enterprise modules can modify pubmodule
|
139
|
+
modulesManager.start();
|
140
|
+
|
141
|
+
pubModulesManager.start();
|
142
|
+
|
136
143
|
|
137
144
|
settingDataLoader.save();
|
138
145
|
schemaMigrationService.checkSchemaMigration();
|
@@ -282,6 +289,8 @@ app.use('/widgets', widgetsLoader);
|
|
282
289
|
app.use('/images', images);
|
283
290
|
app.use('/files', files);
|
284
291
|
app.use('/users', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken], users);
|
292
|
+
app.use('/requests_util', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken], requestUtilRoot);
|
293
|
+
|
285
294
|
|
286
295
|
// TODO security issues
|
287
296
|
if (process.env.DISABLE_TRANSCRIPT_VIEW_PAGE ) {
|
@@ -310,7 +319,6 @@ app.use('/:projectid/', [projectIdSetter, projectSetter]);
|
|
310
319
|
app.use('/:projectid/authtestWithRoleCheck', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken], authtestWithRoleCheck);
|
311
320
|
|
312
321
|
app.use('/:projectid/leads', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRoleOrTypes('agent', ['bot','subscription'])], lead);
|
313
|
-
// guest perche nn c'è guest???? no???
|
314
322
|
app.use('/:projectid/requests/:request_id/messages', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRoleOrTypes(null, ['bot','subscription'])] , message);
|
315
323
|
|
316
324
|
app.use('/:projectid/messages', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRoleOrTypes('agent', ['bot','subscription'])] , messagesRootRoute);
|
@@ -189,7 +189,7 @@ class Chat21Handler {
|
|
189
189
|
setImmediate(() => {
|
190
190
|
winston.debug("Chat21Handler on lead.update ", lead);
|
191
191
|
|
192
|
-
// AGGIORNA SOLO SE PASSA DA GUEST A ALTRO??
|
192
|
+
// TODO AGGIORNA SOLO SE PASSA DA GUEST A ALTRO??
|
193
193
|
Request.find({lead: lead._id, id_project: lead.id_project}, function(err, requests) {
|
194
194
|
|
195
195
|
if (err) {
|
@@ -364,10 +364,10 @@ class Chat21Handler {
|
|
364
364
|
// winston.warn("Chat21Sender this is a direct message. Unimplemented method", message);
|
365
365
|
|
366
366
|
chat21.auth.setAdminToken(adminToken);
|
367
|
-
|
367
|
+
|
368
368
|
// send: function(sender_fullname, recipient_id, recipient_fullname, text, sender_id, attributes, type, metadata){
|
369
369
|
return chat21.messages.send(message.senderFullname, message.recipient,
|
370
|
-
|
370
|
+
message.recipientFullname, message.text, message.sender, message.attributes, message.type, message.metadata)
|
371
371
|
.then(function(data){
|
372
372
|
winston.verbose("Chat21Sender send sent: "+ JSON.stringify(data));
|
373
373
|
|
@@ -383,13 +383,54 @@ class Chat21Handler {
|
|
383
383
|
});
|
384
384
|
|
385
385
|
}).catch(function(err) {
|
386
|
-
winston.error("Chat21
|
386
|
+
winston.error("Chat21 send direct err", err);
|
387
387
|
chat21Event.emit('message.sent.error', err);
|
388
388
|
});
|
389
389
|
|
390
390
|
|
391
391
|
|
392
|
-
}
|
392
|
+
}
|
393
|
+
|
394
|
+
else if (message &&
|
395
|
+
message.status === MessageConstants.CHAT_MESSAGE_STATUS.SENDING &&
|
396
|
+
message.channel_type == MessageConstants.CHANNEL_TYPE.GROUP &&
|
397
|
+
message.channel.name == ChannelConstants.CHAT21) {
|
398
|
+
|
399
|
+
// winston.warn("Chat21Sender this is a group message. Unimplemented method", message);
|
400
|
+
|
401
|
+
chat21.auth.setAdminToken(adminToken);
|
402
|
+
|
403
|
+
var timestamp = Date.now();
|
404
|
+
// var timestamp = undefined;
|
405
|
+
if (message.attributes && message.attributes.clienttimestamp) {
|
406
|
+
timestamp = message.attributes.clienttimestamp;
|
407
|
+
}
|
408
|
+
|
409
|
+
|
410
|
+
return chat21.messages.sendToGroup(message.senderFullname, message.recipient,
|
411
|
+
message.recipientFullname, message.text, message.sender, message.attributes, message.type, message.metadata, timestamp)
|
412
|
+
.then(function(data){
|
413
|
+
winston.verbose("Chat21Sender send sent: "+ JSON.stringify(data));
|
414
|
+
|
415
|
+
|
416
|
+
// chat21.conversations.stopTyping(message.recipient,message.sender);
|
417
|
+
|
418
|
+
chat21Event.emit('message.sent', data);
|
419
|
+
|
420
|
+
messageService.changeStatus(message._id, MessageConstants.CHAT_MESSAGE_STATUS.DELIVERED) .then(function(upMessage){
|
421
|
+
winston.debug("Chat21 message sent ", upMessage.toObject());
|
422
|
+
}).catch(function(err) {
|
423
|
+
winston.error("Error Chat21 message sent with id: "+message._id, err);
|
424
|
+
});
|
425
|
+
|
426
|
+
}).catch(function(err) {
|
427
|
+
winston.error("Chat21 sendToGroup err", err);
|
428
|
+
chat21Event.emit('message.sent.error', err);
|
429
|
+
});
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
} else {
|
393
434
|
winston.error("Chat21Sender this is not a group o direct message", message);
|
394
435
|
return;
|
395
436
|
}
|
@@ -815,6 +856,8 @@ class Chat21Handler {
|
|
815
856
|
|
816
857
|
return chat21.groups.create(group.name, groupMembers, undefined, group_id).then(function(data) {
|
817
858
|
winston.verbose("Chat21 group created: " + JSON.stringify(data));
|
859
|
+
// TODO ritorna success anche se
|
860
|
+
// verbose: Chat21 group created: {"success":false,"err":{"message":"Channel closed","stack":"IllegalOperationError: Channel closed\n at ConfirmChannel.<anonymous> (/usr/src/app/node_modules/amqplib/lib/channel.js:160:11)\n at ConfirmChannel.Channel.publish (/usr/src/app/node_modules/amqplib/lib/callback_model.js:171:17)\n at ConfirmChannel.publish (/usr/src/app/node_modules/amqplib/lib/callback_model.js:301:36)\n at Chat21Api.publish (/usr/src/app/chat21Api/index.js:1028:29)\n at Chat21Api.sendMessageRaw (/usr/src/app/chat21Api/index.js:762:14)\n at Chat21Api.sendGroupWelcomeMessage (/usr/src/app/chat21Api/index.js:205:14)\n at /usr/src/app/chat21Api/index.js:99:22\n at /usr/src/app/chat21Api/index.js:234:17\n at /usr/src/app/chatdb/index.js:77:9\n at executeCallback (/usr/src/app/node_modules/mongodb/lib/operations/execute_operation.js:70:5)\n at updateCallback (/usr/src/app/node_modules/mongodb/lib/operations/update_one.js:41:3)\n at /usr/src/app/node_modules/mongodb/lib/operations/update_one.js:24:64\n at handleCallback (/usr/src/app/node_modules/mongodb/lib/utils.js:128:55)\n at /usr/src/app/node_modules/mongodb/lib/operations/common_functions.js:378:5\n at handler (/usr/src/app/node_modules/mongodb/lib/core/sdam/topology.js:913:24)","stackAtStateChange":"Stack capture: Socket error\n at Connection.C.onSocketError (/usr/src/app/node_modules/amqplib/lib/connection.js:354:13)\n at Connection.emit (events.js:314:20)\n at Socket.go (/usr/src/app/node_modules/amqplib/lib/connection.js:481:12)\n at Socket.emit (events.js:314:20)\n at emitReadable_ (_stream_readable.js:557:12)\n at processTicksAndRejections (internal/process/task_queues.js:83:21)"}}
|
818
861
|
chat21Event.emit('group.create', data);
|
819
862
|
}).catch(function(err) {
|
820
863
|
winston.error("Error creating chat21 group ", err);
|