Built motion from commit (unavailable).|2.5.21
[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 _0x15a9=['code','message','result','catch','CreateMailMessage','body','options','raw','debug','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./mailMessage.socket','register','request','then','info','MailMessage,\x20%s,\x20%s','request\x20sent','MailMessage,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x5a1c70,_0x2375c5){var _0x12ba37=function(_0x4991c0){while(--_0x4991c0){_0x5a1c70['push'](_0x5a1c70['shift']());}};_0x12ba37(++_0x2375c5);}(_0x15a9,0x18a));var _0x915a=function(_0x16e52e,_0x2362dc){_0x16e52e=_0x16e52e-0x0;var _0x167a54=_0x15a9[_0x16e52e];return _0x167a54;};'use strict';var _=require(_0x915a('0x0'));var util=require(_0x915a('0x1'));var moment=require(_0x915a('0x2'));var BPromise=require(_0x915a('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x915a('0x4'));var db=require(_0x915a('0x5'))['db'];var utils=require(_0x915a('0x6'));var logger=require(_0x915a('0x7'))(_0x915a('0x8'));var config=require(_0x915a('0x9'));var jayson=require(_0x915a('0xa'));var client=jayson[_0x915a('0xb')][_0x915a('0xc')]({'port':0x232a});config[_0x915a('0xd')]=_[_0x915a('0xe')](config[_0x915a('0xd')],{'host':_0x915a('0xf'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x915a('0x10'))[_0x915a('0x11')](socket);function respondWithRpcPromise(_0x49c09,_0x1eda56,_0x17900d){return new BPromise(function(_0x1c7d0a,_0x4903ee){return client[_0x915a('0x12')](_0x49c09,_0x17900d)[_0x915a('0x13')](function(_0x2abc8c){logger[_0x915a('0x14')](_0x915a('0x15'),_0x1eda56,_0x915a('0x16'));logger['debug'](_0x915a('0x17'),_0x1eda56,'request\x20sent',JSON[_0x915a('0x18')](_0x2abc8c));if(_0x2abc8c[_0x915a('0x19')]){if(_0x2abc8c['error'][_0x915a('0x1a')]===0x1f4){logger[_0x915a('0x19')](_0x915a('0x15'),_0x1eda56,_0x2abc8c[_0x915a('0x19')]['message']);return _0x4903ee(_0x2abc8c['error'][_0x915a('0x1b')]);}logger['error'](_0x915a('0x15'),_0x1eda56,_0x2abc8c['error']['message']);return _0x1c7d0a(_0x2abc8c[_0x915a('0x19')][_0x915a('0x1b')]);}else{logger[_0x915a('0x14')](_0x915a('0x15'),_0x1eda56,_0x915a('0x16'));_0x1c7d0a(_0x2abc8c[_0x915a('0x1c')][_0x915a('0x1b')]);}})[_0x915a('0x1d')](function(_0x1ff4e6){logger['error'](_0x915a('0x15'),_0x1eda56,_0x1ff4e6);_0x4903ee(_0x1ff4e6);});});}exports[_0x915a('0x1e')]=function(_0x2f8843){var _0x313fb5=this;return new Promise(function(_0x5b9b18,_0x54132b){return db['MailMessage']['create'](_0x2f8843[_0x915a('0x1f')],{'raw':_0x2f8843[_0x915a('0x20')]?_0x2f8843['options'][_0x915a('0x21')]===undefined?!![]:![]:!![]})[_0x915a('0x13')](function(_0x3e3f49){logger[_0x915a('0x14')]('CreateMailMessage',_0x2f8843);logger[_0x915a('0x22')](_0x915a('0x1e'),_0x2f8843,JSON[_0x915a('0x18')](_0x3e3f49));_0x5b9b18(_0x3e3f49);})[_0x915a('0x1d')](function(_0xa13ce8){logger['error'](_0x915a('0x1e'),_0xa13ce8[_0x915a('0x1b')],_0x2f8843);_0x54132b(_0x313fb5[_0x915a('0x19')](0x1f4,_0xa13ce8[_0x915a('0x1b')]));});});};