611793bc1bd32685d9eddeaf0795e7bf6172a2b6
[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 _0xf6c9=['ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','./smsMessage.socket','register','request','then','info','SmsMessage,\x20%s,\x20%s','request\x20sent','debug','SmsMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','SmsMessage','create','body','options','raw','CreateSmsMessage','lodash','util','moment','randomstring'];(function(_0x5dac60,_0x2a3533){var _0x4ffd5c=function(_0x101189){while(--_0x101189){_0x5dac60['push'](_0x5dac60['shift']());}};_0x4ffd5c(++_0x2a3533);}(_0xf6c9,0x12e));var _0x9f6c=function(_0x11dc1e,_0x15ab16){_0x11dc1e=_0x11dc1e-0x0;var _0x2132fc=_0xf6c9[_0x11dc1e];return _0x2132fc;};'use strict';var _=require(_0x9f6c('0x0'));var util=require(_0x9f6c('0x1'));var moment=require(_0x9f6c('0x2'));var BPromise=require('bluebird');var rs=require(_0x9f6c('0x3'));var fs=require('fs');var Redis=require(_0x9f6c('0x4'));var db=require(_0x9f6c('0x5'))['db'];var utils=require(_0x9f6c('0x6'));var logger=require('../../config/logger')(_0x9f6c('0x7'));var config=require(_0x9f6c('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x9f6c('0x9')]['http']({'port':0x232a});config[_0x9f6c('0xa')]=_[_0x9f6c('0xb')](config['redis'],{'host':_0x9f6c('0xc'),'port':0x18eb});var socket=require(_0x9f6c('0xd'))(new Redis(config[_0x9f6c('0xa')]));require(_0x9f6c('0xe'))[_0x9f6c('0xf')](socket);function respondWithRpcPromise(_0x504d04,_0x18bb65,_0x56ada5){return new BPromise(function(_0x13797d,_0x475802){return client[_0x9f6c('0x10')](_0x504d04,_0x56ada5)[_0x9f6c('0x11')](function(_0x3d5f43){logger[_0x9f6c('0x12')](_0x9f6c('0x13'),_0x18bb65,_0x9f6c('0x14'));logger[_0x9f6c('0x15')](_0x9f6c('0x16'),_0x18bb65,_0x9f6c('0x14'),JSON[_0x9f6c('0x17')](_0x3d5f43));if(_0x3d5f43[_0x9f6c('0x18')]){if(_0x3d5f43[_0x9f6c('0x18')][_0x9f6c('0x19')]===0x1f4){logger[_0x9f6c('0x18')](_0x9f6c('0x13'),_0x18bb65,_0x3d5f43[_0x9f6c('0x18')][_0x9f6c('0x1a')]);return _0x475802(_0x3d5f43[_0x9f6c('0x18')][_0x9f6c('0x1a')]);}logger['error']('SmsMessage,\x20%s,\x20%s',_0x18bb65,_0x3d5f43[_0x9f6c('0x18')][_0x9f6c('0x1a')]);return _0x13797d(_0x3d5f43[_0x9f6c('0x18')]['message']);}else{logger[_0x9f6c('0x12')]('SmsMessage,\x20%s,\x20%s',_0x18bb65,_0x9f6c('0x14'));_0x13797d(_0x3d5f43['result'][_0x9f6c('0x1a')]);}})[_0x9f6c('0x1b')](function(_0xe407fc){logger[_0x9f6c('0x18')](_0x9f6c('0x13'),_0x18bb65,_0xe407fc);_0x475802(_0xe407fc);});});}exports['CreateSmsMessage']=function(_0x5387ef){var _0x1198ed=this;return new Promise(function(_0x3d21b6,_0x5767b4){return db[_0x9f6c('0x1c')][_0x9f6c('0x1d')](_0x5387ef[_0x9f6c('0x1e')],{'raw':_0x5387ef[_0x9f6c('0x1f')]?_0x5387ef[_0x9f6c('0x1f')][_0x9f6c('0x20')]===undefined?!![]:![]:!![]})[_0x9f6c('0x11')](function(_0x157da0){logger[_0x9f6c('0x12')](_0x9f6c('0x21'),_0x5387ef);logger[_0x9f6c('0x15')]('CreateSmsMessage',_0x5387ef,JSON[_0x9f6c('0x17')](_0x157da0));_0x3d21b6(_0x157da0);})[_0x9f6c('0x1b')](function(_0x412f36){logger['error'](_0x9f6c('0x21'),_0x412f36['message'],_0x5387ef);_0x5767b4(_0x1198ed[_0x9f6c('0x18')](0x1f4,_0x412f36[_0x9f6c('0x1a')]));});});};