Built motion from commit 1fa89557.|2.6.10
[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 _0xd1d5=['client','http','request','MailApplication,\x20%s,\x20%s','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','UpdateMailApplication','MailApplication','update','body','options','raw','where','attributes','limit','then','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x22258d,_0x3e9503){var _0x3c0c2d=function(_0x249b1c){while(--_0x249b1c){_0x22258d['push'](_0x22258d['shift']());}};_0x3c0c2d(++_0x3e9503);}(_0xd1d5,0xa4));var _0x5d1d=function(_0x122096,_0x60c295){_0x122096=_0x122096-0x0;var _0x3d1966=_0xd1d5[_0x122096];return _0x3d1966;};'use strict';var _=require(_0x5d1d('0x0'));var util=require(_0x5d1d('0x1'));var moment=require(_0x5d1d('0x2'));var BPromise=require('bluebird');var rs=require(_0x5d1d('0x3'));var fs=require('fs');var Redis=require(_0x5d1d('0x4'));var db=require(_0x5d1d('0x5'))['db'];var utils=require(_0x5d1d('0x6'));var logger=require(_0x5d1d('0x7'))(_0x5d1d('0x8'));var config=require(_0x5d1d('0x9'));var jayson=require(_0x5d1d('0xa'));var client=jayson[_0x5d1d('0xb')][_0x5d1d('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x280771,_0x4d4cc4,_0xb1d25a){return new BPromise(function(_0x55bb6d,_0x4383a0){return client[_0x5d1d('0xd')](_0x280771,_0xb1d25a)['then'](function(_0x177f9c){logger['info'](_0x5d1d('0xe'),_0x4d4cc4,_0x5d1d('0xf'));logger[_0x5d1d('0x10')](_0x5d1d('0x11'),_0x4d4cc4,_0x5d1d('0xf'),JSON[_0x5d1d('0x12')](_0x177f9c));if(_0x177f9c[_0x5d1d('0x13')]){if(_0x177f9c[_0x5d1d('0x13')][_0x5d1d('0x14')]===0x1f4){logger[_0x5d1d('0x13')](_0x5d1d('0xe'),_0x4d4cc4,_0x177f9c[_0x5d1d('0x13')][_0x5d1d('0x15')]);return _0x4383a0(_0x177f9c['error'][_0x5d1d('0x15')]);}logger[_0x5d1d('0x13')](_0x5d1d('0xe'),_0x4d4cc4,_0x177f9c[_0x5d1d('0x13')]['message']);return _0x55bb6d(_0x177f9c[_0x5d1d('0x13')][_0x5d1d('0x15')]);}else{logger[_0x5d1d('0x16')](_0x5d1d('0xe'),_0x4d4cc4,'request\x20sent');_0x55bb6d(_0x177f9c[_0x5d1d('0x17')]['message']);}})[_0x5d1d('0x18')](function(_0x33fe5b){logger[_0x5d1d('0x13')]('MailApplication,\x20%s,\x20%s',_0x4d4cc4,_0x33fe5b);_0x4383a0(_0x33fe5b);});});}exports[_0x5d1d('0x19')]=function(_0x462f2b){var _0x176754=this;return new Promise(function(_0x57a2c5,_0x1ecf88){return db[_0x5d1d('0x1a')][_0x5d1d('0x1b')](_0x462f2b[_0x5d1d('0x1c')],{'raw':_0x462f2b['options']?_0x462f2b[_0x5d1d('0x1d')][_0x5d1d('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x462f2b[_0x5d1d('0x1d')]?_0x462f2b['options'][_0x5d1d('0x1f')]||null:null,'attributes':_0x462f2b[_0x5d1d('0x1d')]?_0x462f2b[_0x5d1d('0x1d')][_0x5d1d('0x20')]||null:null,'limit':_0x462f2b['options']?_0x462f2b[_0x5d1d('0x1d')][_0x5d1d('0x21')]||null:null})[_0x5d1d('0x22')](function(_0x218ed8){logger['info']('UpdateMailApplication',_0x462f2b);logger[_0x5d1d('0x10')](_0x5d1d('0x19'),_0x462f2b,JSON[_0x5d1d('0x12')](_0x218ed8));_0x57a2c5(_0x218ed8);})['catch'](function(_0x2a9b11){logger[_0x5d1d('0x13')](_0x5d1d('0x19'),_0x2a9b11[_0x5d1d('0x15')],_0x462f2b);_0x1ecf88(_0x176754[_0x5d1d('0x13')](0x1f4,_0x2a9b11[_0x5d1d('0x15')]));});});};