358866130c303a84e71eb01d49d82788bb370ffa
[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 _0x9b51=['update','options','raw','where','attributes','limit','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','MailApplication,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','UpdateMailApplication','MailApplication'];(function(_0x142cdb,_0x4fd7e6){var _0x5be46a=function(_0x2a9c40){while(--_0x2a9c40){_0x142cdb['push'](_0x142cdb['shift']());}};_0x5be46a(++_0x4fd7e6);}(_0x9b51,0xc6));var _0x19b5=function(_0x32a2c9,_0x27c01c){_0x32a2c9=_0x32a2c9-0x0;var _0x10d835=_0x9b51[_0x32a2c9];return _0x10d835;};'use strict';var _=require(_0x19b5('0x0'));var util=require(_0x19b5('0x1'));var moment=require('moment');var BPromise=require(_0x19b5('0x2'));var rs=require(_0x19b5('0x3'));var fs=require('fs');var Redis=require(_0x19b5('0x4'));var db=require(_0x19b5('0x5'))['db'];var utils=require(_0x19b5('0x6'));var logger=require(_0x19b5('0x7'))(_0x19b5('0x8'));var config=require(_0x19b5('0x9'));var jayson=require(_0x19b5('0xa'));var client=jayson['client'][_0x19b5('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x309f15,_0x1a8376,_0x2eac5b){return new BPromise(function(_0x3bd84f,_0x2b93c9){return client[_0x19b5('0xc')](_0x309f15,_0x2eac5b)[_0x19b5('0xd')](function(_0x41aad0){logger['info'](_0x19b5('0xe'),_0x1a8376,_0x19b5('0xf'));logger[_0x19b5('0x10')]('MailApplication,\x20%s,\x20%s,\x20%s',_0x1a8376,_0x19b5('0xf'),JSON[_0x19b5('0x11')](_0x41aad0));if(_0x41aad0[_0x19b5('0x12')]){if(_0x41aad0[_0x19b5('0x12')][_0x19b5('0x13')]===0x1f4){logger[_0x19b5('0x12')](_0x19b5('0xe'),_0x1a8376,_0x41aad0[_0x19b5('0x12')]['message']);return _0x2b93c9(_0x41aad0[_0x19b5('0x12')][_0x19b5('0x14')]);}logger[_0x19b5('0x12')](_0x19b5('0xe'),_0x1a8376,_0x41aad0['error'][_0x19b5('0x14')]);return _0x3bd84f(_0x41aad0[_0x19b5('0x12')]['message']);}else{logger[_0x19b5('0x15')]('MailApplication,\x20%s,\x20%s',_0x1a8376,_0x19b5('0xf'));_0x3bd84f(_0x41aad0[_0x19b5('0x16')][_0x19b5('0x14')]);}})[_0x19b5('0x17')](function(_0x23492f){logger['error'](_0x19b5('0xe'),_0x1a8376,_0x23492f);_0x2b93c9(_0x23492f);});});}exports[_0x19b5('0x18')]=function(_0x1f8741){var _0x2cc9c5=this;return new Promise(function(_0x450190,_0x1d6798){return db[_0x19b5('0x19')][_0x19b5('0x1a')](_0x1f8741['body'],{'raw':_0x1f8741[_0x19b5('0x1b')]?_0x1f8741['options'][_0x19b5('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1f8741[_0x19b5('0x1b')]?_0x1f8741['options'][_0x19b5('0x1d')]||null:null,'attributes':_0x1f8741[_0x19b5('0x1b')]?_0x1f8741[_0x19b5('0x1b')][_0x19b5('0x1e')]||null:null,'limit':_0x1f8741['options']?_0x1f8741[_0x19b5('0x1b')][_0x19b5('0x1f')]||null:null})[_0x19b5('0xd')](function(_0x28e93c){logger[_0x19b5('0x15')](_0x19b5('0x18'),_0x1f8741);logger[_0x19b5('0x10')]('UpdateMailApplication',_0x1f8741,JSON[_0x19b5('0x11')](_0x28e93c));_0x450190(_0x28e93c);})[_0x19b5('0x17')](function(_0x34e257){logger[_0x19b5('0x12')](_0x19b5('0x18'),_0x34e257['message'],_0x1f8741);_0x1d6798(_0x2cc9c5['error'](0x1f4,_0x34e257['message']));});});};