Built motion from commit (unavailable).|2.5.1
[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 _0x6308=['info','result','catch','MailInteraction','update','body','raw','options','where','limit','UpdateMailInteraction','AddTagsToMailInteraction','find','addTags','ids','spread','AddTags','lodash','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','redis','defaults','localhost','socket.io-emitter','register','request','then','MailInteraction,\x20%s,\x20%s','request\x20sent','stringify','error','message'];(function(_0x49630d,_0x1a9f1d){var _0x4a38f7=function(_0x2d09f9){while(--_0x2d09f9){_0x49630d['push'](_0x49630d['shift']());}};_0x4a38f7(++_0x1a9f1d);}(_0x6308,0x1f2));var _0x8630=function(_0x279d37,_0x14de3f){_0x279d37=_0x279d37-0x0;var _0x530173=_0x6308[_0x279d37];return _0x530173;};'use strict';var _=require(_0x8630('0x0'));var util=require('util');var moment=require(_0x8630('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8630('0x2'));var db=require(_0x8630('0x3'))['db'];var utils=require(_0x8630('0x4'));var logger=require(_0x8630('0x5'))(_0x8630('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x8630('0x7')]['http']({'port':0x232a});config[_0x8630('0x8')]=_[_0x8630('0x9')](config[_0x8630('0x8')],{'host':_0x8630('0xa'),'port':0x18eb});var socket=require(_0x8630('0xb'))(new Redis(config[_0x8630('0x8')]));require('./mailInteraction.socket')[_0x8630('0xc')](socket);function respondWithRpcPromise(_0x5726fd,_0x3dc3c8,_0x399bb0){return new BPromise(function(_0x2155fd,_0x48c93c){return client[_0x8630('0xd')](_0x5726fd,_0x399bb0)[_0x8630('0xe')](function(_0x3ec6aa){logger['info'](_0x8630('0xf'),_0x3dc3c8,_0x8630('0x10'));logger['debug']('MailInteraction,\x20%s,\x20%s,\x20%s',_0x3dc3c8,_0x8630('0x10'),JSON[_0x8630('0x11')](_0x3ec6aa));if(_0x3ec6aa['error']){if(_0x3ec6aa[_0x8630('0x12')]['code']===0x1f4){logger[_0x8630('0x12')]('MailInteraction,\x20%s,\x20%s',_0x3dc3c8,_0x3ec6aa[_0x8630('0x12')]['message']);return _0x48c93c(_0x3ec6aa['error'][_0x8630('0x13')]);}logger[_0x8630('0x12')]('MailInteraction,\x20%s,\x20%s',_0x3dc3c8,_0x3ec6aa['error'][_0x8630('0x13')]);return _0x2155fd(_0x3ec6aa['error'][_0x8630('0x13')]);}else{logger[_0x8630('0x14')](_0x8630('0xf'),_0x3dc3c8,_0x8630('0x10'));_0x2155fd(_0x3ec6aa[_0x8630('0x15')][_0x8630('0x13')]);}})[_0x8630('0x16')](function(_0x39edd5){logger[_0x8630('0x12')]('MailInteraction,\x20%s,\x20%s',_0x3dc3c8,_0x39edd5);_0x48c93c(_0x39edd5);});});}exports['UpdateMailInteraction']=function(_0x2730c0){var _0x1a773c=this;return new Promise(function(_0x557e74,_0x5cff5c){return db[_0x8630('0x17')][_0x8630('0x18')](_0x2730c0[_0x8630('0x19')],{'raw':_0x2730c0['options']?_0x2730c0['options'][_0x8630('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2730c0['options']?_0x2730c0[_0x8630('0x1b')][_0x8630('0x1c')]||null:null,'attributes':_0x2730c0[_0x8630('0x1b')]?_0x2730c0[_0x8630('0x1b')]['attributes']||null:null,'limit':_0x2730c0[_0x8630('0x1b')]?_0x2730c0[_0x8630('0x1b')][_0x8630('0x1d')]||null:null})[_0x8630('0xe')](function(_0x41871a){logger[_0x8630('0x14')](_0x8630('0x1e'),_0x2730c0);logger['debug']('UpdateMailInteraction',_0x2730c0,JSON[_0x8630('0x11')](_0x41871a));_0x557e74(_0x41871a);})[_0x8630('0x16')](function(_0x439b33){logger[_0x8630('0x12')](_0x8630('0x1e'),_0x439b33[_0x8630('0x13')],_0x2730c0);_0x5cff5c(_0x1a773c[_0x8630('0x12')](0x1f4,_0x439b33[_0x8630('0x13')]));});});};exports[_0x8630('0x1f')]=function(_0x357c15){return new Promise(function(_0x221841,_0x41f74c){return db[_0x8630('0x17')][_0x8630('0x20')]({'where':_0x357c15[_0x8630('0x1b')]?_0x357c15[_0x8630('0x1b')][_0x8630('0x1c')]||null:null})['then'](function(_0x3521a2){if(_0x3521a2){return _0x3521a2[_0x8630('0x21')](_0x357c15[_0x8630('0x19')][_0x8630('0x22')],_['omit'](_0x357c15[_0x8630('0x19')],[_0x8630('0x22'),'id'])||{});}})[_0x8630('0x23')](function(_0x18e62b){logger[_0x8630('0x14')](_0x8630('0x24'),_0x357c15);logger['debug'](_0x8630('0x24'),_0x357c15,JSON[_0x8630('0x11')](_0x18e62b));_0x221841(_0x18e62b);})[_0x8630('0x16')](function(_0x4a970e){logger[_0x8630('0x12')](_0x8630('0x24'),_0x4a970e[_0x8630('0x13')],_0x357c15);_0x41f74c(_this[_0x8630('0x12')](0x1f4,_0x4a970e[_0x8630('0x13')]));});});};