Built motion from commit (unavailable).|2.5.15
[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 _0x83f7=['lodash','util','moment','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','register','request','then','info','request\x20sent','debug','stringify','error','code','MailMessage,\x20%s,\x20%s','message','result','CreateMailMessage','MailMessage','create','body','options','raw','catch'];(function(_0x52de64,_0x254a38){var _0x58f454=function(_0x427dda){while(--_0x427dda){_0x52de64['push'](_0x52de64['shift']());}};_0x58f454(++_0x254a38);}(_0x83f7,0x84));var _0x783f=function(_0x11c470,_0x3738e6){_0x11c470=_0x11c470-0x0;var _0xeeeac8=_0x83f7[_0x11c470];return _0xeeeac8;};'use strict';var _=require(_0x783f('0x0'));var util=require(_0x783f('0x1'));var moment=require(_0x783f('0x2'));var BPromise=require('bluebird');var rs=require(_0x783f('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x783f('0x4'));var logger=require(_0x783f('0x5'))(_0x783f('0x6'));var config=require(_0x783f('0x7'));var jayson=require(_0x783f('0x8'));var client=jayson[_0x783f('0x9')][_0x783f('0xa')]({'port':0x232a});config[_0x783f('0xb')]=_['defaults'](config[_0x783f('0xb')],{'host':_0x783f('0xc'),'port':0x18eb});var socket=require(_0x783f('0xd'))(new Redis(config[_0x783f('0xb')]));require('./mailMessage.socket')[_0x783f('0xe')](socket);function respondWithRpcPromise(_0x53b61d,_0x195d40,_0x3f6d1b){return new BPromise(function(_0xc94050,_0x3deb73){return client[_0x783f('0xf')](_0x53b61d,_0x3f6d1b)[_0x783f('0x10')](function(_0x1661c9){logger[_0x783f('0x11')]('MailMessage,\x20%s,\x20%s',_0x195d40,_0x783f('0x12'));logger[_0x783f('0x13')]('MailMessage,\x20%s,\x20%s,\x20%s',_0x195d40,_0x783f('0x12'),JSON[_0x783f('0x14')](_0x1661c9));if(_0x1661c9[_0x783f('0x15')]){if(_0x1661c9[_0x783f('0x15')][_0x783f('0x16')]===0x1f4){logger['error'](_0x783f('0x17'),_0x195d40,_0x1661c9[_0x783f('0x15')][_0x783f('0x18')]);return _0x3deb73(_0x1661c9['error']['message']);}logger[_0x783f('0x15')](_0x783f('0x17'),_0x195d40,_0x1661c9[_0x783f('0x15')][_0x783f('0x18')]);return _0xc94050(_0x1661c9[_0x783f('0x15')][_0x783f('0x18')]);}else{logger['info'](_0x783f('0x17'),_0x195d40,_0x783f('0x12'));_0xc94050(_0x1661c9[_0x783f('0x19')][_0x783f('0x18')]);}})['catch'](function(_0x1ef1bb){logger[_0x783f('0x15')]('MailMessage,\x20%s,\x20%s',_0x195d40,_0x1ef1bb);_0x3deb73(_0x1ef1bb);});});}exports[_0x783f('0x1a')]=function(_0x2c445e){var _0x1b907a=this;return new Promise(function(_0x53c376,_0x8d6b57){return db[_0x783f('0x1b')][_0x783f('0x1c')](_0x2c445e[_0x783f('0x1d')],{'raw':_0x2c445e[_0x783f('0x1e')]?_0x2c445e[_0x783f('0x1e')][_0x783f('0x1f')]===undefined?!![]:![]:!![]})[_0x783f('0x10')](function(_0x451d41){logger['info'](_0x783f('0x1a'),_0x2c445e);logger[_0x783f('0x13')](_0x783f('0x1a'),_0x2c445e,JSON[_0x783f('0x14')](_0x451d41));_0x53c376(_0x451d41);})[_0x783f('0x20')](function(_0x38bc45){logger['error'](_0x783f('0x1a'),_0x38bc45[_0x783f('0x18')],_0x2c445e);_0x8d6b57(_0x1b907a[_0x783f('0x15')](0x1f4,_0x38bc45['message']));});});};