d31ec69b900ccffb25eceb328f812b390bf9df0e
[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 _0xd492=['../../config/utils','../../config/logger','rpc','../../config/environment','request','then','info','MailApplication,\x20%s,\x20%s','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','UpdateMailApplication','MailApplication','update','body','options','raw','attributes','limit','util','moment','randomstring','../../mysqldb'];(function(_0x38db66,_0x41727f){var _0x41c00a=function(_0x572bdc){while(--_0x572bdc){_0x38db66['push'](_0x38db66['shift']());}};_0x41c00a(++_0x41727f);}(_0xd492,0x68));var _0x2d49=function(_0x20595d,_0x3db075){_0x20595d=_0x20595d-0x0;var _0x61d1a5=_0xd492[_0x20595d];return _0x61d1a5;};'use strict';var _=require('lodash');var util=require(_0x2d49('0x0'));var moment=require(_0x2d49('0x1'));var BPromise=require('bluebird');var rs=require(_0x2d49('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2d49('0x3'))['db'];var utils=require(_0x2d49('0x4'));var logger=require(_0x2d49('0x5'))(_0x2d49('0x6'));var config=require(_0x2d49('0x7'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x399d2e,_0xcdd120,_0x3584ac){return new BPromise(function(_0x58300a,_0x2079db){return client[_0x2d49('0x8')](_0x399d2e,_0x3584ac)[_0x2d49('0x9')](function(_0x12660c){logger[_0x2d49('0xa')](_0x2d49('0xb'),_0xcdd120,_0x2d49('0xc'));logger[_0x2d49('0xd')](_0x2d49('0xe'),_0xcdd120,'request\x20sent',JSON[_0x2d49('0xf')](_0x12660c));if(_0x12660c['error']){if(_0x12660c['error']['code']===0x1f4){logger[_0x2d49('0x10')]('MailApplication,\x20%s,\x20%s',_0xcdd120,_0x12660c[_0x2d49('0x10')][_0x2d49('0x11')]);return _0x2079db(_0x12660c['error']['message']);}logger[_0x2d49('0x10')](_0x2d49('0xb'),_0xcdd120,_0x12660c['error'][_0x2d49('0x11')]);return _0x58300a(_0x12660c[_0x2d49('0x10')]['message']);}else{logger['info'](_0x2d49('0xb'),_0xcdd120,_0x2d49('0xc'));_0x58300a(_0x12660c['result']['message']);}})[_0x2d49('0x12')](function(_0xe174f0){logger[_0x2d49('0x10')](_0x2d49('0xb'),_0xcdd120,_0xe174f0);_0x2079db(_0xe174f0);});});}exports[_0x2d49('0x13')]=function(_0x284415){var _0x417ec5=this;return new Promise(function(_0x1b7a67,_0x114372){return db[_0x2d49('0x14')][_0x2d49('0x15')](_0x284415[_0x2d49('0x16')],{'raw':_0x284415[_0x2d49('0x17')]?_0x284415['options'][_0x2d49('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x284415[_0x2d49('0x17')]?_0x284415[_0x2d49('0x17')]['where']||null:null,'attributes':_0x284415[_0x2d49('0x17')]?_0x284415['options'][_0x2d49('0x19')]||null:null,'limit':_0x284415[_0x2d49('0x17')]?_0x284415[_0x2d49('0x17')][_0x2d49('0x1a')]||null:null})[_0x2d49('0x9')](function(_0x382d09){logger[_0x2d49('0xa')]('UpdateMailApplication',_0x284415);logger[_0x2d49('0xd')](_0x2d49('0x13'),_0x284415,JSON[_0x2d49('0xf')](_0x382d09));_0x1b7a67(_0x382d09);})[_0x2d49('0x12')](function(_0x22809e){logger[_0x2d49('0x10')](_0x2d49('0x13'),_0x22809e[_0x2d49('0x11')],_0x284415);_0x114372(_0x417ec5[_0x2d49('0x10')](0x1f4,_0x22809e['message']));});});};