Built motion from commit da617fac.|2.6.6
[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 _0xcbca=['message','SmsMessage,\x20%s,\x20%s','info','catch','CreateSmsMessage','SmsMessage','create','body','options','raw','lodash','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./smsMessage.socket','register','request','then','debug','request\x20sent','stringify','error','code'];(function(_0x1cd6a7,_0x3de156){var _0x1033e4=function(_0x3798e2){while(--_0x3798e2){_0x1cd6a7['push'](_0x1cd6a7['shift']());}};_0x1033e4(++_0x3de156);}(_0xcbca,0x96));var _0xacbc=function(_0x256ffb,_0x103b45){_0x256ffb=_0x256ffb-0x0;var _0x2ab707=_0xcbca[_0x256ffb];return _0x2ab707;};'use strict';var _=require(_0xacbc('0x0'));var util=require(_0xacbc('0x1'));var moment=require(_0xacbc('0x2'));var BPromise=require(_0xacbc('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xacbc('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xacbc('0x5'));var logger=require(_0xacbc('0x6'))(_0xacbc('0x7'));var config=require(_0xacbc('0x8'));var jayson=require(_0xacbc('0x9'));var client=jayson[_0xacbc('0xa')][_0xacbc('0xb')]({'port':0x232a});config[_0xacbc('0xc')]=_[_0xacbc('0xd')](config[_0xacbc('0xc')],{'host':_0xacbc('0xe'),'port':0x18eb});var socket=require(_0xacbc('0xf'))(new Redis(config[_0xacbc('0xc')]));require(_0xacbc('0x10'))[_0xacbc('0x11')](socket);function respondWithRpcPromise(_0x2cc127,_0x60e5fc,_0x181793){return new BPromise(function(_0x2b5343,_0x35c218){return client[_0xacbc('0x12')](_0x2cc127,_0x181793)[_0xacbc('0x13')](function(_0x24ff1f){logger['info']('SmsMessage,\x20%s,\x20%s',_0x60e5fc,'request\x20sent');logger[_0xacbc('0x14')]('SmsMessage,\x20%s,\x20%s,\x20%s',_0x60e5fc,_0xacbc('0x15'),JSON[_0xacbc('0x16')](_0x24ff1f));if(_0x24ff1f['error']){if(_0x24ff1f[_0xacbc('0x17')][_0xacbc('0x18')]===0x1f4){logger[_0xacbc('0x17')]('SmsMessage,\x20%s,\x20%s',_0x60e5fc,_0x24ff1f[_0xacbc('0x17')][_0xacbc('0x19')]);return _0x35c218(_0x24ff1f[_0xacbc('0x17')][_0xacbc('0x19')]);}logger[_0xacbc('0x17')](_0xacbc('0x1a'),_0x60e5fc,_0x24ff1f[_0xacbc('0x17')][_0xacbc('0x19')]);return _0x2b5343(_0x24ff1f[_0xacbc('0x17')][_0xacbc('0x19')]);}else{logger[_0xacbc('0x1b')](_0xacbc('0x1a'),_0x60e5fc,_0xacbc('0x15'));_0x2b5343(_0x24ff1f['result'][_0xacbc('0x19')]);}})[_0xacbc('0x1c')](function(_0x2d1c79){logger[_0xacbc('0x17')](_0xacbc('0x1a'),_0x60e5fc,_0x2d1c79);_0x35c218(_0x2d1c79);});});}exports[_0xacbc('0x1d')]=function(_0x29decc){var _0x43f0d0=this;return new Promise(function(_0xfc0ab7,_0x151f35){return db[_0xacbc('0x1e')][_0xacbc('0x1f')](_0x29decc[_0xacbc('0x20')],{'raw':_0x29decc[_0xacbc('0x21')]?_0x29decc['options'][_0xacbc('0x22')]===undefined?!![]:![]:!![]})[_0xacbc('0x13')](function(_0x20d2a9){logger[_0xacbc('0x1b')](_0xacbc('0x1d'),_0x29decc);logger[_0xacbc('0x14')]('CreateSmsMessage',_0x29decc,JSON[_0xacbc('0x16')](_0x20d2a9));_0xfc0ab7(_0x20d2a9);})[_0xacbc('0x1c')](function(_0x17e23a){logger[_0xacbc('0x17')]('CreateSmsMessage',_0x17e23a[_0xacbc('0x19')],_0x29decc);_0x151f35(_0x43f0d0[_0xacbc('0x17')](0x1f4,_0x17e23a['message']));});});};