Built motion from commit d9028345.|2.5.43
[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 _0xb4c9=['request','then','info','request\x20sent','debug','error','code','MailInteraction,\x20%s,\x20%s','message','result','catch','MailInteraction','update','body','options','raw','where','limit','UpdateMailInteraction','AddTagsToMailInteraction','find','addTags','ids','omit','spread','AddTags','stringify','util','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register'];(function(_0x59145a,_0x1f60f1){var _0xf04d7=function(_0x247581){while(--_0x247581){_0x59145a['push'](_0x59145a['shift']());}};_0xf04d7(++_0x1f60f1);}(_0xb4c9,0xbf));var _0x9b4c=function(_0xef3649,_0x501fdd){_0xef3649=_0xef3649-0x0;var _0x50fb88=_0xb4c9[_0xef3649];return _0x50fb88;};'use strict';var _=require('lodash');var util=require(_0x9b4c('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x9b4c('0x1'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x9b4c('0x2'));var logger=require(_0x9b4c('0x3'))(_0x9b4c('0x4'));var config=require(_0x9b4c('0x5'));var jayson=require(_0x9b4c('0x6'));var client=jayson[_0x9b4c('0x7')][_0x9b4c('0x8')]({'port':0x232a});config[_0x9b4c('0x9')]=_[_0x9b4c('0xa')](config[_0x9b4c('0x9')],{'host':_0x9b4c('0xb'),'port':0x18eb});var socket=require(_0x9b4c('0xc'))(new Redis(config[_0x9b4c('0x9')]));require('./mailInteraction.socket')[_0x9b4c('0xd')](socket);function respondWithRpcPromise(_0x300a7a,_0x23210b,_0x315437){return new BPromise(function(_0x46e6f5,_0xe7b36d){return client[_0x9b4c('0xe')](_0x300a7a,_0x315437)[_0x9b4c('0xf')](function(_0xb27041){logger[_0x9b4c('0x10')]('MailInteraction,\x20%s,\x20%s',_0x23210b,_0x9b4c('0x11'));logger[_0x9b4c('0x12')]('MailInteraction,\x20%s,\x20%s,\x20%s',_0x23210b,_0x9b4c('0x11'),JSON['stringify'](_0xb27041));if(_0xb27041[_0x9b4c('0x13')]){if(_0xb27041['error'][_0x9b4c('0x14')]===0x1f4){logger[_0x9b4c('0x13')](_0x9b4c('0x15'),_0x23210b,_0xb27041[_0x9b4c('0x13')][_0x9b4c('0x16')]);return _0xe7b36d(_0xb27041[_0x9b4c('0x13')]['message']);}logger['error'](_0x9b4c('0x15'),_0x23210b,_0xb27041[_0x9b4c('0x13')]['message']);return _0x46e6f5(_0xb27041['error'][_0x9b4c('0x16')]);}else{logger['info'](_0x9b4c('0x15'),_0x23210b,_0x9b4c('0x11'));_0x46e6f5(_0xb27041[_0x9b4c('0x17')][_0x9b4c('0x16')]);}})[_0x9b4c('0x18')](function(_0x3c797d){logger[_0x9b4c('0x13')]('MailInteraction,\x20%s,\x20%s',_0x23210b,_0x3c797d);_0xe7b36d(_0x3c797d);});});}exports['UpdateMailInteraction']=function(_0xd03081){var _0x27ee27=this;return new Promise(function(_0x2916c9,_0x1cbf69){return db[_0x9b4c('0x19')][_0x9b4c('0x1a')](_0xd03081[_0x9b4c('0x1b')],{'raw':_0xd03081['options']?_0xd03081[_0x9b4c('0x1c')][_0x9b4c('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xd03081[_0x9b4c('0x1c')]?_0xd03081[_0x9b4c('0x1c')][_0x9b4c('0x1e')]||null:null,'attributes':_0xd03081[_0x9b4c('0x1c')]?_0xd03081[_0x9b4c('0x1c')]['attributes']||null:null,'limit':_0xd03081[_0x9b4c('0x1c')]?_0xd03081[_0x9b4c('0x1c')][_0x9b4c('0x1f')]||null:null})[_0x9b4c('0xf')](function(_0x26cdf4){logger[_0x9b4c('0x10')]('UpdateMailInteraction',_0xd03081);logger[_0x9b4c('0x12')](_0x9b4c('0x20'),_0xd03081,JSON['stringify'](_0x26cdf4));_0x2916c9(_0x26cdf4);})[_0x9b4c('0x18')](function(_0x34b672){logger[_0x9b4c('0x13')](_0x9b4c('0x20'),_0x34b672[_0x9b4c('0x16')],_0xd03081);_0x1cbf69(_0x27ee27[_0x9b4c('0x13')](0x1f4,_0x34b672[_0x9b4c('0x16')]));});});};exports[_0x9b4c('0x21')]=function(_0x2d43e9){return new Promise(function(_0x2f800a,_0x551772){return db[_0x9b4c('0x19')][_0x9b4c('0x22')]({'where':_0x2d43e9[_0x9b4c('0x1c')]?_0x2d43e9[_0x9b4c('0x1c')][_0x9b4c('0x1e')]||null:null})[_0x9b4c('0xf')](function(_0x46c26b){if(_0x46c26b){return _0x46c26b[_0x9b4c('0x23')](_0x2d43e9[_0x9b4c('0x1b')][_0x9b4c('0x24')],_[_0x9b4c('0x25')](_0x2d43e9[_0x9b4c('0x1b')],['ids','id'])||{});}})[_0x9b4c('0x26')](function(_0x8dbfec){logger[_0x9b4c('0x10')](_0x9b4c('0x27'),_0x2d43e9);logger[_0x9b4c('0x12')](_0x9b4c('0x27'),_0x2d43e9,JSON[_0x9b4c('0x28')](_0x8dbfec));_0x2f800a(_0x8dbfec);})['catch'](function(_0x1dabb8){logger['error']('AddTags',_0x1dabb8[_0x9b4c('0x16')],_0x2d43e9);_0x551772(_this['error'](0x1f4,_0x1dabb8[_0x9b4c('0x16')]));});});};