Built motion from commit e1760111.|2.6.18
[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 _0x6f46=['attributes','limit','then','UpdateMailInteraction','debug','AddTagsToMailInteraction','find','addTags','ids','spread','AddTags','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','./mailInteraction.socket','register','request','MailInteraction,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','MailInteraction','body','options','where'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x6f46,0xb8));var _0x66f4=function(_0x2479f7,_0x126ecc){_0x2479f7=_0x2479f7-0x0;var _0x420f4b=_0x6f46[_0x2479f7];return _0x420f4b;};'use strict';var _=require(_0x66f4('0x0'));var util=require('util');var moment=require(_0x66f4('0x1'));var BPromise=require(_0x66f4('0x2'));var rs=require(_0x66f4('0x3'));var fs=require('fs');var Redis=require(_0x66f4('0x4'));var db=require(_0x66f4('0x5'))['db'];var utils=require(_0x66f4('0x6'));var logger=require(_0x66f4('0x7'))(_0x66f4('0x8'));var config=require(_0x66f4('0x9'));var jayson=require(_0x66f4('0xa'));var client=jayson[_0x66f4('0xb')]['http']({'port':0x232a});config['redis']=_[_0x66f4('0xc')](config[_0x66f4('0xd')],{'host':_0x66f4('0xe'),'port':0x18eb});var socket=require(_0x66f4('0xf'))(new Redis(config[_0x66f4('0xd')]));require(_0x66f4('0x10'))[_0x66f4('0x11')](socket);function respondWithRpcPromise(_0x549a15,_0x5d0db9,_0x209717){return new BPromise(function(_0x2dca11,_0x41c102){return client[_0x66f4('0x12')](_0x549a15,_0x209717)['then'](function(_0x2c67a4){logger['info'](_0x66f4('0x13'),_0x5d0db9,_0x66f4('0x14'));logger['debug']('MailInteraction,\x20%s,\x20%s,\x20%s',_0x5d0db9,_0x66f4('0x14'),JSON[_0x66f4('0x15')](_0x2c67a4));if(_0x2c67a4[_0x66f4('0x16')]){if(_0x2c67a4[_0x66f4('0x16')][_0x66f4('0x17')]===0x1f4){logger['error'](_0x66f4('0x13'),_0x5d0db9,_0x2c67a4['error'][_0x66f4('0x18')]);return _0x41c102(_0x2c67a4[_0x66f4('0x16')]['message']);}logger[_0x66f4('0x16')](_0x66f4('0x13'),_0x5d0db9,_0x2c67a4[_0x66f4('0x16')][_0x66f4('0x18')]);return _0x2dca11(_0x2c67a4[_0x66f4('0x16')][_0x66f4('0x18')]);}else{logger[_0x66f4('0x19')](_0x66f4('0x13'),_0x5d0db9,'request\x20sent');_0x2dca11(_0x2c67a4[_0x66f4('0x1a')][_0x66f4('0x18')]);}})['catch'](function(_0x55a208){logger[_0x66f4('0x16')]('MailInteraction,\x20%s,\x20%s',_0x5d0db9,_0x55a208);_0x41c102(_0x55a208);});});}exports['UpdateMailInteraction']=function(_0x555832){var _0x18c5a0=this;return new Promise(function(_0x14de0e,_0x166487){return db[_0x66f4('0x1b')]['update'](_0x555832[_0x66f4('0x1c')],{'raw':_0x555832[_0x66f4('0x1d')]?_0x555832[_0x66f4('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x555832['options']?_0x555832[_0x66f4('0x1d')][_0x66f4('0x1e')]||null:null,'attributes':_0x555832['options']?_0x555832[_0x66f4('0x1d')][_0x66f4('0x1f')]||null:null,'limit':_0x555832[_0x66f4('0x1d')]?_0x555832['options'][_0x66f4('0x20')]||null:null})[_0x66f4('0x21')](function(_0x28e912){logger[_0x66f4('0x19')](_0x66f4('0x22'),_0x555832);logger[_0x66f4('0x23')](_0x66f4('0x22'),_0x555832,JSON['stringify'](_0x28e912));_0x14de0e(_0x28e912);})['catch'](function(_0x2904ec){logger['error'](_0x66f4('0x22'),_0x2904ec[_0x66f4('0x18')],_0x555832);_0x166487(_0x18c5a0[_0x66f4('0x16')](0x1f4,_0x2904ec[_0x66f4('0x18')]));});});};exports[_0x66f4('0x24')]=function(_0x1d877f){return new Promise(function(_0x2b6d71,_0x464a25){return db[_0x66f4('0x1b')][_0x66f4('0x25')]({'where':_0x1d877f['options']?_0x1d877f[_0x66f4('0x1d')][_0x66f4('0x1e')]||null:null})[_0x66f4('0x21')](function(_0x428b2b){if(_0x428b2b){return _0x428b2b[_0x66f4('0x26')](_0x1d877f[_0x66f4('0x1c')]['ids'],_['omit'](_0x1d877f['body'],[_0x66f4('0x27'),'id'])||{});}})[_0x66f4('0x28')](function(_0x2d09b0){logger[_0x66f4('0x19')](_0x66f4('0x29'),_0x1d877f);logger['debug'](_0x66f4('0x29'),_0x1d877f,JSON[_0x66f4('0x15')](_0x2d09b0));_0x2b6d71(_0x2d09b0);})[_0x66f4('0x2a')](function(_0x4652af){logger[_0x66f4('0x16')](_0x66f4('0x29'),_0x4652af[_0x66f4('0x18')],_0x1d877f);_0x464a25(_this[_0x66f4('0x16')](0x1f4,_0x4652af['message']));});});};