Built motion from commit da617fac.|2.6.6
[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 _0x6829=['limit','UpdateMailInteraction','AddTagsToMailInteraction','find','where','addTags','ids','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','jayson/promise','client','redis','localhost','socket.io-emitter','./mailInteraction.socket','register','request','then','info','MailInteraction,\x20%s,\x20%s','request\x20sent','debug','MailInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','MailInteraction','body','options'];(function(_0x238830,_0x545f75){var _0x5917f0=function(_0x12f821){while(--_0x12f821){_0x238830['push'](_0x238830['shift']());}};_0x5917f0(++_0x545f75);}(_0x6829,0xf3));var _0x9682=function(_0x341e0f,_0x4a09d0){_0x341e0f=_0x341e0f-0x0;var _0x59555a=_0x6829[_0x341e0f];return _0x59555a;};'use strict';var _=require(_0x9682('0x0'));var util=require(_0x9682('0x1'));var moment=require(_0x9682('0x2'));var BPromise=require(_0x9682('0x3'));var rs=require(_0x9682('0x4'));var fs=require('fs');var Redis=require(_0x9682('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x9682('0x6'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x9682('0x7'));var client=jayson[_0x9682('0x8')]['http']({'port':0x232a});config[_0x9682('0x9')]=_['defaults'](config[_0x9682('0x9')],{'host':_0x9682('0xa'),'port':0x18eb});var socket=require(_0x9682('0xb'))(new Redis(config['redis']));require(_0x9682('0xc'))[_0x9682('0xd')](socket);function respondWithRpcPromise(_0x3a171d,_0x43db3f,_0x43b2b4){return new BPromise(function(_0x311d7c,_0x1bac30){return client[_0x9682('0xe')](_0x3a171d,_0x43b2b4)[_0x9682('0xf')](function(_0x56fd90){logger[_0x9682('0x10')](_0x9682('0x11'),_0x43db3f,_0x9682('0x12'));logger[_0x9682('0x13')](_0x9682('0x14'),_0x43db3f,_0x9682('0x12'),JSON[_0x9682('0x15')](_0x56fd90));if(_0x56fd90[_0x9682('0x16')]){if(_0x56fd90['error'][_0x9682('0x17')]===0x1f4){logger[_0x9682('0x16')]('MailInteraction,\x20%s,\x20%s',_0x43db3f,_0x56fd90[_0x9682('0x16')][_0x9682('0x18')]);return _0x1bac30(_0x56fd90[_0x9682('0x16')][_0x9682('0x18')]);}logger[_0x9682('0x16')](_0x9682('0x11'),_0x43db3f,_0x56fd90['error'][_0x9682('0x18')]);return _0x311d7c(_0x56fd90[_0x9682('0x16')]['message']);}else{logger[_0x9682('0x10')](_0x9682('0x11'),_0x43db3f,_0x9682('0x12'));_0x311d7c(_0x56fd90[_0x9682('0x19')]['message']);}})[_0x9682('0x1a')](function(_0x54163b){logger[_0x9682('0x16')]('MailInteraction,\x20%s,\x20%s',_0x43db3f,_0x54163b);_0x1bac30(_0x54163b);});});}exports['UpdateMailInteraction']=function(_0x427a03){var _0x461307=this;return new Promise(function(_0xfe19d5,_0x144ef0){return db[_0x9682('0x1b')]['update'](_0x427a03[_0x9682('0x1c')],{'raw':_0x427a03[_0x9682('0x1d')]?_0x427a03[_0x9682('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x427a03[_0x9682('0x1d')]?_0x427a03[_0x9682('0x1d')]['where']||null:null,'attributes':_0x427a03[_0x9682('0x1d')]?_0x427a03[_0x9682('0x1d')]['attributes']||null:null,'limit':_0x427a03[_0x9682('0x1d')]?_0x427a03[_0x9682('0x1d')][_0x9682('0x1e')]||null:null})[_0x9682('0xf')](function(_0x22ab80){logger['info'](_0x9682('0x1f'),_0x427a03);logger[_0x9682('0x13')](_0x9682('0x1f'),_0x427a03,JSON['stringify'](_0x22ab80));_0xfe19d5(_0x22ab80);})[_0x9682('0x1a')](function(_0xc9d9d2){logger[_0x9682('0x16')](_0x9682('0x1f'),_0xc9d9d2[_0x9682('0x18')],_0x427a03);_0x144ef0(_0x461307[_0x9682('0x16')](0x1f4,_0xc9d9d2[_0x9682('0x18')]));});});};exports[_0x9682('0x20')]=function(_0xbe4934){return new Promise(function(_0xa7ab1f,_0x43c729){return db['MailInteraction'][_0x9682('0x21')]({'where':_0xbe4934['options']?_0xbe4934[_0x9682('0x1d')][_0x9682('0x22')]||null:null})['then'](function(_0x58f189){if(_0x58f189){return _0x58f189[_0x9682('0x23')](_0xbe4934[_0x9682('0x1c')]['ids'],_['omit'](_0xbe4934['body'],[_0x9682('0x24'),'id'])||{});}})[_0x9682('0x25')](function(_0x381302){logger[_0x9682('0x10')]('AddTags',_0xbe4934);logger[_0x9682('0x13')](_0x9682('0x26'),_0xbe4934,JSON[_0x9682('0x15')](_0x381302));_0xa7ab1f(_0x381302);})['catch'](function(_0x15bdcb){logger[_0x9682('0x16')](_0x9682('0x26'),_0x15bdcb['message'],_0xbe4934);_0x43c729(_this[_0x9682('0x16')](0x1f4,_0x15bdcb[_0x9682('0x18')]));});});};