c0e2a79fb8321a10fe5ce75263672d7651dd502d
[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 _0xc3fa=['http','redis','defaults','localhost','socket.io-emitter','request','info','SmsMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','catch','CreateSmsMessage','SmsMessage','options','raw','then','lodash','util','bluebird','randomstring','ioredis','../../config/utils','rpc','jayson/promise'];(function(_0x6be7b7,_0x23c9eb){var _0x217e2d=function(_0x4e79e3){while(--_0x4e79e3){_0x6be7b7['push'](_0x6be7b7['shift']());}};_0x217e2d(++_0x23c9eb);}(_0xc3fa,0xeb));var _0xac3f=function(_0x2bddf9,_0x22c873){_0x2bddf9=_0x2bddf9-0x0;var _0x3f3ae9=_0xc3fa[_0x2bddf9];return _0x3f3ae9;};'use strict';var _=require(_0xac3f('0x0'));var util=require(_0xac3f('0x1'));var moment=require('moment');var BPromise=require(_0xac3f('0x2'));var rs=require(_0xac3f('0x3'));var fs=require('fs');var Redis=require(_0xac3f('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xac3f('0x5'));var logger=require('../../config/logger')(_0xac3f('0x6'));var config=require('../../config/environment');var jayson=require(_0xac3f('0x7'));var client=jayson['client'][_0xac3f('0x8')]({'port':0x232a});config[_0xac3f('0x9')]=_[_0xac3f('0xa')](config['redis'],{'host':_0xac3f('0xb'),'port':0x18eb});var socket=require(_0xac3f('0xc'))(new Redis(config['redis']));require('./smsMessage.socket')['register'](socket);function respondWithRpcPromise(_0xfc35d5,_0x456f57,_0x44875a){return new BPromise(function(_0x223189,_0x233b0b){return client[_0xac3f('0xd')](_0xfc35d5,_0x44875a)['then'](function(_0x531f06){logger[_0xac3f('0xe')](_0xac3f('0xf'),_0x456f57,_0xac3f('0x10'));logger[_0xac3f('0x11')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x456f57,_0xac3f('0x10'),JSON[_0xac3f('0x12')](_0x531f06));if(_0x531f06[_0xac3f('0x13')]){if(_0x531f06[_0xac3f('0x13')]['code']===0x1f4){logger['error']('SmsMessage,\x20%s,\x20%s',_0x456f57,_0x531f06[_0xac3f('0x13')][_0xac3f('0x14')]);return _0x233b0b(_0x531f06['error'][_0xac3f('0x14')]);}logger[_0xac3f('0x13')](_0xac3f('0xf'),_0x456f57,_0x531f06[_0xac3f('0x13')][_0xac3f('0x14')]);return _0x223189(_0x531f06[_0xac3f('0x13')][_0xac3f('0x14')]);}else{logger[_0xac3f('0xe')](_0xac3f('0xf'),_0x456f57,_0xac3f('0x10'));_0x223189(_0x531f06['result'][_0xac3f('0x14')]);}})[_0xac3f('0x15')](function(_0x3aba39){logger['error'](_0xac3f('0xf'),_0x456f57,_0x3aba39);_0x233b0b(_0x3aba39);});});}exports[_0xac3f('0x16')]=function(_0x2e775e){var _0x4b3ce4=this;return new Promise(function(_0x346a96,_0x4fa88c){return db[_0xac3f('0x17')]['create'](_0x2e775e['body'],{'raw':_0x2e775e[_0xac3f('0x18')]?_0x2e775e[_0xac3f('0x18')][_0xac3f('0x19')]===undefined?!![]:![]:!![]})[_0xac3f('0x1a')](function(_0x26fbdf){logger[_0xac3f('0xe')](_0xac3f('0x16'),_0x2e775e);logger[_0xac3f('0x11')](_0xac3f('0x16'),_0x2e775e,JSON[_0xac3f('0x12')](_0x26fbdf));_0x346a96(_0x26fbdf);})[_0xac3f('0x15')](function(_0x3f8f6d){logger[_0xac3f('0x13')](_0xac3f('0x16'),_0x3f8f6d[_0xac3f('0x14')],_0x2e775e);_0x4fa88c(_0x4b3ce4[_0xac3f('0x13')](0x1f4,_0x3f8f6d[_0xac3f('0x14')]));});});};