Built motion from commit (unavailable).|2.5.9
[motion2.git] / server / api / chatProactiveAction / chatProactiveAction.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xc8c9=['body','catch','update','destroy','rimraf','zip-dir','request-promise','moment','bluebird','mustache','sox','to-csv','lodash','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','count','offset','limit','set','Content-Range','save','then','end','sendStatus','error','stack','name','send','params','keys','query','filters','intersection','attributes','model','fields','length','includeAll','include','merge','find','ChatProactiveAction','create'];(function(_0x2ff4bd,_0x4780a6){var _0x28edc6=function(_0x792380){while(--_0x792380){_0x2ff4bd['push'](_0x2ff4bd['shift']());}};_0x28edc6(++_0x4780a6);}(_0xc8c9,0x1f3));var _0x9c8c=function(_0x1aba25,_0x1faed1){_0x1aba25=_0x1aba25-0x0;var _0x47d997=_0xc8c9[_0x1aba25];return _0x47d997;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x9c8c('0x0'));var zipdir=require(_0x9c8c('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9c8c('0x2'));var moment=require(_0x9c8c('0x3'));var BPromise=require(_0x9c8c('0x4'));var Mustache=require(_0x9c8c('0x5'));var util=require('util');var path=require('path');var sox=require(_0x9c8c('0x6'));var csv=require(_0x9c8c('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x9c8c('0x8'));var squel=require('squel');var crypto=require(_0x9c8c('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x9c8c('0xa'));var toCsv=require(_0x9c8c('0x7'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x9c8c('0xb'));var authService=require(_0x9c8c('0xc'));var qs=require(_0x9c8c('0xd'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9c8c('0xe'));var logger=require(_0x9c8c('0xf'))(_0x9c8c('0x10'));var utils=require(_0x9c8c('0x11'));var config=require(_0x9c8c('0x12'));var licenseUtil=require(_0x9c8c('0x13'));var db=require(_0x9c8c('0x14'))['db'];function respondWithStatusCode(_0x32860d,_0x787949){_0x787949=_0x787949||0xcc;return function(_0x14c1f7){if(_0x14c1f7){return _0x32860d['sendStatus'](_0x787949);}return _0x32860d[_0x9c8c('0x15')](_0x787949)['end']();};}function respondWithResult(_0x224119,_0x26ab05){_0x26ab05=_0x26ab05||0xc8;return function(_0x3ee43d){if(_0x3ee43d){return _0x224119[_0x9c8c('0x15')](_0x26ab05)[_0x9c8c('0x16')](_0x3ee43d);}};}function respondWithFilteredResult(_0x23ec8b,_0x4e3f17){return function(_0x537f75){if(_0x537f75){var _0x22bb57=_0x537f75[_0x9c8c('0x17')],_0x3e2268=_0x4e3f17[_0x9c8c('0x18')],_0x5ed555=_0x4e3f17['offset']+_0x4e3f17[_0x9c8c('0x19')],_0x191acb;if(_0x5ed555>=_0x22bb57){_0x5ed555=_0x22bb57;_0x191acb=0xc8;}else{_0x191acb=0xce;}_0x23ec8b[_0x9c8c('0x15')](_0x191acb);return _0x23ec8b[_0x9c8c('0x1a')](_0x9c8c('0x1b'),_0x3e2268+'-'+_0x5ed555+'/'+_0x22bb57)[_0x9c8c('0x16')](_0x537f75);}return null;};}function patchUpdates(_0x258114){return function(_0x240052){try{jsonpatch['apply'](_0x240052,_0x258114,!![]);}catch(_0x1a5bb8){return BPromise['reject'](_0x1a5bb8);}return _0x240052[_0x9c8c('0x1c')]();};}function saveUpdates(_0x1a9dfd,_0x181652){return function(_0x57afc7){if(_0x57afc7){return _0x57afc7['update'](_0x1a9dfd)['then'](function(_0x1faa20){return _0x1faa20;});}return null;};}function removeEntity(_0x904382,_0x5ac640){return function(_0x2e386d){if(_0x2e386d){return _0x2e386d['destroy']()[_0x9c8c('0x1d')](function(){_0x904382[_0x9c8c('0x15')](0xcc)[_0x9c8c('0x1e')]();});}};}function handleEntityNotFound(_0x13f69b,_0x2e5c88){return function(_0x54b1a6){if(!_0x54b1a6){_0x13f69b[_0x9c8c('0x1f')](0x194);}return _0x54b1a6;};}function handleError(_0x49ee8e,_0x2ea1bc){_0x2ea1bc=_0x2ea1bc||0x1f4;return function(_0x486b60){logger[_0x9c8c('0x20')](_0x486b60[_0x9c8c('0x21')]);if(_0x486b60['name']){delete _0x486b60[_0x9c8c('0x22')];}_0x49ee8e[_0x9c8c('0x15')](_0x2ea1bc)[_0x9c8c('0x23')](_0x486b60);};}exports['show']=function(_0x112038,_0x53f124){var _0x4fae40={'raw':!![],'where':{'id':_0x112038[_0x9c8c('0x24')]['id']}},_0x1a5587={};_0x1a5587['model']=_[_0x9c8c('0x25')](db['ChatProactiveAction']['rawAttributes']);_0x1a5587[_0x9c8c('0x26')]=_['keys'](_0x112038[_0x9c8c('0x26')]);_0x1a5587[_0x9c8c('0x27')]=_[_0x9c8c('0x28')](_0x1a5587['model'],_0x1a5587[_0x9c8c('0x26')]);_0x4fae40[_0x9c8c('0x29')]=_['intersection'](_0x1a5587[_0x9c8c('0x2a')],qs['fields'](_0x112038[_0x9c8c('0x26')][_0x9c8c('0x2b')]));_0x4fae40['attributes']=_0x4fae40[_0x9c8c('0x29')][_0x9c8c('0x2c')]?_0x4fae40[_0x9c8c('0x29')]:_0x1a5587['model'];if(_0x112038['query'][_0x9c8c('0x2d')]){_0x4fae40[_0x9c8c('0x2e')]=[{'all':!![]}];}_0x4fae40=_[_0x9c8c('0x2f')]({},_0x4fae40,_0x112038['options']);return db['ChatProactiveAction'][_0x9c8c('0x30')](_0x4fae40)['then'](handleEntityNotFound(_0x53f124,null))[_0x9c8c('0x1d')](respondWithResult(_0x53f124,null))['catch'](handleError(_0x53f124,null));};exports['create']=function(_0x3d74c1,_0x53d6b1){return db[_0x9c8c('0x31')][_0x9c8c('0x32')](_0x3d74c1[_0x9c8c('0x33')],{})[_0x9c8c('0x1d')](respondWithResult(_0x53d6b1,0xc9))[_0x9c8c('0x34')](handleError(_0x53d6b1,null));};exports[_0x9c8c('0x35')]=function(_0x47a263,_0x158c4b){if(_0x47a263[_0x9c8c('0x33')]['id']){delete _0x47a263[_0x9c8c('0x33')]['id'];}return db[_0x9c8c('0x31')][_0x9c8c('0x30')]({'where':{'id':_0x47a263['params']['id']}})['then'](handleEntityNotFound(_0x158c4b,null))['then'](saveUpdates(_0x47a263['body'],null))[_0x9c8c('0x1d')](respondWithResult(_0x158c4b,null))[_0x9c8c('0x34')](handleError(_0x158c4b,null));};exports[_0x9c8c('0x36')]=function(_0x27fbe8,_0x46115a){return db[_0x9c8c('0x31')]['find']({'where':{'id':_0x27fbe8[_0x9c8c('0x24')]['id']}})['then'](handleEntityNotFound(_0x46115a,null))['then'](removeEntity(_0x46115a,null))['catch'](handleError(_0x46115a,null));};