Built motion from commit 25580385.|2.6.2
[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 _0x3256=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','request','then','info','MailApplication,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','UpdateMailApplication','MailApplication','options','raw','where','attributes','lodash','util'];(function(_0x3b0dfc,_0x4ddca1){var _0x1f619a=function(_0x3f8a6c){while(--_0x3f8a6c){_0x3b0dfc['push'](_0x3b0dfc['shift']());}};_0x1f619a(++_0x4ddca1);}(_0x3256,0xee));var _0x6325=function(_0x1336ae,_0x2b9434){_0x1336ae=_0x1336ae-0x0;var _0x5b34da=_0x3256[_0x1336ae];return _0x5b34da;};'use strict';var _=require(_0x6325('0x0'));var util=require(_0x6325('0x1'));var moment=require(_0x6325('0x2'));var BPromise=require(_0x6325('0x3'));var rs=require(_0x6325('0x4'));var fs=require('fs');var Redis=require(_0x6325('0x5'));var db=require(_0x6325('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x6325('0x7'))(_0x6325('0x8'));var config=require('../../config/environment');var jayson=require(_0x6325('0x9'));var client=jayson[_0x6325('0xa')][_0x6325('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x343c84,_0x111c1b,_0x89b7f1){return new BPromise(function(_0x2872a2,_0x523feb){return client[_0x6325('0xc')](_0x343c84,_0x89b7f1)[_0x6325('0xd')](function(_0x1cb3bf){logger[_0x6325('0xe')](_0x6325('0xf'),_0x111c1b,_0x6325('0x10'));logger[_0x6325('0x11')]('MailApplication,\x20%s,\x20%s,\x20%s',_0x111c1b,'request\x20sent',JSON[_0x6325('0x12')](_0x1cb3bf));if(_0x1cb3bf[_0x6325('0x13')]){if(_0x1cb3bf[_0x6325('0x13')][_0x6325('0x14')]===0x1f4){logger[_0x6325('0x13')]('MailApplication,\x20%s,\x20%s',_0x111c1b,_0x1cb3bf[_0x6325('0x13')]['message']);return _0x523feb(_0x1cb3bf[_0x6325('0x13')][_0x6325('0x15')]);}logger[_0x6325('0x13')](_0x6325('0xf'),_0x111c1b,_0x1cb3bf[_0x6325('0x13')][_0x6325('0x15')]);return _0x2872a2(_0x1cb3bf[_0x6325('0x13')][_0x6325('0x15')]);}else{logger['info'](_0x6325('0xf'),_0x111c1b,_0x6325('0x10'));_0x2872a2(_0x1cb3bf[_0x6325('0x16')][_0x6325('0x15')]);}})[_0x6325('0x17')](function(_0x345a8a){logger[_0x6325('0x13')](_0x6325('0xf'),_0x111c1b,_0x345a8a);_0x523feb(_0x345a8a);});});}exports[_0x6325('0x18')]=function(_0x234b44){var _0x328e89=this;return new Promise(function(_0x27e4da,_0x15ee7b){return db[_0x6325('0x19')]['update'](_0x234b44['body'],{'raw':_0x234b44['options']?_0x234b44[_0x6325('0x1a')][_0x6325('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x234b44[_0x6325('0x1a')]?_0x234b44[_0x6325('0x1a')][_0x6325('0x1c')]||null:null,'attributes':_0x234b44[_0x6325('0x1a')]?_0x234b44[_0x6325('0x1a')][_0x6325('0x1d')]||null:null,'limit':_0x234b44[_0x6325('0x1a')]?_0x234b44['options']['limit']||null:null})[_0x6325('0xd')](function(_0x390f65){logger[_0x6325('0xe')](_0x6325('0x18'),_0x234b44);logger[_0x6325('0x11')](_0x6325('0x18'),_0x234b44,JSON[_0x6325('0x12')](_0x390f65));_0x27e4da(_0x390f65);})[_0x6325('0x17')](function(_0x359f56){logger[_0x6325('0x13')](_0x6325('0x18'),_0x359f56[_0x6325('0x15')],_0x234b44);_0x15ee7b(_0x328e89[_0x6325('0x13')](0x1f4,_0x359f56[_0x6325('0x15')]));});});};