Built motion from commit (unavailable).|2.3.91
[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 _0x2f74=['../../mysqldb','../../config/utils','../../config/logger','rpc','http','redis','defaults','localhost','socket.io-emitter','./mailMessage.socket','request','info','MailMessage,\x20%s,\x20%s','request\x20sent','debug','MailMessage,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','MailMessage','options','raw','then','CreateMailMessage','lodash','moment','bluebird','randomstring','ioredis'];(function(_0x26de65,_0x51af04){var _0x3e0fc6=function(_0x8ccce1){while(--_0x8ccce1){_0x26de65['push'](_0x26de65['shift']());}};_0x3e0fc6(++_0x51af04);}(_0x2f74,0x7b));var _0x42f7=function(_0x26ac72,_0x482803){_0x26ac72=_0x26ac72-0x0;var _0x25fc90=_0x2f74[_0x26ac72];return _0x25fc90;};'use strict';var _=require(_0x42f7('0x0'));var util=require('util');var moment=require(_0x42f7('0x1'));var BPromise=require(_0x42f7('0x2'));var rs=require(_0x42f7('0x3'));var fs=require('fs');var Redis=require(_0x42f7('0x4'));var db=require(_0x42f7('0x5'))['db'];var utils=require(_0x42f7('0x6'));var logger=require(_0x42f7('0x7'))(_0x42f7('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x42f7('0x9')]({'port':0x232a});config[_0x42f7('0xa')]=_[_0x42f7('0xb')](config[_0x42f7('0xa')],{'host':_0x42f7('0xc'),'port':0x18eb});var socket=require(_0x42f7('0xd'))(new Redis(config[_0x42f7('0xa')]));require(_0x42f7('0xe'))['register'](socket);function respondWithRpcPromise(_0x13538,_0x24fb3b,_0x106807){return new BPromise(function(_0x3a1a00,_0x1f56d2){return client[_0x42f7('0xf')](_0x13538,_0x106807)['then'](function(_0x44480d){logger[_0x42f7('0x10')](_0x42f7('0x11'),_0x24fb3b,_0x42f7('0x12'));logger[_0x42f7('0x13')](_0x42f7('0x14'),_0x24fb3b,_0x42f7('0x12'),JSON[_0x42f7('0x15')](_0x44480d));if(_0x44480d['error']){if(_0x44480d['error'][_0x42f7('0x16')]===0x1f4){logger[_0x42f7('0x17')](_0x42f7('0x11'),_0x24fb3b,_0x44480d[_0x42f7('0x17')][_0x42f7('0x18')]);return _0x1f56d2(_0x44480d['error'][_0x42f7('0x18')]);}logger['error'](_0x42f7('0x11'),_0x24fb3b,_0x44480d[_0x42f7('0x17')][_0x42f7('0x18')]);return _0x3a1a00(_0x44480d[_0x42f7('0x17')][_0x42f7('0x18')]);}else{logger[_0x42f7('0x10')](_0x42f7('0x11'),_0x24fb3b,'request\x20sent');_0x3a1a00(_0x44480d[_0x42f7('0x19')][_0x42f7('0x18')]);}})[_0x42f7('0x1a')](function(_0x61517a){logger[_0x42f7('0x17')](_0x42f7('0x11'),_0x24fb3b,_0x61517a);_0x1f56d2(_0x61517a);});});}exports['CreateMailMessage']=function(_0x2b1910){var _0x4f0fe4=this;return new Promise(function(_0x1ae649,_0x5d9fcf){return db[_0x42f7('0x1b')]['create'](_0x2b1910['body'],{'raw':_0x2b1910['options']?_0x2b1910[_0x42f7('0x1c')][_0x42f7('0x1d')]===undefined?!![]:![]:!![]})[_0x42f7('0x1e')](function(_0x2a755a){logger[_0x42f7('0x10')](_0x42f7('0x1f'),_0x2b1910);logger[_0x42f7('0x13')](_0x42f7('0x1f'),_0x2b1910,JSON[_0x42f7('0x15')](_0x2a755a));_0x1ae649(_0x2a755a);})[_0x42f7('0x1a')](function(_0x2730a1){logger[_0x42f7('0x17')](_0x42f7('0x1f'),_0x2730a1[_0x42f7('0x18')],_0x2b1910);_0x5d9fcf(_0x4f0fe4['error'](0x1f4,_0x2730a1['message']));});});};