Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / mailApplication / mailApplication.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 _0x0f24=['catch','lodash','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','MailApplication,\x20%s,\x20%s','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','UpdateMailApplication','update','options','raw','where','attributes','limit','then'];(function(_0x3ad73a,_0x5669a8){var _0x109bdc=function(_0x104b37){while(--_0x104b37){_0x3ad73a['push'](_0x3ad73a['shift']());}};_0x109bdc(++_0x5669a8);}(_0x0f24,0x187));var _0x40f2=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x0f24[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0x40f2('0x0'));var util=require(_0x40f2('0x1'));var moment=require(_0x40f2('0x2'));var BPromise=require(_0x40f2('0x3'));var rs=require(_0x40f2('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x40f2('0x5'));var logger=require(_0x40f2('0x6'))(_0x40f2('0x7'));var config=require(_0x40f2('0x8'));var jayson=require(_0x40f2('0x9'));var client=jayson[_0x40f2('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4e02af,_0x490a00,_0x39ab79){return new BPromise(function(_0xb9c546,_0x201b1b){return client[_0x40f2('0xb')](_0x4e02af,_0x39ab79)['then'](function(_0x2b1691){logger['info'](_0x40f2('0xc'),_0x490a00,_0x40f2('0xd'));logger[_0x40f2('0xe')](_0x40f2('0xf'),_0x490a00,_0x40f2('0xd'),JSON[_0x40f2('0x10')](_0x2b1691));if(_0x2b1691[_0x40f2('0x11')]){if(_0x2b1691[_0x40f2('0x11')]['code']===0x1f4){logger[_0x40f2('0x11')](_0x40f2('0xc'),_0x490a00,_0x2b1691[_0x40f2('0x11')][_0x40f2('0x12')]);return _0x201b1b(_0x2b1691[_0x40f2('0x11')][_0x40f2('0x12')]);}logger['error'](_0x40f2('0xc'),_0x490a00,_0x2b1691[_0x40f2('0x11')][_0x40f2('0x12')]);return _0xb9c546(_0x2b1691[_0x40f2('0x11')][_0x40f2('0x12')]);}else{logger[_0x40f2('0x13')](_0x40f2('0xc'),_0x490a00,_0x40f2('0xd'));_0xb9c546(_0x2b1691[_0x40f2('0x14')][_0x40f2('0x12')]);}})['catch'](function(_0x32a20){logger[_0x40f2('0x11')](_0x40f2('0xc'),_0x490a00,_0x32a20);_0x201b1b(_0x32a20);});});}exports[_0x40f2('0x15')]=function(_0x5044da){var _0x25dcf3=this;return new Promise(function(_0x22aa18,_0x3221f0){return db['MailApplication'][_0x40f2('0x16')](_0x5044da['body'],{'raw':_0x5044da['options']?_0x5044da[_0x40f2('0x17')][_0x40f2('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5044da['options']?_0x5044da['options'][_0x40f2('0x19')]||null:null,'attributes':_0x5044da[_0x40f2('0x17')]?_0x5044da['options'][_0x40f2('0x1a')]||null:null,'limit':_0x5044da[_0x40f2('0x17')]?_0x5044da[_0x40f2('0x17')][_0x40f2('0x1b')]||null:null})[_0x40f2('0x1c')](function(_0x5af04e){logger['info'](_0x40f2('0x15'),_0x5044da);logger[_0x40f2('0xe')](_0x40f2('0x15'),_0x5044da,JSON[_0x40f2('0x10')](_0x5af04e));_0x22aa18(_0x5af04e);})[_0x40f2('0x1d')](function(_0x4e0555){logger['error']('UpdateMailApplication',_0x4e0555[_0x40f2('0x12')],_0x5044da);_0x3221f0(_0x25dcf3[_0x40f2('0x11')](0x1f4,_0x4e0555[_0x40f2('0x12')]));});});};