e2b0b872d9e8d38575c3c141d2573847607a9423
[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 _0x7ac3=['SmsMessage,\x20%s,\x20%s','SmsMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','CreateSmsMessage','create','body','options','raw','debug','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','./smsMessage.socket','register','request','then','info'];(function(_0x1041b9,_0x560a66){var _0x509972=function(_0x4c6ca4){while(--_0x4c6ca4){_0x1041b9['push'](_0x1041b9['shift']());}};_0x509972(++_0x560a66);}(_0x7ac3,0x185));var _0x37ac=function(_0xbf370a,_0x4a936c){_0xbf370a=_0xbf370a-0x0;var _0x371b0b=_0x7ac3[_0xbf370a];return _0x371b0b;};'use strict';var _=require('lodash');var util=require(_0x37ac('0x0'));var moment=require(_0x37ac('0x1'));var BPromise=require(_0x37ac('0x2'));var rs=require(_0x37ac('0x3'));var fs=require('fs');var Redis=require(_0x37ac('0x4'));var db=require(_0x37ac('0x5'))['db'];var utils=require(_0x37ac('0x6'));var logger=require('../../config/logger')(_0x37ac('0x7'));var config=require(_0x37ac('0x8'));var jayson=require(_0x37ac('0x9'));var client=jayson[_0x37ac('0xa')][_0x37ac('0xb')]({'port':0x232a});config[_0x37ac('0xc')]=_[_0x37ac('0xd')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x37ac('0xe'))[_0x37ac('0xf')](socket);function respondWithRpcPromise(_0x55ac50,_0x5b9d45,_0x48a72c){return new BPromise(function(_0x161d40,_0x218cb4){return client[_0x37ac('0x10')](_0x55ac50,_0x48a72c)[_0x37ac('0x11')](function(_0x5b00af){logger[_0x37ac('0x12')](_0x37ac('0x13'),_0x5b9d45,'request\x20sent');logger['debug'](_0x37ac('0x14'),_0x5b9d45,_0x37ac('0x15'),JSON[_0x37ac('0x16')](_0x5b00af));if(_0x5b00af[_0x37ac('0x17')]){if(_0x5b00af[_0x37ac('0x17')][_0x37ac('0x18')]===0x1f4){logger[_0x37ac('0x17')](_0x37ac('0x13'),_0x5b9d45,_0x5b00af[_0x37ac('0x17')]['message']);return _0x218cb4(_0x5b00af[_0x37ac('0x17')][_0x37ac('0x19')]);}logger[_0x37ac('0x17')](_0x37ac('0x13'),_0x5b9d45,_0x5b00af[_0x37ac('0x17')][_0x37ac('0x19')]);return _0x161d40(_0x5b00af[_0x37ac('0x17')][_0x37ac('0x19')]);}else{logger['info'](_0x37ac('0x13'),_0x5b9d45,_0x37ac('0x15'));_0x161d40(_0x5b00af[_0x37ac('0x1a')][_0x37ac('0x19')]);}})[_0x37ac('0x1b')](function(_0x35e496){logger[_0x37ac('0x17')](_0x37ac('0x13'),_0x5b9d45,_0x35e496);_0x218cb4(_0x35e496);});});}exports[_0x37ac('0x1c')]=function(_0x263528){var _0x5b3f69=this;return new Promise(function(_0x31d74f,_0x32daab){return db['SmsMessage'][_0x37ac('0x1d')](_0x263528[_0x37ac('0x1e')],{'raw':_0x263528['options']?_0x263528[_0x37ac('0x1f')][_0x37ac('0x20')]===undefined?!![]:![]:!![]})[_0x37ac('0x11')](function(_0x3d6f80){logger[_0x37ac('0x12')](_0x37ac('0x1c'),_0x263528);logger[_0x37ac('0x21')](_0x37ac('0x1c'),_0x263528,JSON[_0x37ac('0x16')](_0x3d6f80));_0x31d74f(_0x3d6f80);})[_0x37ac('0x1b')](function(_0x177d6){logger[_0x37ac('0x17')]('CreateSmsMessage',_0x177d6[_0x37ac('0x19')],_0x263528);_0x32daab(_0x5b3f69[_0x37ac('0x17')](0x1f4,_0x177d6['message']));});});};