Built motion from commit (unavailable).|2.5.14
[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 _0x4157=['../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./mailInteraction.socket','register','then','info','MailInteraction,\x20%s,\x20%s','request\x20sent','MailInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','UpdateMailInteraction','MailInteraction','update','body','raw','options','where','limit','debug','catch','find','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x4200e3,_0xb34e23){var _0x26ac37=function(_0x5b09e5){while(--_0x5b09e5){_0x4200e3['push'](_0x4200e3['shift']());}};_0x26ac37(++_0xb34e23);}(_0x4157,0xf3));var _0x7415=function(_0x3f6112,_0x3b89ab){_0x3f6112=_0x3f6112-0x0;var _0x535587=_0x4157[_0x3f6112];return _0x535587;};'use strict';var _=require(_0x7415('0x0'));var util=require(_0x7415('0x1'));var moment=require(_0x7415('0x2'));var BPromise=require(_0x7415('0x3'));var rs=require(_0x7415('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7415('0x5'))['db'];var utils=require(_0x7415('0x6'));var logger=require(_0x7415('0x7'))(_0x7415('0x8'));var config=require(_0x7415('0x9'));var jayson=require(_0x7415('0xa'));var client=jayson[_0x7415('0xb')][_0x7415('0xc')]({'port':0x232a});config[_0x7415('0xd')]=_['defaults'](config[_0x7415('0xd')],{'host':'localhost','port':0x18eb});var socket=require(_0x7415('0xe'))(new Redis(config['redis']));require(_0x7415('0xf'))[_0x7415('0x10')](socket);function respondWithRpcPromise(_0x30090b,_0xb023fa,_0x9c9c38){return new BPromise(function(_0x1dc06d,_0x283f22){return client['request'](_0x30090b,_0x9c9c38)[_0x7415('0x11')](function(_0xaba79e){logger[_0x7415('0x12')](_0x7415('0x13'),_0xb023fa,_0x7415('0x14'));logger['debug'](_0x7415('0x15'),_0xb023fa,_0x7415('0x14'),JSON[_0x7415('0x16')](_0xaba79e));if(_0xaba79e[_0x7415('0x17')]){if(_0xaba79e[_0x7415('0x17')][_0x7415('0x18')]===0x1f4){logger[_0x7415('0x17')](_0x7415('0x13'),_0xb023fa,_0xaba79e[_0x7415('0x17')][_0x7415('0x19')]);return _0x283f22(_0xaba79e[_0x7415('0x17')][_0x7415('0x19')]);}logger[_0x7415('0x17')]('MailInteraction,\x20%s,\x20%s',_0xb023fa,_0xaba79e[_0x7415('0x17')][_0x7415('0x19')]);return _0x1dc06d(_0xaba79e[_0x7415('0x17')][_0x7415('0x19')]);}else{logger['info'](_0x7415('0x13'),_0xb023fa,_0x7415('0x14'));_0x1dc06d(_0xaba79e['result'][_0x7415('0x19')]);}})['catch'](function(_0x28ca7b){logger[_0x7415('0x17')](_0x7415('0x13'),_0xb023fa,_0x28ca7b);_0x283f22(_0x28ca7b);});});}exports[_0x7415('0x1a')]=function(_0x3cecb9){var _0x28cfec=this;return new Promise(function(_0x266fa3,_0x36a934){return db[_0x7415('0x1b')][_0x7415('0x1c')](_0x3cecb9[_0x7415('0x1d')],{'raw':_0x3cecb9['options']?_0x3cecb9['options'][_0x7415('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3cecb9[_0x7415('0x1f')]?_0x3cecb9[_0x7415('0x1f')][_0x7415('0x20')]||null:null,'attributes':_0x3cecb9['options']?_0x3cecb9[_0x7415('0x1f')]['attributes']||null:null,'limit':_0x3cecb9['options']?_0x3cecb9[_0x7415('0x1f')][_0x7415('0x21')]||null:null})[_0x7415('0x11')](function(_0x1271ca){logger[_0x7415('0x12')](_0x7415('0x1a'),_0x3cecb9);logger[_0x7415('0x22')](_0x7415('0x1a'),_0x3cecb9,JSON[_0x7415('0x16')](_0x1271ca));_0x266fa3(_0x1271ca);})[_0x7415('0x23')](function(_0x57b08a){logger[_0x7415('0x17')](_0x7415('0x1a'),_0x57b08a[_0x7415('0x19')],_0x3cecb9);_0x36a934(_0x28cfec[_0x7415('0x17')](0x1f4,_0x57b08a[_0x7415('0x19')]));});});};exports['AddTagsToMailInteraction']=function(_0x15e69d){return new Promise(function(_0x5d2a50,_0xea1932){return db[_0x7415('0x1b')][_0x7415('0x24')]({'where':_0x15e69d[_0x7415('0x1f')]?_0x15e69d['options'][_0x7415('0x20')]||null:null})['then'](function(_0x5acb16){if(_0x5acb16){return _0x5acb16[_0x7415('0x25')](_0x15e69d[_0x7415('0x1d')][_0x7415('0x26')],_[_0x7415('0x27')](_0x15e69d['body'],[_0x7415('0x26'),'id'])||{});}})[_0x7415('0x28')](function(_0x5ed06d){logger[_0x7415('0x12')](_0x7415('0x29'),_0x15e69d);logger[_0x7415('0x22')](_0x7415('0x29'),_0x15e69d,JSON[_0x7415('0x16')](_0x5ed06d));_0x5d2a50(_0x5ed06d);})[_0x7415('0x23')](function(_0x2b1698){logger[_0x7415('0x17')]('AddTags',_0x2b1698[_0x7415('0x19')],_0x15e69d);_0xea1932(_this[_0x7415('0x17')](0x1f4,_0x2b1698['message']));});});};