Built motion from commit (unavailable).|2.5.7
[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 _0x0a47=['intersection','attributes','fields','length','query','include','merge','find','catch','create','body','params','destroy','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','status','end','json','offset','limit','set','Content-Range','apply','save','update','then','error','stack','name','send','show','model','keys','ChatProactiveAction','rawAttributes','filters'];(function(_0x5627e1,_0x1b2dbf){var _0x2f013f=function(_0x142015){while(--_0x142015){_0x5627e1['push'](_0x5627e1['shift']());}};_0x2f013f(++_0x1b2dbf);}(_0x0a47,0x181));var _0x70a4=function(_0x3de543,_0x189223){_0x3de543=_0x3de543-0x0;var _0x126bfa=_0x0a47[_0x3de543];return _0x126bfa;};'use strict';var pdf=require(_0x70a4('0x0'));var emlformat=require(_0x70a4('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x70a4('0x2'));var jsonpatch=require(_0x70a4('0x3'));var rp=require(_0x70a4('0x4'));var moment=require(_0x70a4('0x5'));var BPromise=require(_0x70a4('0x6'));var Mustache=require('mustache');var util=require(_0x70a4('0x7'));var path=require(_0x70a4('0x8'));var sox=require(_0x70a4('0x9'));var csv=require('to-csv');var ejs=require(_0x70a4('0xa'));var fs=require('fs');var _=require(_0x70a4('0xb'));var squel=require(_0x70a4('0xc'));var crypto=require(_0x70a4('0xd'));var jsforce=require(_0x70a4('0xe'));var deskjs=require(_0x70a4('0xf'));var toCsv=require(_0x70a4('0x10'));var querystring=require(_0x70a4('0x11'));var Papa=require(_0x70a4('0x12'));var Redis=require(_0x70a4('0x13'));var authService=require(_0x70a4('0x14'));var qs=require(_0x70a4('0x15'));var as=require(_0x70a4('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x70a4('0x17'))(_0x70a4('0x18'));var utils=require(_0x70a4('0x19'));var config=require(_0x70a4('0x1a'));var licenseUtil=require(_0x70a4('0x1b'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x55927b,_0x1da10d){_0x1da10d=_0x1da10d||0xcc;return function(_0x577dc4){if(_0x577dc4){return _0x55927b['sendStatus'](_0x1da10d);}return _0x55927b[_0x70a4('0x1c')](_0x1da10d)[_0x70a4('0x1d')]();};}function respondWithResult(_0x3f8d9e,_0x4aa7cf){_0x4aa7cf=_0x4aa7cf||0xc8;return function(_0x54f446){if(_0x54f446){return _0x3f8d9e[_0x70a4('0x1c')](_0x4aa7cf)[_0x70a4('0x1e')](_0x54f446);}};}function respondWithFilteredResult(_0x2fcf6e,_0x1f8d94){return function(_0x242537){if(_0x242537){var _0x287062=_0x242537['count'],_0xad4874=_0x1f8d94['offset'],_0xbc03be=_0x1f8d94[_0x70a4('0x1f')]+_0x1f8d94[_0x70a4('0x20')],_0x19eb4b;if(_0xbc03be>=_0x287062){_0xbc03be=_0x287062;_0x19eb4b=0xc8;}else{_0x19eb4b=0xce;}_0x2fcf6e['status'](_0x19eb4b);return _0x2fcf6e[_0x70a4('0x21')](_0x70a4('0x22'),_0xad4874+'-'+_0xbc03be+'/'+_0x287062)['json'](_0x242537);}return null;};}function patchUpdates(_0x46fd3f){return function(_0x207f5b){try{jsonpatch[_0x70a4('0x23')](_0x207f5b,_0x46fd3f,!![]);}catch(_0x3c754f){return BPromise['reject'](_0x3c754f);}return _0x207f5b[_0x70a4('0x24')]();};}function saveUpdates(_0x47c63f,_0x474cfe){return function(_0x4d7115){if(_0x4d7115){return _0x4d7115[_0x70a4('0x25')](_0x47c63f)[_0x70a4('0x26')](function(_0xb5108c){return _0xb5108c;});}return null;};}function removeEntity(_0x9d7b4,_0x5b4ed7){return function(_0x2c8a21){if(_0x2c8a21){return _0x2c8a21['destroy']()[_0x70a4('0x26')](function(){_0x9d7b4[_0x70a4('0x1c')](0xcc)[_0x70a4('0x1d')]();});}};}function handleEntityNotFound(_0x41c723,_0x25b69e){return function(_0x49d979){if(!_0x49d979){_0x41c723['sendStatus'](0x194);}return _0x49d979;};}function handleError(_0x2e803c,_0x3da438){_0x3da438=_0x3da438||0x1f4;return function(_0x1a9c39){logger[_0x70a4('0x27')](_0x1a9c39[_0x70a4('0x28')]);if(_0x1a9c39[_0x70a4('0x29')]){delete _0x1a9c39['name'];}_0x2e803c['status'](_0x3da438)[_0x70a4('0x2a')](_0x1a9c39);};}exports[_0x70a4('0x2b')]=function(_0x36f342,_0x24bef1){var _0x17b9cc={'raw':!![],'where':{'id':_0x36f342['params']['id']}},_0x24811d={};_0x24811d[_0x70a4('0x2c')]=_[_0x70a4('0x2d')](db[_0x70a4('0x2e')][_0x70a4('0x2f')]);_0x24811d['query']=_['keys'](_0x36f342['query']);_0x24811d[_0x70a4('0x30')]=_[_0x70a4('0x31')](_0x24811d[_0x70a4('0x2c')],_0x24811d['query']);_0x17b9cc[_0x70a4('0x32')]=_[_0x70a4('0x31')](_0x24811d['model'],qs[_0x70a4('0x33')](_0x36f342['query'][_0x70a4('0x33')]));_0x17b9cc[_0x70a4('0x32')]=_0x17b9cc[_0x70a4('0x32')][_0x70a4('0x34')]?_0x17b9cc[_0x70a4('0x32')]:_0x24811d[_0x70a4('0x2c')];if(_0x36f342[_0x70a4('0x35')]['includeAll']){_0x17b9cc[_0x70a4('0x36')]=[{'all':!![]}];}_0x17b9cc=_[_0x70a4('0x37')]({},_0x17b9cc,_0x36f342['options']);return db[_0x70a4('0x2e')][_0x70a4('0x38')](_0x17b9cc)[_0x70a4('0x26')](handleEntityNotFound(_0x24bef1,null))[_0x70a4('0x26')](respondWithResult(_0x24bef1,null))[_0x70a4('0x39')](handleError(_0x24bef1,null));};exports[_0x70a4('0x3a')]=function(_0xc6031,_0x4840a7){return db[_0x70a4('0x2e')]['create'](_0xc6031[_0x70a4('0x3b')],{})[_0x70a4('0x26')](respondWithResult(_0x4840a7,0xc9))[_0x70a4('0x39')](handleError(_0x4840a7,null));};exports[_0x70a4('0x25')]=function(_0x445923,_0x2e8bb7){if(_0x445923[_0x70a4('0x3b')]['id']){delete _0x445923['body']['id'];}return db[_0x70a4('0x2e')][_0x70a4('0x38')]({'where':{'id':_0x445923[_0x70a4('0x3c')]['id']}})[_0x70a4('0x26')](handleEntityNotFound(_0x2e8bb7,null))['then'](saveUpdates(_0x445923['body'],null))['then'](respondWithResult(_0x2e8bb7,null))[_0x70a4('0x39')](handleError(_0x2e8bb7,null));};exports[_0x70a4('0x3d')]=function(_0x7fc00d,_0x48a8f4){return db['ChatProactiveAction']['find']({'where':{'id':_0x7fc00d[_0x70a4('0x3c')]['id']}})[_0x70a4('0x26')](handleEntityNotFound(_0x48a8f4,null))[_0x70a4('0x26')](removeEntity(_0x48a8f4,null))[_0x70a4('0x39')](handleError(_0x48a8f4,null));};