66d01a3046f4821f283b8019f0a86d3f0b447914
[motion2.git] / server / api / mailMessage / mailMessage.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 _0x9f2b=['message','result','catch','MailMessage','create','body','options','CreateMailMessage','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','socket.io-emitter','./mailMessage.socket','register','request','then','info','debug','MailMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','MailMessage,\x20%s,\x20%s'];(function(_0x639b83,_0x54dc17){var _0x5a754b=function(_0x41ad71){while(--_0x41ad71){_0x639b83['push'](_0x639b83['shift']());}};_0x5a754b(++_0x54dc17);}(_0x9f2b,0xb7));var _0xb9f2=function(_0x1e5757,_0x178e60){_0x1e5757=_0x1e5757-0x0;var _0x50f711=_0x9f2b[_0x1e5757];return _0x50f711;};'use strict';var _=require(_0xb9f2('0x0'));var util=require(_0xb9f2('0x1'));var moment=require(_0xb9f2('0x2'));var BPromise=require(_0xb9f2('0x3'));var rs=require(_0xb9f2('0x4'));var fs=require('fs');var Redis=require(_0xb9f2('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xb9f2('0x6'));var logger=require(_0xb9f2('0x7'))(_0xb9f2('0x8'));var config=require(_0xb9f2('0x9'));var jayson=require(_0xb9f2('0xa'));var client=jayson['client'][_0xb9f2('0xb')]({'port':0x232a});config[_0xb9f2('0xc')]=_[_0xb9f2('0xd')](config[_0xb9f2('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0xb9f2('0xe'))(new Redis(config['redis']));require(_0xb9f2('0xf'))[_0xb9f2('0x10')](socket);function respondWithRpcPromise(_0x27a129,_0x2e473a,_0x2aea00){return new BPromise(function(_0x582d84,_0x3ca797){return client[_0xb9f2('0x11')](_0x27a129,_0x2aea00)[_0xb9f2('0x12')](function(_0x3c27ff){logger[_0xb9f2('0x13')]('MailMessage,\x20%s,\x20%s',_0x2e473a,'request\x20sent');logger[_0xb9f2('0x14')](_0xb9f2('0x15'),_0x2e473a,_0xb9f2('0x16'),JSON[_0xb9f2('0x17')](_0x3c27ff));if(_0x3c27ff[_0xb9f2('0x18')]){if(_0x3c27ff[_0xb9f2('0x18')][_0xb9f2('0x19')]===0x1f4){logger['error'](_0xb9f2('0x1a'),_0x2e473a,_0x3c27ff[_0xb9f2('0x18')][_0xb9f2('0x1b')]);return _0x3ca797(_0x3c27ff['error'][_0xb9f2('0x1b')]);}logger[_0xb9f2('0x18')](_0xb9f2('0x1a'),_0x2e473a,_0x3c27ff['error'][_0xb9f2('0x1b')]);return _0x582d84(_0x3c27ff[_0xb9f2('0x18')][_0xb9f2('0x1b')]);}else{logger[_0xb9f2('0x13')](_0xb9f2('0x1a'),_0x2e473a,'request\x20sent');_0x582d84(_0x3c27ff[_0xb9f2('0x1c')][_0xb9f2('0x1b')]);}})[_0xb9f2('0x1d')](function(_0x5c4c30){logger[_0xb9f2('0x18')](_0xb9f2('0x1a'),_0x2e473a,_0x5c4c30);_0x3ca797(_0x5c4c30);});});}exports['CreateMailMessage']=function(_0x52a9c2){var _0x465d94=this;return new Promise(function(_0x129137,_0x4bb435){return db[_0xb9f2('0x1e')][_0xb9f2('0x1f')](_0x52a9c2[_0xb9f2('0x20')],{'raw':_0x52a9c2[_0xb9f2('0x21')]?_0x52a9c2[_0xb9f2('0x21')]['raw']===undefined?!![]:![]:!![]})[_0xb9f2('0x12')](function(_0x44f030){logger[_0xb9f2('0x13')](_0xb9f2('0x22'),_0x52a9c2);logger[_0xb9f2('0x14')](_0xb9f2('0x22'),_0x52a9c2,JSON[_0xb9f2('0x17')](_0x44f030));_0x129137(_0x44f030);})[_0xb9f2('0x1d')](function(_0x15aecb){logger['error'](_0xb9f2('0x22'),_0x15aecb[_0xb9f2('0x1b')],_0x52a9c2);_0x4bb435(_0x465d94[_0xb9f2('0x18')](0x1f4,_0x15aecb['message']));});});};