From 3fdde522770c6dc28efb943a7a9002b576b56109 Mon Sep 17 00:00:00 2001 From: lolimay Date: Fri, 11 Sep 2020 21:55:14 +0800 Subject: [PATCH 1/5] [NEW] Livechat bridge method setCustomFields --- app/apps/server/bridges/livechat.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/apps/server/bridges/livechat.js b/app/apps/server/bridges/livechat.js index a064cb22c748..d4adfa35b838 100644 --- a/app/apps/server/bridges/livechat.js +++ b/app/apps/server/bridges/livechat.js @@ -192,4 +192,10 @@ export class AppLivechatBridge { return this.orch.getConverters().get('departments').convertDepartment(LivechatDepartment.findOneByIdOrName(value)); } + + async setCustomFields(data, appId) { + this.orch.debugLog(`The App ${ appId } is setting livechat visitor's custom fields.`); + + return Livechat.setCustomFields(data); + } } From 4bf7a479aaecd03a4c06ccd2fb812a42e07192f0 Mon Sep 17 00:00:00 2001 From: lolimay Date: Tue, 15 Sep 2020 10:53:58 +0800 Subject: [PATCH 2/5] Map livechatData to customFields --- app/apps/server/converters/visitors.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/apps/server/converters/visitors.js b/app/apps/server/converters/visitors.js index 55151577b3fb..16e9456ce93a 100644 --- a/app/apps/server/converters/visitors.js +++ b/app/apps/server/converters/visitors.js @@ -32,6 +32,7 @@ export class AppVisitorsConverter { token: 'token', phone: 'phone', visitorEmails: 'visitorEmails', + customFields: 'livechatData', }; return transformMappedData(visitor, map); From ce67a0dd23244426209dd4fb20bce33852a04abd Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Fri, 18 Sep 2020 19:45:48 -0300 Subject: [PATCH 3/5] Add livechatData field to apps converter --- app/apps/server/converters/rooms.js | 2 ++ app/apps/server/converters/visitors.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/apps/server/converters/rooms.js b/app/apps/server/converters/rooms.js index 04eeba2098fd..df7f43f94c6b 100644 --- a/app/apps/server/converters/rooms.js +++ b/app/apps/server/converters/rooms.js @@ -91,6 +91,7 @@ export class AppRoomsConverter { closedAt: room.closedAt, lm: room.lastModifiedAt, customFields: room.customFields, + livechatData: room.livechatData, prid: typeof room.parentRoom === 'undefined' ? undefined : room.parentRoom.id, ...room._USERNAMES && { _USERNAMES: room._USERNAMES }, }; @@ -115,6 +116,7 @@ export class AppRoomsConverter { closedAt: 'closedAt', lastModifiedAt: 'lm', customFields: 'customFields', + livechatData: 'livechatData', isWaitingResponse: 'waitingResponse', isOpen: 'open', _USERNAMES: '_USERNAMES', diff --git a/app/apps/server/converters/visitors.js b/app/apps/server/converters/visitors.js index 16e9456ce93a..e9ea5482a534 100644 --- a/app/apps/server/converters/visitors.js +++ b/app/apps/server/converters/visitors.js @@ -32,7 +32,7 @@ export class AppVisitorsConverter { token: 'token', phone: 'phone', visitorEmails: 'visitorEmails', - customFields: 'livechatData', + livechatData: 'livechatData', }; return transformMappedData(visitor, map); @@ -49,6 +49,7 @@ export class AppVisitorsConverter { name: visitor.name, token: visitor.token, phone: visitor.phone, + livechatData: visitor.livechatData, ...visitor.visitorEmails && { visitorEmails: visitor.visitorEmails }, ...visitor.department && { department: visitor.department }, }; From 6e410633951d9fe77267a5c28395a830ee9f66e8 Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Fri, 18 Sep 2020 19:53:45 -0300 Subject: [PATCH 4/5] Update Apps-Engine version --- package-lock.json | 102 +++++++++++++++++++++++++++++++++------------- package.json | 2 +- 2 files changed, 75 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3b2455825f34..04872487de12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5028,12 +5028,13 @@ } }, "@rocket.chat/apps-engine": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.17.0.tgz", - "integrity": "sha512-4jsN9RUQR9zvZnOr4IZj9bnZR5/kAuSpKJ3JwqTv/DXBeHRSrCCCX0EDoZh5akmQu6x9tRpAXd1DRJWRfI5/Jw==", + "version": "1.18.0-alpha.3824", + "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.18.0-alpha.3824.tgz", + "integrity": "sha512-BYTcdOTB/BRJ/KvA0rflhv1VGfsYPU4aJDzoxBsJiKcoXu1mS51F3QsjEzNHXSJuDrrwtafnuVKI5sRwSmQygQ==", "requires": { "adm-zip": "^0.4.9", "cryptiles": "^4.1.3", + "file-type": "^15.0.1", "lodash.clonedeep": "^4.5.0", "semver": "^5.5.0", "stack-trace": "0.0.10", @@ -5041,10 +5042,16 @@ "uuid": "^3.2.1" }, "dependencies": { - "adm-zip": { - "version": "0.4.16", - "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.16.tgz", - "integrity": "sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg==" + "file-type": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-15.0.1.tgz", + "integrity": "sha512-0LieQlSA3bWUdErNrxzxfI4rhsvNAVPBO06R8pTc1hp9SE6nhqlVyvhcaXoMmtXkBTPnQenbMPLW9X76hH76oQ==", + "requires": { + "readable-web-to-node-stream": "^2.0.0", + "strtok3": "^6.0.3", + "token-types": "^2.0.0", + "typedarray-to-buffer": "^3.1.5" + } }, "typescript": { "version": "2.9.2", @@ -8136,6 +8143,11 @@ } } }, + "@tokenizer/token": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.1.1.tgz", + "integrity": "sha512-XO6INPbZCxdprl+9qa/AAbFFOMzzwqYxpjPgLICrMD6C2FCw6qfJOPcBk6JqqPLSaZ/Qx87qn4rpPmPMwaAK6w==" + }, "@types/anymatch": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz", @@ -8220,8 +8232,7 @@ "@types/debug": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.5.tgz", - "integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==", - "dev": true + "integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==" }, "@types/dedent": { "version": "0.7.0", @@ -17909,7 +17920,7 @@ }, "chownr": { "version": "1.1.1", - "resolved": false, + "resolved": "", "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", "dev": true, "optional": true @@ -17944,7 +17955,7 @@ }, "debug": { "version": "4.1.1", - "resolved": false, + "resolved": "", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, "optional": true, @@ -17975,7 +17986,7 @@ }, "fs-minipass": { "version": "1.2.5", - "resolved": false, + "resolved": "", "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "dev": true, "optional": true, @@ -18009,7 +18020,7 @@ }, "glob": { "version": "7.1.3", - "resolved": false, + "resolved": "", "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "optional": true, @@ -18041,7 +18052,7 @@ }, "ignore-walk": { "version": "3.0.1", - "resolved": false, + "resolved": "", "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", "dev": true, "optional": true, @@ -18062,7 +18073,7 @@ }, "inherits": { "version": "2.0.3", - "resolved": false, + "resolved": "", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true, "optional": true @@ -18110,7 +18121,7 @@ }, "minipass": { "version": "2.3.5", - "resolved": false, + "resolved": "", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, "optional": true, @@ -18121,7 +18132,7 @@ }, "minizlib": { "version": "1.2.1", - "resolved": false, + "resolved": "", "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", "dev": true, "optional": true, @@ -18141,7 +18152,7 @@ }, "ms": { "version": "2.1.1", - "resolved": false, + "resolved": "", "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true, "optional": true @@ -18155,7 +18166,7 @@ }, "needle": { "version": "2.3.0", - "resolved": false, + "resolved": "", "integrity": "sha512-QBZu7aAFR0522EyaXZM0FZ9GLpq6lvQ3uq8gteiDUp7wKdy0lSd2hPlgFwVuW1CBkfEs9PfDQsQzZghLs/psdg==", "dev": true, "optional": true, @@ -18167,7 +18178,7 @@ }, "node-pre-gyp": { "version": "0.12.0", - "resolved": false, + "resolved": "", "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", "dev": true, "optional": true, @@ -18197,14 +18208,14 @@ }, "npm-bundled": { "version": "1.0.6", - "resolved": false, + "resolved": "", "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", "dev": true, "optional": true }, "npm-packlist": { "version": "1.4.1", - "resolved": false, + "resolved": "", "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", "dev": true, "optional": true, @@ -18284,7 +18295,7 @@ }, "process-nextick-args": { "version": "2.0.0", - "resolved": false, + "resolved": "", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true, "optional": true @@ -18329,7 +18340,7 @@ }, "rimraf": { "version": "2.6.3", - "resolved": false, + "resolved": "", "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "dev": true, "optional": true, @@ -18360,7 +18371,7 @@ }, "semver": { "version": "5.7.0", - "resolved": false, + "resolved": "", "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true, "optional": true @@ -18420,7 +18431,7 @@ }, "tar": { "version": "4.4.8", - "resolved": false, + "resolved": "", "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", "dev": true, "optional": true, @@ -18460,7 +18471,7 @@ }, "yallist": { "version": "3.0.3", - "resolved": false, + "resolved": "", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", "dev": true, "optional": true @@ -26370,6 +26381,11 @@ "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.4.456.tgz", "integrity": "sha512-yckJEHq3F48hcp6wStEpbN9McOj328Ib09UrBlGAKxvN2k+qYPN5iq6TH6jD1C0pso7zTep+g/CKsYgdrQd5QA==" }, + "peek-readable": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-3.1.0.tgz", + "integrity": "sha512-KGuODSTV6hcgdZvDrIDBUkN0utcAVj1LL7FfGbM0viKTtCHmtZcuEJ+lGqsp0fTFkGqesdtemV2yUSMeyy3ddA==" + }, "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -29164,6 +29180,11 @@ "util-deprecate": "~1.0.1" } }, + "readable-web-to-node-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-2.0.0.tgz", + "integrity": "sha512-+oZJurc4hXpaaqsN68GoZGQAQIA3qr09Or4fqEsargABnbe5Aau8hFn6ISVleT3cpY/0n/8drn7huyyEvTbghA==" + }, "readdirp": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", @@ -31367,6 +31388,16 @@ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, + "strtok3": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.0.4.tgz", + "integrity": "sha512-rqWMKwsbN9APU47bQTMEYTPcwdpKDtmf1jVhHzNW2cL1WqAxaM9iBb9t5P2fj+RV2YsErUWgQzHD5JwV0uCTEQ==", + "requires": { + "@tokenizer/token": "^0.1.1", + "@types/debug": "^4.1.5", + "peek-readable": "^3.1.0" + } + }, "stubs": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", @@ -32684,6 +32715,22 @@ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" }, + "token-types": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/token-types/-/token-types-2.0.0.tgz", + "integrity": "sha512-WWvu8sGK8/ZmGusekZJJ5NM6rRVTTDO7/bahz4NGiSDb/XsmdYBn6a1N/bymUHuWYTWeuLUg98wUzvE4jPdCZw==", + "requires": { + "@tokenizer/token": "^0.1.0", + "ieee754": "^1.1.13" + }, + "dependencies": { + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + } + } + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -33075,7 +33122,6 @@ "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, "requires": { "is-typedarray": "^1.0.0" } diff --git a/package.json b/package.json index 0966101fb2fb..7e83d9e6726c 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "@nivo/heatmap": "^0.61.0", "@nivo/line": "^0.61.1", "@nivo/pie": "^0.61.1", - "@rocket.chat/apps-engine": "1.17.0", + "@rocket.chat/apps-engine": "1.18.0-alpha.3824", "@rocket.chat/css-in-js": "^0.14.1", "@rocket.chat/fuselage": "^0.14.1", "@rocket.chat/fuselage-hooks": "^0.14.1", From 9e89a3346bac864959f63524f6a540606b4f9095 Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Fri, 18 Sep 2020 20:23:11 -0300 Subject: [PATCH 5/5] Update Apps-Engine version --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04872487de12..2f716c591291 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5028,9 +5028,9 @@ } }, "@rocket.chat/apps-engine": { - "version": "1.18.0-alpha.3824", - "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.18.0-alpha.3824.tgz", - "integrity": "sha512-BYTcdOTB/BRJ/KvA0rflhv1VGfsYPU4aJDzoxBsJiKcoXu1mS51F3QsjEzNHXSJuDrrwtafnuVKI5sRwSmQygQ==", + "version": "1.18.0-beta.3837", + "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.18.0-beta.3837.tgz", + "integrity": "sha512-cAdyBDW7TQNlTsMF/imgySXdGxh3RJdbeYV8Crzl9trHzq0Mu5PPOyZBcro/iutoNE6NxG3ZHS6/5ejf8Qg4BA==", "requires": { "adm-zip": "^0.4.9", "cryptiles": "^4.1.3", diff --git a/package.json b/package.json index 7e83d9e6726c..a31a601d0b1f 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "@nivo/heatmap": "^0.61.0", "@nivo/line": "^0.61.1", "@nivo/pie": "^0.61.1", - "@rocket.chat/apps-engine": "1.18.0-alpha.3824", + "@rocket.chat/apps-engine": "1.18.0-beta.3837", "@rocket.chat/css-in-js": "^0.14.1", "@rocket.chat/fuselage": "^0.14.1", "@rocket.chat/fuselage-hooks": "^0.14.1",