d673653547cc201400073933c3854ddfbb4fad56
[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 _0x323e=['attributes','moment','randomstring','ioredis','../../mysqldb','jayson/promise','client','http','then','info','MailApplication,\x20%s,\x20%s','request\x20sent','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','UpdateMailApplication','MailApplication','update','body','options','where'];(function(_0x27bc65,_0x93b685){var _0x6d521f=function(_0x2850cf){while(--_0x2850cf){_0x27bc65['push'](_0x27bc65['shift']());}};_0x6d521f(++_0x93b685);}(_0x323e,0x18d));var _0xe323=function(_0x209eda,_0x5776cf){_0x209eda=_0x209eda-0x0;var _0x1fe649=_0x323e[_0x209eda];return _0x1fe649;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xe323('0x0'));var BPromise=require('bluebird');var rs=require(_0xe323('0x1'));var fs=require('fs');var Redis=require(_0xe323('0x2'));var db=require(_0xe323('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0xe323('0x4'));var client=jayson[_0xe323('0x5')][_0xe323('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x4c7253,_0x10bfa4,_0x10c493){return new BPromise(function(_0x28c733,_0x17e8cc){return client['request'](_0x4c7253,_0x10c493)[_0xe323('0x7')](function(_0x5c58e2){logger[_0xe323('0x8')](_0xe323('0x9'),_0x10bfa4,_0xe323('0xa'));logger['debug'](_0xe323('0xb'),_0x10bfa4,'request\x20sent',JSON[_0xe323('0xc')](_0x5c58e2));if(_0x5c58e2['error']){if(_0x5c58e2[_0xe323('0xd')]['code']===0x1f4){logger[_0xe323('0xd')](_0xe323('0x9'),_0x10bfa4,_0x5c58e2[_0xe323('0xd')][_0xe323('0xe')]);return _0x17e8cc(_0x5c58e2[_0xe323('0xd')][_0xe323('0xe')]);}logger[_0xe323('0xd')](_0xe323('0x9'),_0x10bfa4,_0x5c58e2[_0xe323('0xd')][_0xe323('0xe')]);return _0x28c733(_0x5c58e2[_0xe323('0xd')][_0xe323('0xe')]);}else{logger[_0xe323('0x8')](_0xe323('0x9'),_0x10bfa4,_0xe323('0xa'));_0x28c733(_0x5c58e2['result'][_0xe323('0xe')]);}})['catch'](function(_0x7bc8cc){logger[_0xe323('0xd')](_0xe323('0x9'),_0x10bfa4,_0x7bc8cc);_0x17e8cc(_0x7bc8cc);});});}exports[_0xe323('0xf')]=function(_0x4528a6){var _0x23720f=this;return new Promise(function(_0x46931e,_0x57116f){return db[_0xe323('0x10')][_0xe323('0x11')](_0x4528a6[_0xe323('0x12')],{'raw':_0x4528a6[_0xe323('0x13')]?_0x4528a6[_0xe323('0x13')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4528a6[_0xe323('0x13')]?_0x4528a6['options'][_0xe323('0x14')]||null:null,'attributes':_0x4528a6[_0xe323('0x13')]?_0x4528a6[_0xe323('0x13')][_0xe323('0x15')]||null:null,'limit':_0x4528a6[_0xe323('0x13')]?_0x4528a6['options']['limit']||null:null})[_0xe323('0x7')](function(_0x2714f9){logger[_0xe323('0x8')]('UpdateMailApplication',_0x4528a6);logger['debug'](_0xe323('0xf'),_0x4528a6,JSON[_0xe323('0xc')](_0x2714f9));_0x46931e(_0x2714f9);})['catch'](function(_0x5ebab6){logger[_0xe323('0xd')](_0xe323('0xf'),_0x5ebab6[_0xe323('0xe')],_0x4528a6);_0x57116f(_0x23720f[_0xe323('0xd')](0x1f4,_0x5ebab6['message']));});});};