Built motion from commit 775e2a94.|2.6.3
[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 _0x8f59=['redis','localhost','socket.io-emitter','register','info','request\x20sent','debug','MailMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','MailMessage,\x20%s,\x20%s','result','catch','create','body','options','raw','then','CreateMailMessage','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http'];(function(_0x12a26a,_0x418bdd){var _0x263348=function(_0x4f7553){while(--_0x4f7553){_0x12a26a['push'](_0x12a26a['shift']());}};_0x263348(++_0x418bdd);}(_0x8f59,0x11d));var _0x98f5=function(_0x5c7e5e,_0x5e59f8){_0x5c7e5e=_0x5c7e5e-0x0;var _0x2d40cf=_0x8f59[_0x5c7e5e];return _0x2d40cf;};'use strict';var _=require(_0x98f5('0x0'));var util=require(_0x98f5('0x1'));var moment=require(_0x98f5('0x2'));var BPromise=require(_0x98f5('0x3'));var rs=require(_0x98f5('0x4'));var fs=require('fs');var Redis=require(_0x98f5('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x98f5('0x6'));var logger=require(_0x98f5('0x7'))(_0x98f5('0x8'));var config=require(_0x98f5('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x98f5('0xa')][_0x98f5('0xb')]({'port':0x232a});config[_0x98f5('0xc')]=_['defaults'](config['redis'],{'host':_0x98f5('0xd'),'port':0x18eb});var socket=require(_0x98f5('0xe'))(new Redis(config[_0x98f5('0xc')]));require('./mailMessage.socket')[_0x98f5('0xf')](socket);function respondWithRpcPromise(_0x31b669,_0x227cf3,_0x39e85d){return new BPromise(function(_0x4c4abc,_0x26a0fc){return client['request'](_0x31b669,_0x39e85d)['then'](function(_0x3cf4b2){logger[_0x98f5('0x10')]('MailMessage,\x20%s,\x20%s',_0x227cf3,_0x98f5('0x11'));logger[_0x98f5('0x12')](_0x98f5('0x13'),_0x227cf3,_0x98f5('0x11'),JSON[_0x98f5('0x14')](_0x3cf4b2));if(_0x3cf4b2[_0x98f5('0x15')]){if(_0x3cf4b2['error'][_0x98f5('0x16')]===0x1f4){logger[_0x98f5('0x15')]('MailMessage,\x20%s,\x20%s',_0x227cf3,_0x3cf4b2[_0x98f5('0x15')][_0x98f5('0x17')]);return _0x26a0fc(_0x3cf4b2[_0x98f5('0x15')]['message']);}logger[_0x98f5('0x15')](_0x98f5('0x18'),_0x227cf3,_0x3cf4b2[_0x98f5('0x15')]['message']);return _0x4c4abc(_0x3cf4b2[_0x98f5('0x15')][_0x98f5('0x17')]);}else{logger['info'](_0x98f5('0x18'),_0x227cf3,'request\x20sent');_0x4c4abc(_0x3cf4b2[_0x98f5('0x19')][_0x98f5('0x17')]);}})[_0x98f5('0x1a')](function(_0x11b6d4){logger[_0x98f5('0x15')](_0x98f5('0x18'),_0x227cf3,_0x11b6d4);_0x26a0fc(_0x11b6d4);});});}exports['CreateMailMessage']=function(_0xf88f34){var _0x5500a2=this;return new Promise(function(_0xd1209d,_0x191f23){return db['MailMessage'][_0x98f5('0x1b')](_0xf88f34[_0x98f5('0x1c')],{'raw':_0xf88f34[_0x98f5('0x1d')]?_0xf88f34[_0x98f5('0x1d')][_0x98f5('0x1e')]===undefined?!![]:![]:!![]})[_0x98f5('0x1f')](function(_0x38b46d){logger['info'](_0x98f5('0x20'),_0xf88f34);logger['debug'](_0x98f5('0x20'),_0xf88f34,JSON['stringify'](_0x38b46d));_0xd1209d(_0x38b46d);})[_0x98f5('0x1a')](function(_0x40c69b){logger[_0x98f5('0x15')](_0x98f5('0x20'),_0x40c69b[_0x98f5('0x17')],_0xf88f34);_0x191f23(_0x5500a2[_0x98f5('0x15')](0x1f4,_0x40c69b[_0x98f5('0x17')]));});});};