Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / smsMessage / smsMessage.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 _0x68f7=['register','then','info','request\x20sent','debug','stringify','error','code','SmsMessage,\x20%s,\x20%s','message','result','catch','CreateSmsMessage','SmsMessage','create','body','options','raw','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter'];(function(_0x129f62,_0x1cdf67){var _0x2ea030=function(_0x2a3ae){while(--_0x2a3ae){_0x129f62['push'](_0x129f62['shift']());}};_0x2ea030(++_0x1cdf67);}(_0x68f7,0x1a5));var _0x768f=function(_0x53be2f,_0x2b041e){_0x53be2f=_0x53be2f-0x0;var _0x225286=_0x68f7[_0x53be2f];return _0x225286;};'use strict';var _=require('lodash');var util=require(_0x768f('0x0'));var moment=require('moment');var BPromise=require(_0x768f('0x1'));var rs=require(_0x768f('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x768f('0x3'))['db'];var utils=require(_0x768f('0x4'));var logger=require(_0x768f('0x5'))('rpc');var config=require(_0x768f('0x6'));var jayson=require(_0x768f('0x7'));var client=jayson[_0x768f('0x8')]['http']({'port':0x232a});config[_0x768f('0x9')]=_[_0x768f('0xa')](config['redis'],{'host':_0x768f('0xb'),'port':0x18eb});var socket=require(_0x768f('0xc'))(new Redis(config[_0x768f('0x9')]));require('./smsMessage.socket')[_0x768f('0xd')](socket);function respondWithRpcPromise(_0x59aa57,_0x2b1200,_0xa319a1){return new BPromise(function(_0x2fa08b,_0x288a02){return client['request'](_0x59aa57,_0xa319a1)[_0x768f('0xe')](function(_0x2bfc49){logger[_0x768f('0xf')]('SmsMessage,\x20%s,\x20%s',_0x2b1200,_0x768f('0x10'));logger[_0x768f('0x11')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x2b1200,_0x768f('0x10'),JSON[_0x768f('0x12')](_0x2bfc49));if(_0x2bfc49['error']){if(_0x2bfc49[_0x768f('0x13')][_0x768f('0x14')]===0x1f4){logger[_0x768f('0x13')](_0x768f('0x15'),_0x2b1200,_0x2bfc49[_0x768f('0x13')][_0x768f('0x16')]);return _0x288a02(_0x2bfc49[_0x768f('0x13')][_0x768f('0x16')]);}logger[_0x768f('0x13')](_0x768f('0x15'),_0x2b1200,_0x2bfc49['error'][_0x768f('0x16')]);return _0x2fa08b(_0x2bfc49['error'][_0x768f('0x16')]);}else{logger[_0x768f('0xf')](_0x768f('0x15'),_0x2b1200,_0x768f('0x10'));_0x2fa08b(_0x2bfc49[_0x768f('0x17')][_0x768f('0x16')]);}})[_0x768f('0x18')](function(_0x764754){logger['error']('SmsMessage,\x20%s,\x20%s',_0x2b1200,_0x764754);_0x288a02(_0x764754);});});}exports[_0x768f('0x19')]=function(_0x33ef14){var _0x1a3a8d=this;return new Promise(function(_0x2c3043,_0x3f3523){return db[_0x768f('0x1a')][_0x768f('0x1b')](_0x33ef14[_0x768f('0x1c')],{'raw':_0x33ef14[_0x768f('0x1d')]?_0x33ef14[_0x768f('0x1d')][_0x768f('0x1e')]===undefined?!![]:![]:!![]})[_0x768f('0xe')](function(_0x380cfc){logger[_0x768f('0xf')](_0x768f('0x19'),_0x33ef14);logger['debug']('CreateSmsMessage',_0x33ef14,JSON[_0x768f('0x12')](_0x380cfc));_0x2c3043(_0x380cfc);})['catch'](function(_0x2a7171){logger[_0x768f('0x13')](_0x768f('0x19'),_0x2a7171[_0x768f('0x16')],_0x33ef14);_0x3f3523(_0x1a3a8d['error'](0x1f4,_0x2a7171[_0x768f('0x16')]));});});};