Built motion from commit c0cdc9d8.|2.6.28
[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 _0xe808=['limit','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','then','info','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','MailApplication,\x20%s,\x20%s','message','catch','UpdateMailApplication','MailApplication','update','body','options','raw','where','attributes'];(function(_0x4b4f24,_0x5654a8){var _0x1c13d4=function(_0x4940bf){while(--_0x4940bf){_0x4b4f24['push'](_0x4b4f24['shift']());}};_0x1c13d4(++_0x5654a8);}(_0xe808,0xe9));var _0x8e80=function(_0xcc8e64,_0x22157f){_0xcc8e64=_0xcc8e64-0x0;var _0x1b2f14=_0xe808[_0xcc8e64];return _0x1b2f14;};'use strict';var _=require('lodash');var util=require(_0x8e80('0x0'));var moment=require('moment');var BPromise=require(_0x8e80('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8e80('0x2'));var db=require(_0x8e80('0x3'))['db'];var utils=require(_0x8e80('0x4'));var logger=require(_0x8e80('0x5'))(_0x8e80('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x8e80('0x7')][_0x8e80('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x57ab4f,_0x29560e,_0x43f842){return new BPromise(function(_0x35e101,_0x294d16){return client['request'](_0x57ab4f,_0x43f842)[_0x8e80('0x9')](function(_0x1771f2){logger[_0x8e80('0xa')]('MailApplication,\x20%s,\x20%s',_0x29560e,_0x8e80('0xb'));logger[_0x8e80('0xc')](_0x8e80('0xd'),_0x29560e,_0x8e80('0xb'),JSON[_0x8e80('0xe')](_0x1771f2));if(_0x1771f2['error']){if(_0x1771f2[_0x8e80('0xf')][_0x8e80('0x10')]===0x1f4){logger[_0x8e80('0xf')](_0x8e80('0x11'),_0x29560e,_0x1771f2[_0x8e80('0xf')][_0x8e80('0x12')]);return _0x294d16(_0x1771f2[_0x8e80('0xf')][_0x8e80('0x12')]);}logger[_0x8e80('0xf')]('MailApplication,\x20%s,\x20%s',_0x29560e,_0x1771f2['error']['message']);return _0x35e101(_0x1771f2[_0x8e80('0xf')][_0x8e80('0x12')]);}else{logger['info']('MailApplication,\x20%s,\x20%s',_0x29560e,_0x8e80('0xb'));_0x35e101(_0x1771f2['result'][_0x8e80('0x12')]);}})[_0x8e80('0x13')](function(_0x120e18){logger[_0x8e80('0xf')]('MailApplication,\x20%s,\x20%s',_0x29560e,_0x120e18);_0x294d16(_0x120e18);});});}exports[_0x8e80('0x14')]=function(_0x241196){var _0x5b7ce4=this;return new Promise(function(_0x335f77,_0x5f354f){return db[_0x8e80('0x15')][_0x8e80('0x16')](_0x241196[_0x8e80('0x17')],{'raw':_0x241196[_0x8e80('0x18')]?_0x241196[_0x8e80('0x18')][_0x8e80('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x241196[_0x8e80('0x18')]?_0x241196[_0x8e80('0x18')][_0x8e80('0x1a')]||null:null,'attributes':_0x241196['options']?_0x241196[_0x8e80('0x18')][_0x8e80('0x1b')]||null:null,'limit':_0x241196[_0x8e80('0x18')]?_0x241196['options'][_0x8e80('0x1c')]||null:null})[_0x8e80('0x9')](function(_0x18f0cb){logger[_0x8e80('0xa')](_0x8e80('0x14'),_0x241196);logger[_0x8e80('0xc')](_0x8e80('0x14'),_0x241196,JSON[_0x8e80('0xe')](_0x18f0cb));_0x335f77(_0x18f0cb);})['catch'](function(_0x3ce201){logger[_0x8e80('0xf')]('UpdateMailApplication',_0x3ce201['message'],_0x241196);_0x5f354f(_0x5b7ce4[_0x8e80('0xf')](0x1f4,_0x3ce201[_0x8e80('0x12')]));});});};