Built motion from commit 58b0471d.|2.6.29
[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 _0xb9bf=['../../config/environment','client','http','request','then','MailApplication,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','catch','UpdateMailApplication','MailApplication','update','options','raw','debug','lodash','util','moment','randomstring','../../config/utils','../../config/logger','rpc'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0xb9bf,0xaf));var _0xfb9b=function(_0x279d37,_0x14de3f){_0x279d37=_0x279d37-0x0;var _0x530173=_0xb9bf[_0x279d37];return _0x530173;};'use strict';var _=require(_0xfb9b('0x0'));var util=require(_0xfb9b('0x1'));var moment=require(_0xfb9b('0x2'));var BPromise=require('bluebird');var rs=require(_0xfb9b('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xfb9b('0x4'));var logger=require(_0xfb9b('0x5'))(_0xfb9b('0x6'));var config=require(_0xfb9b('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xfb9b('0x8')][_0xfb9b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x356d39,_0x466b70,_0xf97552){return new BPromise(function(_0x3eb465,_0x3e2a44){return client[_0xfb9b('0xa')](_0x356d39,_0xf97552)[_0xfb9b('0xb')](function(_0x4b5fed){logger['info'](_0xfb9b('0xc'),_0x466b70,_0xfb9b('0xd'));logger['debug']('MailApplication,\x20%s,\x20%s,\x20%s',_0x466b70,_0xfb9b('0xd'),JSON[_0xfb9b('0xe')](_0x4b5fed));if(_0x4b5fed['error']){if(_0x4b5fed[_0xfb9b('0xf')][_0xfb9b('0x10')]===0x1f4){logger[_0xfb9b('0xf')](_0xfb9b('0xc'),_0x466b70,_0x4b5fed[_0xfb9b('0xf')][_0xfb9b('0x11')]);return _0x3e2a44(_0x4b5fed['error'][_0xfb9b('0x11')]);}logger[_0xfb9b('0xf')](_0xfb9b('0xc'),_0x466b70,_0x4b5fed[_0xfb9b('0xf')][_0xfb9b('0x11')]);return _0x3eb465(_0x4b5fed[_0xfb9b('0xf')]['message']);}else{logger[_0xfb9b('0x12')](_0xfb9b('0xc'),_0x466b70,_0xfb9b('0xd'));_0x3eb465(_0x4b5fed['result'][_0xfb9b('0x11')]);}})[_0xfb9b('0x13')](function(_0x49fed7){logger['error'](_0xfb9b('0xc'),_0x466b70,_0x49fed7);_0x3e2a44(_0x49fed7);});});}exports[_0xfb9b('0x14')]=function(_0x372f12){var _0x1aad9c=this;return new Promise(function(_0x1af378,_0x4a5136){return db[_0xfb9b('0x15')][_0xfb9b('0x16')](_0x372f12['body'],{'raw':_0x372f12[_0xfb9b('0x17')]?_0x372f12['options'][_0xfb9b('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x372f12[_0xfb9b('0x17')]?_0x372f12['options']['where']||null:null,'attributes':_0x372f12[_0xfb9b('0x17')]?_0x372f12[_0xfb9b('0x17')]['attributes']||null:null,'limit':_0x372f12[_0xfb9b('0x17')]?_0x372f12[_0xfb9b('0x17')]['limit']||null:null})[_0xfb9b('0xb')](function(_0x143ccd){logger[_0xfb9b('0x12')]('UpdateMailApplication',_0x372f12);logger[_0xfb9b('0x19')](_0xfb9b('0x14'),_0x372f12,JSON[_0xfb9b('0xe')](_0x143ccd));_0x1af378(_0x143ccd);})[_0xfb9b('0x13')](function(_0x5d170b){logger[_0xfb9b('0xf')]('UpdateMailApplication',_0x5d170b[_0xfb9b('0x11')],_0x372f12);_0x4a5136(_0x1aad9c['error'](0x1f4,_0x5d170b['message']));});});};