Built motion from commit (unavailable).|2.5.14
[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 _0xc7bf=['redis','defaults','localhost','socket.io-emitter','register','request','then','debug','SmsMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','SmsMessage,\x20%s,\x20%s','message','result','catch','CreateSmsMessage','SmsMessage','options','info','util','moment','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x5337fa,_0x435f92){var _0x43e388=function(_0x3e26e3){while(--_0x3e26e3){_0x5337fa['push'](_0x5337fa['shift']());}};_0x43e388(++_0x435f92);}(_0xc7bf,0x8c));var _0xfc7b=function(_0x1e5fbd,_0x2e3998){_0x1e5fbd=_0x1e5fbd-0x0;var _0x153ca4=_0xc7bf[_0x1e5fbd];return _0x153ca4;};'use strict';var _=require('lodash');var util=require(_0xfc7b('0x0'));var moment=require(_0xfc7b('0x1'));var BPromise=require(_0xfc7b('0x2'));var rs=require(_0xfc7b('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xfc7b('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xfc7b('0x5'));var config=require(_0xfc7b('0x6'));var jayson=require(_0xfc7b('0x7'));var client=jayson[_0xfc7b('0x8')][_0xfc7b('0x9')]({'port':0x232a});config[_0xfc7b('0xa')]=_[_0xfc7b('0xb')](config[_0xfc7b('0xa')],{'host':_0xfc7b('0xc'),'port':0x18eb});var socket=require(_0xfc7b('0xd'))(new Redis(config[_0xfc7b('0xa')]));require('./smsMessage.socket')[_0xfc7b('0xe')](socket);function respondWithRpcPromise(_0x353e2c,_0x54e3cd,_0x346b9f){return new BPromise(function(_0x5a5efc,_0x288f71){return client[_0xfc7b('0xf')](_0x353e2c,_0x346b9f)[_0xfc7b('0x10')](function(_0x14d2a1){logger['info']('SmsMessage,\x20%s,\x20%s',_0x54e3cd,'request\x20sent');logger[_0xfc7b('0x11')](_0xfc7b('0x12'),_0x54e3cd,_0xfc7b('0x13'),JSON[_0xfc7b('0x14')](_0x14d2a1));if(_0x14d2a1[_0xfc7b('0x15')]){if(_0x14d2a1[_0xfc7b('0x15')]['code']===0x1f4){logger['error'](_0xfc7b('0x16'),_0x54e3cd,_0x14d2a1[_0xfc7b('0x15')][_0xfc7b('0x17')]);return _0x288f71(_0x14d2a1[_0xfc7b('0x15')]['message']);}logger['error'](_0xfc7b('0x16'),_0x54e3cd,_0x14d2a1[_0xfc7b('0x15')][_0xfc7b('0x17')]);return _0x5a5efc(_0x14d2a1['error'][_0xfc7b('0x17')]);}else{logger['info']('SmsMessage,\x20%s,\x20%s',_0x54e3cd,_0xfc7b('0x13'));_0x5a5efc(_0x14d2a1[_0xfc7b('0x18')][_0xfc7b('0x17')]);}})[_0xfc7b('0x19')](function(_0x482a50){logger[_0xfc7b('0x15')]('SmsMessage,\x20%s,\x20%s',_0x54e3cd,_0x482a50);_0x288f71(_0x482a50);});});}exports[_0xfc7b('0x1a')]=function(_0x43a1b6){var _0x5bfa8c=this;return new Promise(function(_0x263426,_0x504212){return db[_0xfc7b('0x1b')]['create'](_0x43a1b6['body'],{'raw':_0x43a1b6[_0xfc7b('0x1c')]?_0x43a1b6[_0xfc7b('0x1c')]['raw']===undefined?!![]:![]:!![]})[_0xfc7b('0x10')](function(_0x142238){logger[_0xfc7b('0x1d')](_0xfc7b('0x1a'),_0x43a1b6);logger[_0xfc7b('0x11')](_0xfc7b('0x1a'),_0x43a1b6,JSON[_0xfc7b('0x14')](_0x142238));_0x263426(_0x142238);})[_0xfc7b('0x19')](function(_0x101740){logger[_0xfc7b('0x15')](_0xfc7b('0x1a'),_0x101740[_0xfc7b('0x17')],_0x43a1b6);_0x504212(_0x5bfa8c[_0xfc7b('0x15')](0x1f4,_0x101740[_0xfc7b('0x17')]));});});};