Built motion from commit d1eab355.|2.6.28
[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 _0xb0e5=['message','result','UpdateMailInteraction','MailInteraction','update','body','options','where','attributes','limit','debug','catch','AddTagsToMailInteraction','find','addTags','omit','ids','spread','AddTags','lodash','util','moment','bluebird','randomstring','../../config/utils','rpc','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','./mailInteraction.socket','register','then','info','request\x20sent','stringify','error','code','MailInteraction,\x20%s,\x20%s'];(function(_0x30c7c5,_0x168208){var _0x29e24e=function(_0x427d3e){while(--_0x427d3e){_0x30c7c5['push'](_0x30c7c5['shift']());}};_0x29e24e(++_0x168208);}(_0xb0e5,0x1ad));var _0x5b0e=function(_0x105278,_0x774ed2){_0x105278=_0x105278-0x0;var _0x47b1f=_0xb0e5[_0x105278];return _0x47b1f;};'use strict';var _=require(_0x5b0e('0x0'));var util=require(_0x5b0e('0x1'));var moment=require(_0x5b0e('0x2'));var BPromise=require(_0x5b0e('0x3'));var rs=require(_0x5b0e('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x5b0e('0x5'));var logger=require('../../config/logger')(_0x5b0e('0x6'));var config=require('../../config/environment');var jayson=require(_0x5b0e('0x7'));var client=jayson[_0x5b0e('0x8')]['http']({'port':0x232a});config['redis']=_[_0x5b0e('0x9')](config[_0x5b0e('0xa')],{'host':_0x5b0e('0xb'),'port':0x18eb});var socket=require(_0x5b0e('0xc'))(new Redis(config[_0x5b0e('0xa')]));require(_0x5b0e('0xd'))[_0x5b0e('0xe')](socket);function respondWithRpcPromise(_0x49b223,_0x72d6c1,_0x4fcc26){return new BPromise(function(_0x178987,_0x5cc90d){return client['request'](_0x49b223,_0x4fcc26)[_0x5b0e('0xf')](function(_0x7bd16){logger[_0x5b0e('0x10')]('MailInteraction,\x20%s,\x20%s',_0x72d6c1,_0x5b0e('0x11'));logger['debug']('MailInteraction,\x20%s,\x20%s,\x20%s',_0x72d6c1,_0x5b0e('0x11'),JSON[_0x5b0e('0x12')](_0x7bd16));if(_0x7bd16[_0x5b0e('0x13')]){if(_0x7bd16[_0x5b0e('0x13')][_0x5b0e('0x14')]===0x1f4){logger[_0x5b0e('0x13')](_0x5b0e('0x15'),_0x72d6c1,_0x7bd16[_0x5b0e('0x13')][_0x5b0e('0x16')]);return _0x5cc90d(_0x7bd16[_0x5b0e('0x13')][_0x5b0e('0x16')]);}logger[_0x5b0e('0x13')](_0x5b0e('0x15'),_0x72d6c1,_0x7bd16[_0x5b0e('0x13')][_0x5b0e('0x16')]);return _0x178987(_0x7bd16[_0x5b0e('0x13')][_0x5b0e('0x16')]);}else{logger[_0x5b0e('0x10')](_0x5b0e('0x15'),_0x72d6c1,_0x5b0e('0x11'));_0x178987(_0x7bd16[_0x5b0e('0x17')][_0x5b0e('0x16')]);}})['catch'](function(_0x4e2964){logger[_0x5b0e('0x13')](_0x5b0e('0x15'),_0x72d6c1,_0x4e2964);_0x5cc90d(_0x4e2964);});});}exports[_0x5b0e('0x18')]=function(_0x4d26a7){var _0x4eddca=this;return new Promise(function(_0x26908b,_0x570a09){return db[_0x5b0e('0x19')][_0x5b0e('0x1a')](_0x4d26a7[_0x5b0e('0x1b')],{'raw':_0x4d26a7[_0x5b0e('0x1c')]?_0x4d26a7['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4d26a7['options']?_0x4d26a7['options'][_0x5b0e('0x1d')]||null:null,'attributes':_0x4d26a7[_0x5b0e('0x1c')]?_0x4d26a7[_0x5b0e('0x1c')][_0x5b0e('0x1e')]||null:null,'limit':_0x4d26a7[_0x5b0e('0x1c')]?_0x4d26a7['options'][_0x5b0e('0x1f')]||null:null})['then'](function(_0xe22b73){logger[_0x5b0e('0x10')](_0x5b0e('0x18'),_0x4d26a7);logger[_0x5b0e('0x20')](_0x5b0e('0x18'),_0x4d26a7,JSON[_0x5b0e('0x12')](_0xe22b73));_0x26908b(_0xe22b73);})[_0x5b0e('0x21')](function(_0x1e8221){logger[_0x5b0e('0x13')](_0x5b0e('0x18'),_0x1e8221[_0x5b0e('0x16')],_0x4d26a7);_0x570a09(_0x4eddca[_0x5b0e('0x13')](0x1f4,_0x1e8221[_0x5b0e('0x16')]));});});};exports[_0x5b0e('0x22')]=function(_0x303e28){return new Promise(function(_0x3587e7,_0x17a648){return db[_0x5b0e('0x19')][_0x5b0e('0x23')]({'where':_0x303e28[_0x5b0e('0x1c')]?_0x303e28['options'][_0x5b0e('0x1d')]||null:null})[_0x5b0e('0xf')](function(_0x36fe50){if(_0x36fe50){return _0x36fe50[_0x5b0e('0x24')](_0x303e28[_0x5b0e('0x1b')]['ids'],_[_0x5b0e('0x25')](_0x303e28[_0x5b0e('0x1b')],[_0x5b0e('0x26'),'id'])||{});}})[_0x5b0e('0x27')](function(_0x34912c){logger[_0x5b0e('0x10')](_0x5b0e('0x28'),_0x303e28);logger['debug'](_0x5b0e('0x28'),_0x303e28,JSON[_0x5b0e('0x12')](_0x34912c));_0x3587e7(_0x34912c);})['catch'](function(_0x1f03b3){logger[_0x5b0e('0x13')](_0x5b0e('0x28'),_0x1f03b3[_0x5b0e('0x16')],_0x303e28);_0x17a648(_this[_0x5b0e('0x13')](0x1f4,_0x1f03b3[_0x5b0e('0x16')]));});});};