4f00af168afeeae2112d799757a93488274c6938
[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 _0x641b=['MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','UpdateMailApplication','MailApplication','update','body','options','raw','where','attributes','limit','info','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','request','then','MailApplication,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x5568ed,_0x61f3be){var _0x406c98=function(_0x3cc9a7){while(--_0x3cc9a7){_0x5568ed['push'](_0x5568ed['shift']());}};_0x406c98(++_0x61f3be);}(_0x641b,0xa0));var _0xb641=function(_0x5d0c84,_0x59a60d){_0x5d0c84=_0x5d0c84-0x0;var _0x5a3980=_0x641b[_0x5d0c84];return _0x5a3980;};'use strict';var _=require(_0xb641('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xb641('0x1'));var rs=require(_0xb641('0x2'));var fs=require('fs');var Redis=require(_0xb641('0x3'));var db=require(_0xb641('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xb641('0x5'))(_0xb641('0x6'));var config=require(_0xb641('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xb641('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2825ba,_0x2f8f30,_0x30459f){return new BPromise(function(_0x1c5338,_0x262d64){return client[_0xb641('0x9')](_0x2825ba,_0x30459f)[_0xb641('0xa')](function(_0x422d0e){logger['info'](_0xb641('0xb'),_0x2f8f30,_0xb641('0xc'));logger[_0xb641('0xd')](_0xb641('0xe'),_0x2f8f30,_0xb641('0xc'),JSON[_0xb641('0xf')](_0x422d0e));if(_0x422d0e[_0xb641('0x10')]){if(_0x422d0e['error']['code']===0x1f4){logger['error'](_0xb641('0xb'),_0x2f8f30,_0x422d0e['error']['message']);return _0x262d64(_0x422d0e[_0xb641('0x10')][_0xb641('0x11')]);}logger[_0xb641('0x10')](_0xb641('0xb'),_0x2f8f30,_0x422d0e[_0xb641('0x10')]['message']);return _0x1c5338(_0x422d0e[_0xb641('0x10')][_0xb641('0x11')]);}else{logger['info'](_0xb641('0xb'),_0x2f8f30,_0xb641('0xc'));_0x1c5338(_0x422d0e['result'][_0xb641('0x11')]);}})[_0xb641('0x12')](function(_0x4758d7){logger['error']('MailApplication,\x20%s,\x20%s',_0x2f8f30,_0x4758d7);_0x262d64(_0x4758d7);});});}exports[_0xb641('0x13')]=function(_0x3ffa2d){var _0x370c8b=this;return new Promise(function(_0x46c5f0,_0x2f9f41){return db[_0xb641('0x14')][_0xb641('0x15')](_0x3ffa2d[_0xb641('0x16')],{'raw':_0x3ffa2d[_0xb641('0x17')]?_0x3ffa2d[_0xb641('0x17')][_0xb641('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3ffa2d[_0xb641('0x17')]?_0x3ffa2d[_0xb641('0x17')][_0xb641('0x19')]||null:null,'attributes':_0x3ffa2d['options']?_0x3ffa2d['options'][_0xb641('0x1a')]||null:null,'limit':_0x3ffa2d[_0xb641('0x17')]?_0x3ffa2d[_0xb641('0x17')][_0xb641('0x1b')]||null:null})[_0xb641('0xa')](function(_0x4e5cbc){logger[_0xb641('0x1c')]('UpdateMailApplication',_0x3ffa2d);logger['debug'](_0xb641('0x13'),_0x3ffa2d,JSON[_0xb641('0xf')](_0x4e5cbc));_0x46c5f0(_0x4e5cbc);})[_0xb641('0x12')](function(_0x1b0e80){logger[_0xb641('0x10')](_0xb641('0x13'),_0x1b0e80[_0xb641('0x11')],_0x3ffa2d);_0x2f9f41(_0x370c8b[_0xb641('0x10')](0x1f4,_0x1b0e80[_0xb641('0x11')]));});});};