Built motion from commit 1fa89557.|2.6.10
[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 _0x236c=['http','defaults','redis','./mailMessage.socket','then','MailMessage,\x20%s,\x20%s','request\x20sent','MailMessage,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateMailMessage','MailMessage','create','body','options','info','debug','stringify','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client'];(function(_0x3b7a0c,_0xf1a4c2){var _0x3bb70f=function(_0x248b52){while(--_0x248b52){_0x3b7a0c['push'](_0x3b7a0c['shift']());}};_0x3bb70f(++_0xf1a4c2);}(_0x236c,0x155));var _0xc236=function(_0x9568e,_0x3c5527){_0x9568e=_0x9568e-0x0;var _0x14e42c=_0x236c[_0x9568e];return _0x14e42c;};'use strict';var _=require(_0xc236('0x0'));var util=require('util');var moment=require(_0xc236('0x1'));var BPromise=require(_0xc236('0x2'));var rs=require(_0xc236('0x3'));var fs=require('fs');var Redis=require(_0xc236('0x4'));var db=require(_0xc236('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xc236('0x6'))(_0xc236('0x7'));var config=require(_0xc236('0x8'));var jayson=require(_0xc236('0x9'));var client=jayson[_0xc236('0xa')][_0xc236('0xb')]({'port':0x232a});config['redis']=_[_0xc236('0xc')](config[_0xc236('0xd')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xc236('0xe'))['register'](socket);function respondWithRpcPromise(_0x30a28d,_0x381ed1,_0x18f33b){return new BPromise(function(_0x2f8b72,_0xaf651b){return client['request'](_0x30a28d,_0x18f33b)[_0xc236('0xf')](function(_0x3311f7){logger['info'](_0xc236('0x10'),_0x381ed1,_0xc236('0x11'));logger['debug'](_0xc236('0x12'),_0x381ed1,'request\x20sent',JSON['stringify'](_0x3311f7));if(_0x3311f7[_0xc236('0x13')]){if(_0x3311f7[_0xc236('0x13')][_0xc236('0x14')]===0x1f4){logger[_0xc236('0x13')]('MailMessage,\x20%s,\x20%s',_0x381ed1,_0x3311f7[_0xc236('0x13')]['message']);return _0xaf651b(_0x3311f7['error'][_0xc236('0x15')]);}logger[_0xc236('0x13')](_0xc236('0x10'),_0x381ed1,_0x3311f7[_0xc236('0x13')][_0xc236('0x15')]);return _0x2f8b72(_0x3311f7['error']['message']);}else{logger['info'](_0xc236('0x10'),_0x381ed1,_0xc236('0x11'));_0x2f8b72(_0x3311f7[_0xc236('0x16')]['message']);}})[_0xc236('0x17')](function(_0x506974){logger['error'](_0xc236('0x10'),_0x381ed1,_0x506974);_0xaf651b(_0x506974);});});}exports[_0xc236('0x18')]=function(_0x3a6183){var _0x46bc69=this;return new Promise(function(_0x2b6d3f,_0x27c6ab){return db[_0xc236('0x19')][_0xc236('0x1a')](_0x3a6183[_0xc236('0x1b')],{'raw':_0x3a6183[_0xc236('0x1c')]?_0x3a6183[_0xc236('0x1c')]['raw']===undefined?!![]:![]:!![]})[_0xc236('0xf')](function(_0x34d73a){logger[_0xc236('0x1d')](_0xc236('0x18'),_0x3a6183);logger[_0xc236('0x1e')](_0xc236('0x18'),_0x3a6183,JSON[_0xc236('0x1f')](_0x34d73a));_0x2b6d3f(_0x34d73a);})[_0xc236('0x17')](function(_0x1d65e2){logger[_0xc236('0x13')](_0xc236('0x18'),_0x1d65e2['message'],_0x3a6183);_0x27c6ab(_0x46bc69[_0xc236('0x13')](0x1f4,_0x1d65e2[_0xc236('0x15')]));});});};