Built motion from commit b4f7ded2.|2.0.69
[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 _0x9863=['util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','socket.io-emitter','localhost','./mailInteraction.socket','register','then','info','MailInteraction,\x20%s,\x20%s','request\x20sent','debug','MailInteraction,\x20%s,\x20%s,\x20%s','error','message','result','UpdateMailInteraction','MailInteraction','update','body','options','where','limit','stringify','AddTagsToMailInteraction','find','addTags','spread','AddTags','catch'];(function(_0x4fd036,_0x484553){var _0x3d3bce=function(_0x363554){while(--_0x363554){_0x4fd036['push'](_0x4fd036['shift']());}};_0x3d3bce(++_0x484553);}(_0x9863,0x6c));var _0x3986=function(_0x57b54c,_0x54ce0d){_0x57b54c=_0x57b54c-0x0;var _0x59cc19=_0x9863[_0x57b54c];return _0x59cc19;};'use strict';var _=require('lodash');var util=require(_0x3986('0x0'));var moment=require(_0x3986('0x1'));var BPromise=require(_0x3986('0x2'));var rs=require(_0x3986('0x3'));var fs=require('fs');var db=require(_0x3986('0x4'))['db'];var utils=require(_0x3986('0x5'));var logger=require(_0x3986('0x6'))(_0x3986('0x7'));var config=require('../../config/environment');var jayson=require(_0x3986('0x8'));var client=jayson['client']['http']({'port':0x232a});var socket=require(_0x3986('0x9'))({'host':_0x3986('0xa'),'port':0x18eb});require(_0x3986('0xb'))[_0x3986('0xc')](socket);function respondWithRpcPromise(_0x187336,_0x4609f6,_0x109ed8){return new BPromise(function(_0x520b37,_0x3e943c){return client['request'](_0x187336,_0x109ed8)[_0x3986('0xd')](function(_0x203e70){logger[_0x3986('0xe')](_0x3986('0xf'),_0x4609f6,_0x3986('0x10'));logger[_0x3986('0x11')](_0x3986('0x12'),_0x4609f6,'request\x20sent',JSON['stringify'](_0x203e70));if(_0x203e70[_0x3986('0x13')]){if(_0x203e70[_0x3986('0x13')]['code']===0x1f4){logger[_0x3986('0x13')](_0x3986('0xf'),_0x4609f6,_0x203e70[_0x3986('0x13')][_0x3986('0x14')]);return _0x3e943c(_0x203e70[_0x3986('0x13')]['message']);}logger['error']('MailInteraction,\x20%s,\x20%s',_0x4609f6,_0x203e70[_0x3986('0x13')][_0x3986('0x14')]);return _0x520b37(_0x203e70[_0x3986('0x13')][_0x3986('0x14')]);}else{logger[_0x3986('0xe')](_0x3986('0xf'),_0x4609f6,_0x3986('0x10'));_0x520b37(_0x203e70[_0x3986('0x15')][_0x3986('0x14')]);}})['catch'](function(_0x41b1b1){logger['error']('MailInteraction,\x20%s,\x20%s',_0x4609f6,_0x41b1b1);_0x3e943c(_0x41b1b1);});});}exports[_0x3986('0x16')]=function(_0x3e0068){var _0x23ce14=this;return new Promise(function(_0x54ca9d,_0xc16721){return db[_0x3986('0x17')][_0x3986('0x18')](_0x3e0068[_0x3986('0x19')],{'raw':_0x3e0068[_0x3986('0x1a')]?_0x3e0068[_0x3986('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3e0068[_0x3986('0x1a')]?_0x3e0068[_0x3986('0x1a')][_0x3986('0x1b')]||null:null,'attributes':_0x3e0068['options']?_0x3e0068['options']['attributes']||null:null,'limit':_0x3e0068[_0x3986('0x1a')]?_0x3e0068['options'][_0x3986('0x1c')]||null:null})[_0x3986('0xd')](function(_0x28d5e1){logger[_0x3986('0xe')](_0x3986('0x16'),_0x3e0068);logger[_0x3986('0x11')](_0x3986('0x16'),_0x3e0068,JSON[_0x3986('0x1d')](_0x28d5e1));_0x54ca9d(_0x28d5e1);})['catch'](function(_0x9b71d9){logger[_0x3986('0x13')](_0x3986('0x16'),_0x9b71d9[_0x3986('0x14')],_0x3e0068);_0xc16721(_0x23ce14['error'](0x1f4,_0x9b71d9[_0x3986('0x14')]));});});};exports[_0x3986('0x1e')]=function(_0x492bd8){return new Promise(function(_0x3d7d61,_0x1ec898){return db['MailInteraction'][_0x3986('0x1f')]({'where':_0x492bd8[_0x3986('0x1a')]?_0x492bd8[_0x3986('0x1a')]['where']||null:null})['then'](function(_0x493c52){if(_0x493c52){return _0x493c52[_0x3986('0x20')](_0x492bd8[_0x3986('0x19')]['ids'],_['omit'](_0x492bd8[_0x3986('0x19')],['ids','id'])||{});}})[_0x3986('0x21')](function(_0xb50bc7){logger['info'](_0x3986('0x22'),_0x492bd8);logger[_0x3986('0x11')](_0x3986('0x22'),_0x492bd8,JSON[_0x3986('0x1d')](_0xb50bc7));_0x3d7d61(_0xb50bc7);})[_0x3986('0x23')](function(_0x5f1a62){logger[_0x3986('0x13')](_0x3986('0x22'),_0x5f1a62[_0x3986('0x14')],_0x492bd8);_0x1ec898(_this[_0x3986('0x13')](0x1f4,_0x5f1a62[_0x3986('0x14')]));});});};