Built motion from commit 953226e6.|2.6.32
[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 _0x323f=['MailInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','MailInteraction,\x20%s,\x20%s','message','result','catch','UpdateMailInteraction','MailInteraction','body','options','where','attributes','limit','AddTagsToMailInteraction','find','addTags','ids','spread','AddTags','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./mailInteraction.socket','register','request','then','info','request\x20sent','debug'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0x323f,0x1ee));var _0xf323=function(_0x501510,_0x61caa9){_0x501510=_0x501510-0x0;var _0x1e6ee5=_0x323f[_0x501510];return _0x1e6ee5;};'use strict';var _=require('lodash');var util=require(_0xf323('0x0'));var moment=require('moment');var BPromise=require(_0xf323('0x1'));var rs=require(_0xf323('0x2'));var fs=require('fs');var Redis=require(_0xf323('0x3'));var db=require(_0xf323('0x4'))['db'];var utils=require(_0xf323('0x5'));var logger=require(_0xf323('0x6'))(_0xf323('0x7'));var config=require(_0xf323('0x8'));var jayson=require(_0xf323('0x9'));var client=jayson[_0xf323('0xa')]['http']({'port':0x232a});config[_0xf323('0xb')]=_[_0xf323('0xc')](config[_0xf323('0xb')],{'host':_0xf323('0xd'),'port':0x18eb});var socket=require(_0xf323('0xe'))(new Redis(config[_0xf323('0xb')]));require(_0xf323('0xf'))[_0xf323('0x10')](socket);function respondWithRpcPromise(_0x10d1ff,_0x21e82e,_0x22fd48){return new BPromise(function(_0x4196b5,_0x8825ef){return client[_0xf323('0x11')](_0x10d1ff,_0x22fd48)[_0xf323('0x12')](function(_0xb6ec37){logger[_0xf323('0x13')]('MailInteraction,\x20%s,\x20%s',_0x21e82e,_0xf323('0x14'));logger[_0xf323('0x15')](_0xf323('0x16'),_0x21e82e,'request\x20sent',JSON[_0xf323('0x17')](_0xb6ec37));if(_0xb6ec37[_0xf323('0x18')]){if(_0xb6ec37[_0xf323('0x18')][_0xf323('0x19')]===0x1f4){logger[_0xf323('0x18')](_0xf323('0x1a'),_0x21e82e,_0xb6ec37['error']['message']);return _0x8825ef(_0xb6ec37[_0xf323('0x18')][_0xf323('0x1b')]);}logger[_0xf323('0x18')](_0xf323('0x1a'),_0x21e82e,_0xb6ec37[_0xf323('0x18')]['message']);return _0x4196b5(_0xb6ec37[_0xf323('0x18')][_0xf323('0x1b')]);}else{logger[_0xf323('0x13')](_0xf323('0x1a'),_0x21e82e,'request\x20sent');_0x4196b5(_0xb6ec37[_0xf323('0x1c')][_0xf323('0x1b')]);}})[_0xf323('0x1d')](function(_0x41b2cb){logger['error'](_0xf323('0x1a'),_0x21e82e,_0x41b2cb);_0x8825ef(_0x41b2cb);});});}exports[_0xf323('0x1e')]=function(_0x5baab2){var _0x32d7b0=this;return new Promise(function(_0x44378e,_0x32a942){return db[_0xf323('0x1f')]['update'](_0x5baab2[_0xf323('0x20')],{'raw':_0x5baab2[_0xf323('0x21')]?_0x5baab2[_0xf323('0x21')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5baab2[_0xf323('0x21')]?_0x5baab2[_0xf323('0x21')][_0xf323('0x22')]||null:null,'attributes':_0x5baab2[_0xf323('0x21')]?_0x5baab2[_0xf323('0x21')][_0xf323('0x23')]||null:null,'limit':_0x5baab2[_0xf323('0x21')]?_0x5baab2[_0xf323('0x21')][_0xf323('0x24')]||null:null})['then'](function(_0xf85efe){logger[_0xf323('0x13')](_0xf323('0x1e'),_0x5baab2);logger[_0xf323('0x15')](_0xf323('0x1e'),_0x5baab2,JSON[_0xf323('0x17')](_0xf85efe));_0x44378e(_0xf85efe);})['catch'](function(_0x30ed93){logger['error'](_0xf323('0x1e'),_0x30ed93[_0xf323('0x1b')],_0x5baab2);_0x32a942(_0x32d7b0['error'](0x1f4,_0x30ed93[_0xf323('0x1b')]));});});};exports[_0xf323('0x25')]=function(_0x2b6254){return new Promise(function(_0x3dcf65,_0x46e3b1){return db['MailInteraction'][_0xf323('0x26')]({'where':_0x2b6254[_0xf323('0x21')]?_0x2b6254[_0xf323('0x21')][_0xf323('0x22')]||null:null})[_0xf323('0x12')](function(_0x36bd3f){if(_0x36bd3f){return _0x36bd3f[_0xf323('0x27')](_0x2b6254[_0xf323('0x20')][_0xf323('0x28')],_['omit'](_0x2b6254[_0xf323('0x20')],[_0xf323('0x28'),'id'])||{});}})[_0xf323('0x29')](function(_0x3d09d8){logger[_0xf323('0x13')]('AddTags',_0x2b6254);logger[_0xf323('0x15')](_0xf323('0x2a'),_0x2b6254,JSON[_0xf323('0x17')](_0x3d09d8));_0x3dcf65(_0x3d09d8);})[_0xf323('0x1d')](function(_0x3c849a){logger['error'](_0xf323('0x2a'),_0x3c849a[_0xf323('0x1b')],_0x2b6254);_0x46e3b1(_this[_0xf323('0x18')](0x1f4,_0x3c849a[_0xf323('0x1b')]));});});};