Built motion from commit fa4c4286.|2.6.29
[motion2.git] / server / api / mailInteraction / mailInteraction.rpc.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 _0x3c6c=['ids','omit','AddTags','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis','./mailInteraction.socket','request','then','request\x20sent','debug','MailInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','MailInteraction,\x20%s,\x20%s','message','info','result','catch','UpdateMailInteraction','MailInteraction','update','body','options','raw','where','attributes','limit','AddTagsToMailInteraction','addTags'];(function(_0x3a76d9,_0x1a79bf){var _0x38a850=function(_0x10db62){while(--_0x10db62){_0x3a76d9['push'](_0x3a76d9['shift']());}};_0x38a850(++_0x1a79bf);}(_0x3c6c,0x7b));var _0xc3c6=function(_0x170a95,_0x2962e1){_0x170a95=_0x170a95-0x0;var _0x21d290=_0x3c6c[_0x170a95];return _0x21d290;};'use strict';var _=require(_0xc3c6('0x0'));var util=require('util');var moment=require(_0xc3c6('0x1'));var BPromise=require(_0xc3c6('0x2'));var rs=require(_0xc3c6('0x3'));var fs=require('fs');var Redis=require(_0xc3c6('0x4'));var db=require(_0xc3c6('0x5'))['db'];var utils=require(_0xc3c6('0x6'));var logger=require(_0xc3c6('0x7'))(_0xc3c6('0x8'));var config=require('../../config/environment');var jayson=require(_0xc3c6('0x9'));var client=jayson['client'][_0xc3c6('0xa')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc3c6('0xb')]));require(_0xc3c6('0xc'))['register'](socket);function respondWithRpcPromise(_0x168fdc,_0x1ba453,_0x44b9c9){return new BPromise(function(_0x377311,_0x52b108){return client[_0xc3c6('0xd')](_0x168fdc,_0x44b9c9)[_0xc3c6('0xe')](function(_0x1b78ca){logger['info']('MailInteraction,\x20%s,\x20%s',_0x1ba453,_0xc3c6('0xf'));logger[_0xc3c6('0x10')](_0xc3c6('0x11'),_0x1ba453,_0xc3c6('0xf'),JSON[_0xc3c6('0x12')](_0x1b78ca));if(_0x1b78ca[_0xc3c6('0x13')]){if(_0x1b78ca[_0xc3c6('0x13')][_0xc3c6('0x14')]===0x1f4){logger[_0xc3c6('0x13')](_0xc3c6('0x15'),_0x1ba453,_0x1b78ca[_0xc3c6('0x13')][_0xc3c6('0x16')]);return _0x52b108(_0x1b78ca[_0xc3c6('0x13')][_0xc3c6('0x16')]);}logger[_0xc3c6('0x13')](_0xc3c6('0x15'),_0x1ba453,_0x1b78ca[_0xc3c6('0x13')][_0xc3c6('0x16')]);return _0x377311(_0x1b78ca[_0xc3c6('0x13')][_0xc3c6('0x16')]);}else{logger[_0xc3c6('0x17')](_0xc3c6('0x15'),_0x1ba453,_0xc3c6('0xf'));_0x377311(_0x1b78ca[_0xc3c6('0x18')][_0xc3c6('0x16')]);}})[_0xc3c6('0x19')](function(_0x50a39c){logger[_0xc3c6('0x13')](_0xc3c6('0x15'),_0x1ba453,_0x50a39c);_0x52b108(_0x50a39c);});});}exports[_0xc3c6('0x1a')]=function(_0x248bfe){var _0x3893c4=this;return new Promise(function(_0x3b95ae,_0xfe2f70){return db[_0xc3c6('0x1b')][_0xc3c6('0x1c')](_0x248bfe[_0xc3c6('0x1d')],{'raw':_0x248bfe[_0xc3c6('0x1e')]?_0x248bfe[_0xc3c6('0x1e')][_0xc3c6('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x248bfe[_0xc3c6('0x1e')]?_0x248bfe[_0xc3c6('0x1e')][_0xc3c6('0x20')]||null:null,'attributes':_0x248bfe['options']?_0x248bfe[_0xc3c6('0x1e')][_0xc3c6('0x21')]||null:null,'limit':_0x248bfe[_0xc3c6('0x1e')]?_0x248bfe['options'][_0xc3c6('0x22')]||null:null})[_0xc3c6('0xe')](function(_0x400e3d){logger[_0xc3c6('0x17')](_0xc3c6('0x1a'),_0x248bfe);logger[_0xc3c6('0x10')](_0xc3c6('0x1a'),_0x248bfe,JSON['stringify'](_0x400e3d));_0x3b95ae(_0x400e3d);})[_0xc3c6('0x19')](function(_0x13b909){logger['error'](_0xc3c6('0x1a'),_0x13b909[_0xc3c6('0x16')],_0x248bfe);_0xfe2f70(_0x3893c4[_0xc3c6('0x13')](0x1f4,_0x13b909[_0xc3c6('0x16')]));});});};exports[_0xc3c6('0x23')]=function(_0x420723){return new Promise(function(_0x2b1ae0,_0x2e4094){return db[_0xc3c6('0x1b')]['find']({'where':_0x420723[_0xc3c6('0x1e')]?_0x420723[_0xc3c6('0x1e')][_0xc3c6('0x20')]||null:null})[_0xc3c6('0xe')](function(_0x57b1da){if(_0x57b1da){return _0x57b1da[_0xc3c6('0x24')](_0x420723[_0xc3c6('0x1d')][_0xc3c6('0x25')],_[_0xc3c6('0x26')](_0x420723[_0xc3c6('0x1d')],[_0xc3c6('0x25'),'id'])||{});}})['spread'](function(_0x7fa9ae){logger[_0xc3c6('0x17')](_0xc3c6('0x27'),_0x420723);logger[_0xc3c6('0x10')](_0xc3c6('0x27'),_0x420723,JSON['stringify'](_0x7fa9ae));_0x2b1ae0(_0x7fa9ae);})[_0xc3c6('0x19')](function(_0x3f8917){logger[_0xc3c6('0x13')](_0xc3c6('0x27'),_0x3f8917[_0xc3c6('0x16')],_0x420723);_0x2e4094(_this[_0xc3c6('0x13')](0x1f4,_0x3f8917[_0xc3c6('0x16')]));});});};