60babbc3eda725656e190cee7d0d5803179345bf
[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 _0x89f1=['raw','where','limit','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','MailApplication,\x20%s,\x20%s','debug','stringify','error','code','message','info','request\x20sent','result','catch','UpdateMailApplication','update','body','options'];(function(_0x3bb21a,_0x353b56){var _0x5f3983=function(_0x334b13){while(--_0x334b13){_0x3bb21a['push'](_0x3bb21a['shift']());}};_0x5f3983(++_0x353b56);}(_0x89f1,0x11a));var _0x189f=function(_0x50d94a,_0x4bb055){_0x50d94a=_0x50d94a-0x0;var _0x4b88ec=_0x89f1[_0x50d94a];return _0x4b88ec;};'use strict';var _=require(_0x189f('0x0'));var util=require(_0x189f('0x1'));var moment=require(_0x189f('0x2'));var BPromise=require('bluebird');var rs=require(_0x189f('0x3'));var fs=require('fs');var Redis=require(_0x189f('0x4'));var db=require(_0x189f('0x5'))['db'];var utils=require(_0x189f('0x6'));var logger=require(_0x189f('0x7'))(_0x189f('0x8'));var config=require(_0x189f('0x9'));var jayson=require(_0x189f('0xa'));var client=jayson[_0x189f('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x42c85e,_0x3561dd,_0x1cb083){return new BPromise(function(_0x40252c,_0x30d015){return client[_0x189f('0xc')](_0x42c85e,_0x1cb083)[_0x189f('0xd')](function(_0x16c81c){logger['info'](_0x189f('0xe'),_0x3561dd,'request\x20sent');logger[_0x189f('0xf')]('MailApplication,\x20%s,\x20%s,\x20%s',_0x3561dd,'request\x20sent',JSON[_0x189f('0x10')](_0x16c81c));if(_0x16c81c['error']){if(_0x16c81c[_0x189f('0x11')][_0x189f('0x12')]===0x1f4){logger[_0x189f('0x11')](_0x189f('0xe'),_0x3561dd,_0x16c81c[_0x189f('0x11')][_0x189f('0x13')]);return _0x30d015(_0x16c81c[_0x189f('0x11')][_0x189f('0x13')]);}logger[_0x189f('0x11')](_0x189f('0xe'),_0x3561dd,_0x16c81c[_0x189f('0x11')][_0x189f('0x13')]);return _0x40252c(_0x16c81c['error'][_0x189f('0x13')]);}else{logger[_0x189f('0x14')](_0x189f('0xe'),_0x3561dd,_0x189f('0x15'));_0x40252c(_0x16c81c[_0x189f('0x16')][_0x189f('0x13')]);}})[_0x189f('0x17')](function(_0x309524){logger[_0x189f('0x11')](_0x189f('0xe'),_0x3561dd,_0x309524);_0x30d015(_0x309524);});});}exports[_0x189f('0x18')]=function(_0x14141e){var _0x55f688=this;return new Promise(function(_0x2928c6,_0x2bb153){return db['MailApplication'][_0x189f('0x19')](_0x14141e[_0x189f('0x1a')],{'raw':_0x14141e['options']?_0x14141e[_0x189f('0x1b')][_0x189f('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x14141e[_0x189f('0x1b')]?_0x14141e[_0x189f('0x1b')][_0x189f('0x1d')]||null:null,'attributes':_0x14141e[_0x189f('0x1b')]?_0x14141e[_0x189f('0x1b')]['attributes']||null:null,'limit':_0x14141e[_0x189f('0x1b')]?_0x14141e[_0x189f('0x1b')][_0x189f('0x1e')]||null:null})['then'](function(_0x5c520f){logger['info']('UpdateMailApplication',_0x14141e);logger[_0x189f('0xf')](_0x189f('0x18'),_0x14141e,JSON['stringify'](_0x5c520f));_0x2928c6(_0x5c520f);})[_0x189f('0x17')](function(_0x178064){logger[_0x189f('0x11')](_0x189f('0x18'),_0x178064[_0x189f('0x13')],_0x14141e);_0x2bb153(_0x55f688[_0x189f('0x11')](0x1f4,_0x178064[_0x189f('0x13')]));});});};