0307e250b7546d39e3df074039810df2e5e9a04c
[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 _0x9f66=['request','then','info','SmsMessage,\x20%s,\x20%s','request\x20sent','debug','SmsMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','CreateSmsMessage','SmsMessage','create','body','options','raw','lodash','moment','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','defaults','redis','register'];(function(_0x1050f2,_0x5d7a5f){var _0x9d3d54=function(_0xdc5bcc){while(--_0xdc5bcc){_0x1050f2['push'](_0x1050f2['shift']());}};_0x9d3d54(++_0x5d7a5f);}(_0x9f66,0xa8));var _0x69f6=function(_0x2feed3,_0x26dbe9){_0x2feed3=_0x2feed3-0x0;var _0xa0e7e0=_0x9f66[_0x2feed3];return _0xa0e7e0;};'use strict';var _=require(_0x69f6('0x0'));var util=require('util');var moment=require(_0x69f6('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x69f6('0x2'));var db=require(_0x69f6('0x3'))['db'];var utils=require(_0x69f6('0x4'));var logger=require('../../config/logger')(_0x69f6('0x5'));var config=require(_0x69f6('0x6'));var jayson=require(_0x69f6('0x7'));var client=jayson['client'][_0x69f6('0x8')]({'port':0x232a});config['redis']=_[_0x69f6('0x9')](config[_0x69f6('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./smsMessage.socket')[_0x69f6('0xb')](socket);function respondWithRpcPromise(_0x5bc2c7,_0x299efc,_0x24286f){return new BPromise(function(_0xb4c936,_0x3fcd59){return client[_0x69f6('0xc')](_0x5bc2c7,_0x24286f)[_0x69f6('0xd')](function(_0x4e7e14){logger[_0x69f6('0xe')](_0x69f6('0xf'),_0x299efc,_0x69f6('0x10'));logger[_0x69f6('0x11')](_0x69f6('0x12'),_0x299efc,_0x69f6('0x10'),JSON[_0x69f6('0x13')](_0x4e7e14));if(_0x4e7e14[_0x69f6('0x14')]){if(_0x4e7e14[_0x69f6('0x14')][_0x69f6('0x15')]===0x1f4){logger['error'](_0x69f6('0xf'),_0x299efc,_0x4e7e14['error'][_0x69f6('0x16')]);return _0x3fcd59(_0x4e7e14[_0x69f6('0x14')]['message']);}logger['error'](_0x69f6('0xf'),_0x299efc,_0x4e7e14[_0x69f6('0x14')]['message']);return _0xb4c936(_0x4e7e14[_0x69f6('0x14')]['message']);}else{logger['info'](_0x69f6('0xf'),_0x299efc,_0x69f6('0x10'));_0xb4c936(_0x4e7e14['result']['message']);}})[_0x69f6('0x17')](function(_0x321d45){logger[_0x69f6('0x14')](_0x69f6('0xf'),_0x299efc,_0x321d45);_0x3fcd59(_0x321d45);});});}exports[_0x69f6('0x18')]=function(_0x118fd5){var _0x5705fe=this;return new Promise(function(_0x40d595,_0x51baad){return db[_0x69f6('0x19')][_0x69f6('0x1a')](_0x118fd5[_0x69f6('0x1b')],{'raw':_0x118fd5[_0x69f6('0x1c')]?_0x118fd5[_0x69f6('0x1c')][_0x69f6('0x1d')]===undefined?!![]:![]:!![]})[_0x69f6('0xd')](function(_0x1ad724){logger[_0x69f6('0xe')](_0x69f6('0x18'),_0x118fd5);logger[_0x69f6('0x11')](_0x69f6('0x18'),_0x118fd5,JSON[_0x69f6('0x13')](_0x1ad724));_0x40d595(_0x1ad724);})['catch'](function(_0x2a1f94){logger[_0x69f6('0x14')](_0x69f6('0x18'),_0x2a1f94['message'],_0x118fd5);_0x51baad(_0x5705fe[_0x69f6('0x14')](0x1f4,_0x2a1f94[_0x69f6('0x16')]));});});};