Built motion from commit (unavailable).|2.5.9
[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 _0x49e9=['request\x20sent','debug','MailInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','UpdateMailInteraction','MailInteraction','update','body','options','raw','limit','catch','addTags','spread','AddTags','lodash','util','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./mailInteraction.socket','then','info','MailInteraction,\x20%s,\x20%s'];(function(_0x4da572,_0x326408){var _0x378393=function(_0x1357e4){while(--_0x1357e4){_0x4da572['push'](_0x4da572['shift']());}};_0x378393(++_0x326408);}(_0x49e9,0x10f));var _0x949e=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x49e9[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0x949e('0x0'));var util=require(_0x949e('0x1'));var moment=require('moment');var BPromise=require(_0x949e('0x2'));var rs=require(_0x949e('0x3'));var fs=require('fs');var Redis=require(_0x949e('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x949e('0x5'))('rpc');var config=require(_0x949e('0x6'));var jayson=require(_0x949e('0x7'));var client=jayson[_0x949e('0x8')]['http']({'port':0x232a});config[_0x949e('0x9')]=_[_0x949e('0xa')](config[_0x949e('0x9')],{'host':_0x949e('0xb'),'port':0x18eb});var socket=require(_0x949e('0xc'))(new Redis(config[_0x949e('0x9')]));require(_0x949e('0xd'))['register'](socket);function respondWithRpcPromise(_0x394859,_0x50ca96,_0x422dcc){return new BPromise(function(_0x3d0674,_0x255814){return client['request'](_0x394859,_0x422dcc)[_0x949e('0xe')](function(_0x1935a3){logger[_0x949e('0xf')](_0x949e('0x10'),_0x50ca96,_0x949e('0x11'));logger[_0x949e('0x12')](_0x949e('0x13'),_0x50ca96,_0x949e('0x11'),JSON[_0x949e('0x14')](_0x1935a3));if(_0x1935a3[_0x949e('0x15')]){if(_0x1935a3[_0x949e('0x15')][_0x949e('0x16')]===0x1f4){logger[_0x949e('0x15')](_0x949e('0x10'),_0x50ca96,_0x1935a3[_0x949e('0x15')]['message']);return _0x255814(_0x1935a3[_0x949e('0x15')][_0x949e('0x17')]);}logger[_0x949e('0x15')](_0x949e('0x10'),_0x50ca96,_0x1935a3['error'][_0x949e('0x17')]);return _0x3d0674(_0x1935a3[_0x949e('0x15')]['message']);}else{logger[_0x949e('0xf')](_0x949e('0x10'),_0x50ca96,_0x949e('0x11'));_0x3d0674(_0x1935a3[_0x949e('0x18')][_0x949e('0x17')]);}})['catch'](function(_0x31a2ad){logger[_0x949e('0x15')](_0x949e('0x10'),_0x50ca96,_0x31a2ad);_0x255814(_0x31a2ad);});});}exports[_0x949e('0x19')]=function(_0xf319f1){var _0x141bc1=this;return new Promise(function(_0x354e89,_0x2f21bd){return db[_0x949e('0x1a')][_0x949e('0x1b')](_0xf319f1[_0x949e('0x1c')],{'raw':_0xf319f1[_0x949e('0x1d')]?_0xf319f1[_0x949e('0x1d')][_0x949e('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xf319f1[_0x949e('0x1d')]?_0xf319f1[_0x949e('0x1d')]['where']||null:null,'attributes':_0xf319f1[_0x949e('0x1d')]?_0xf319f1[_0x949e('0x1d')]['attributes']||null:null,'limit':_0xf319f1['options']?_0xf319f1[_0x949e('0x1d')][_0x949e('0x1f')]||null:null})[_0x949e('0xe')](function(_0x36c890){logger[_0x949e('0xf')](_0x949e('0x19'),_0xf319f1);logger[_0x949e('0x12')](_0x949e('0x19'),_0xf319f1,JSON[_0x949e('0x14')](_0x36c890));_0x354e89(_0x36c890);})[_0x949e('0x20')](function(_0x5dcc46){logger[_0x949e('0x15')](_0x949e('0x19'),_0x5dcc46['message'],_0xf319f1);_0x2f21bd(_0x141bc1[_0x949e('0x15')](0x1f4,_0x5dcc46[_0x949e('0x17')]));});});};exports['AddTagsToMailInteraction']=function(_0x446401){return new Promise(function(_0x36dc1d,_0x5b9f28){return db[_0x949e('0x1a')]['find']({'where':_0x446401['options']?_0x446401[_0x949e('0x1d')]['where']||null:null})['then'](function(_0x1c9a29){if(_0x1c9a29){return _0x1c9a29[_0x949e('0x21')](_0x446401[_0x949e('0x1c')]['ids'],_['omit'](_0x446401['body'],['ids','id'])||{});}})[_0x949e('0x22')](function(_0x127ae2){logger[_0x949e('0xf')](_0x949e('0x23'),_0x446401);logger['debug'](_0x949e('0x23'),_0x446401,JSON[_0x949e('0x14')](_0x127ae2));_0x36dc1d(_0x127ae2);})[_0x949e('0x20')](function(_0x558632){logger[_0x949e('0x15')](_0x949e('0x23'),_0x558632[_0x949e('0x17')],_0x446401);_0x5b9f28(_this['error'](0x1f4,_0x558632['message']));});});};