Built motion from commit 896e83a8.|2.6.30
[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 _0x6ec2=['../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./mailInteraction.socket','request','then','info','MailInteraction,\x20%s,\x20%s','MailInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','MailInteraction','update','body','options','raw','where','attributes','UpdateMailInteraction','debug','catch','AddTagsToMailInteraction','find','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc'];(function(_0x417dd8,_0x93f4f7){var _0x184956=function(_0x54bdcd){while(--_0x54bdcd){_0x417dd8['push'](_0x417dd8['shift']());}};_0x184956(++_0x93f4f7);}(_0x6ec2,0x78));var _0x26ec=function(_0x464121,_0x39c954){_0x464121=_0x464121-0x0;var _0x1d0cb8=_0x6ec2[_0x464121];return _0x1d0cb8;};'use strict';var _=require(_0x26ec('0x0'));var util=require(_0x26ec('0x1'));var moment=require(_0x26ec('0x2'));var BPromise=require(_0x26ec('0x3'));var rs=require(_0x26ec('0x4'));var fs=require('fs');var Redis=require(_0x26ec('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x26ec('0x6'));var logger=require(_0x26ec('0x7'))(_0x26ec('0x8'));var config=require(_0x26ec('0x9'));var jayson=require(_0x26ec('0xa'));var client=jayson['client'][_0x26ec('0xb')]({'port':0x232a});config['redis']=_['defaults'](config[_0x26ec('0xc')],{'host':_0x26ec('0xd'),'port':0x18eb});var socket=require(_0x26ec('0xe'))(new Redis(config['redis']));require(_0x26ec('0xf'))['register'](socket);function respondWithRpcPromise(_0x143d9f,_0x23b140,_0x26f0a6){return new BPromise(function(_0xef0a42,_0x3b2efe){return client[_0x26ec('0x10')](_0x143d9f,_0x26f0a6)[_0x26ec('0x11')](function(_0x1a8f40){logger[_0x26ec('0x12')](_0x26ec('0x13'),_0x23b140,'request\x20sent');logger['debug'](_0x26ec('0x14'),_0x23b140,_0x26ec('0x15'),JSON[_0x26ec('0x16')](_0x1a8f40));if(_0x1a8f40[_0x26ec('0x17')]){if(_0x1a8f40[_0x26ec('0x17')][_0x26ec('0x18')]===0x1f4){logger[_0x26ec('0x17')]('MailInteraction,\x20%s,\x20%s',_0x23b140,_0x1a8f40[_0x26ec('0x17')][_0x26ec('0x19')]);return _0x3b2efe(_0x1a8f40[_0x26ec('0x17')][_0x26ec('0x19')]);}logger['error']('MailInteraction,\x20%s,\x20%s',_0x23b140,_0x1a8f40[_0x26ec('0x17')][_0x26ec('0x19')]);return _0xef0a42(_0x1a8f40[_0x26ec('0x17')][_0x26ec('0x19')]);}else{logger['info'](_0x26ec('0x13'),_0x23b140,_0x26ec('0x15'));_0xef0a42(_0x1a8f40['result']['message']);}})['catch'](function(_0x21c3ff){logger[_0x26ec('0x17')](_0x26ec('0x13'),_0x23b140,_0x21c3ff);_0x3b2efe(_0x21c3ff);});});}exports['UpdateMailInteraction']=function(_0x4ad50c){var _0x289978=this;return new Promise(function(_0x125fca,_0x33a28b){return db[_0x26ec('0x1a')][_0x26ec('0x1b')](_0x4ad50c[_0x26ec('0x1c')],{'raw':_0x4ad50c['options']?_0x4ad50c[_0x26ec('0x1d')][_0x26ec('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4ad50c[_0x26ec('0x1d')]?_0x4ad50c[_0x26ec('0x1d')][_0x26ec('0x1f')]||null:null,'attributes':_0x4ad50c['options']?_0x4ad50c['options'][_0x26ec('0x20')]||null:null,'limit':_0x4ad50c[_0x26ec('0x1d')]?_0x4ad50c[_0x26ec('0x1d')]['limit']||null:null})['then'](function(_0x19cadf){logger[_0x26ec('0x12')](_0x26ec('0x21'),_0x4ad50c);logger[_0x26ec('0x22')](_0x26ec('0x21'),_0x4ad50c,JSON[_0x26ec('0x16')](_0x19cadf));_0x125fca(_0x19cadf);})[_0x26ec('0x23')](function(_0x4e9cf8){logger['error']('UpdateMailInteraction',_0x4e9cf8[_0x26ec('0x19')],_0x4ad50c);_0x33a28b(_0x289978[_0x26ec('0x17')](0x1f4,_0x4e9cf8[_0x26ec('0x19')]));});});};exports[_0x26ec('0x24')]=function(_0x19e0fc){return new Promise(function(_0x2fb176,_0x3268e9){return db['MailInteraction'][_0x26ec('0x25')]({'where':_0x19e0fc['options']?_0x19e0fc[_0x26ec('0x1d')][_0x26ec('0x1f')]||null:null})['then'](function(_0x60c16d){if(_0x60c16d){return _0x60c16d[_0x26ec('0x26')](_0x19e0fc[_0x26ec('0x1c')][_0x26ec('0x27')],_[_0x26ec('0x28')](_0x19e0fc[_0x26ec('0x1c')],['ids','id'])||{});}})[_0x26ec('0x29')](function(_0x583c51){logger[_0x26ec('0x12')]('AddTags',_0x19e0fc);logger[_0x26ec('0x22')](_0x26ec('0x2a'),_0x19e0fc,JSON['stringify'](_0x583c51));_0x2fb176(_0x583c51);})[_0x26ec('0x23')](function(_0x13c4c3){logger[_0x26ec('0x17')](_0x26ec('0x2a'),_0x13c4c3[_0x26ec('0x19')],_0x19e0fc);_0x3268e9(_this[_0x26ec('0x17')](0x1f4,_0x13c4c3['message']));});});};