Built motion from commit 43538d75.|2.5.35
[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 _0x580a=['../../config/utils','../../config/logger','client','redis','defaults','localhost','socket.io-emitter','register','then','info','SmsMessage,\x20%s,\x20%s','request\x20sent','SmsMessage,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateSmsMessage','SmsMessage','body','options','raw','debug','stringify','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x82129b,_0x484ae9){var _0x2ae5dc=function(_0x299e34){while(--_0x299e34){_0x82129b['push'](_0x82129b['shift']());}};_0x2ae5dc(++_0x484ae9);}(_0x580a,0xd3));var _0xa580=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x580a[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0xa580('0x0'));var util=require('util');var moment=require(_0xa580('0x1'));var BPromise=require(_0xa580('0x2'));var rs=require(_0xa580('0x3'));var fs=require('fs');var Redis=require(_0xa580('0x4'));var db=require(_0xa580('0x5'))['db'];var utils=require(_0xa580('0x6'));var logger=require(_0xa580('0x7'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xa580('0x8')]['http']({'port':0x232a});config[_0xa580('0x9')]=_[_0xa580('0xa')](config['redis'],{'host':_0xa580('0xb'),'port':0x18eb});var socket=require(_0xa580('0xc'))(new Redis(config['redis']));require('./smsMessage.socket')[_0xa580('0xd')](socket);function respondWithRpcPromise(_0x31a069,_0x21d8f1,_0x3bd32e){return new BPromise(function(_0x3424ad,_0x2bbffa){return client['request'](_0x31a069,_0x3bd32e)[_0xa580('0xe')](function(_0x533506){logger[_0xa580('0xf')](_0xa580('0x10'),_0x21d8f1,_0xa580('0x11'));logger['debug'](_0xa580('0x12'),_0x21d8f1,'request\x20sent',JSON['stringify'](_0x533506));if(_0x533506[_0xa580('0x13')]){if(_0x533506[_0xa580('0x13')][_0xa580('0x14')]===0x1f4){logger[_0xa580('0x13')](_0xa580('0x10'),_0x21d8f1,_0x533506['error'][_0xa580('0x15')]);return _0x2bbffa(_0x533506[_0xa580('0x13')][_0xa580('0x15')]);}logger[_0xa580('0x13')](_0xa580('0x10'),_0x21d8f1,_0x533506['error'][_0xa580('0x15')]);return _0x3424ad(_0x533506[_0xa580('0x13')][_0xa580('0x15')]);}else{logger['info'](_0xa580('0x10'),_0x21d8f1,_0xa580('0x11'));_0x3424ad(_0x533506[_0xa580('0x16')][_0xa580('0x15')]);}})[_0xa580('0x17')](function(_0x17590c){logger[_0xa580('0x13')](_0xa580('0x10'),_0x21d8f1,_0x17590c);_0x2bbffa(_0x17590c);});});}exports[_0xa580('0x18')]=function(_0x3275ff){var _0xd07659=this;return new Promise(function(_0x3fadac,_0x6a2997){return db[_0xa580('0x19')]['create'](_0x3275ff[_0xa580('0x1a')],{'raw':_0x3275ff['options']?_0x3275ff[_0xa580('0x1b')][_0xa580('0x1c')]===undefined?!![]:![]:!![]})['then'](function(_0x207006){logger[_0xa580('0xf')](_0xa580('0x18'),_0x3275ff);logger[_0xa580('0x1d')](_0xa580('0x18'),_0x3275ff,JSON[_0xa580('0x1e')](_0x207006));_0x3fadac(_0x207006);})[_0xa580('0x17')](function(_0x4d03c1){logger[_0xa580('0x13')]('CreateSmsMessage',_0x4d03c1[_0xa580('0x15')],_0x3275ff);_0x6a2997(_0xd07659[_0xa580('0x13')](0x1f4,_0x4d03c1[_0xa580('0x15')]));});});};