Built motion from commit 0900f080.|2.5.45
[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 _0xb4f7=['../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./smsMessage.socket','register','then','info','SmsMessage,\x20%s,\x20%s','debug','SmsMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','catch','CreateSmsMessage','SmsMessage','create','body','options','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x5d2803,_0xf375bd){var _0xdcad2c=function(_0x3c3a98){while(--_0x3c3a98){_0x5d2803['push'](_0x5d2803['shift']());}};_0xdcad2c(++_0xf375bd);}(_0xb4f7,0xc8));var _0x7b4f=function(_0x3b85c7,_0x1c341c){_0x3b85c7=_0x3b85c7-0x0;var _0x137c8a=_0xb4f7[_0x3b85c7];return _0x137c8a;};'use strict';var _=require(_0x7b4f('0x0'));var util=require(_0x7b4f('0x1'));var moment=require(_0x7b4f('0x2'));var BPromise=require(_0x7b4f('0x3'));var rs=require(_0x7b4f('0x4'));var fs=require('fs');var Redis=require(_0x7b4f('0x5'));var db=require(_0x7b4f('0x6'))['db'];var utils=require(_0x7b4f('0x7'));var logger=require(_0x7b4f('0x8'))(_0x7b4f('0x9'));var config=require(_0x7b4f('0xa'));var jayson=require(_0x7b4f('0xb'));var client=jayson[_0x7b4f('0xc')][_0x7b4f('0xd')]({'port':0x232a});config[_0x7b4f('0xe')]=_[_0x7b4f('0xf')](config[_0x7b4f('0xe')],{'host':'localhost','port':0x18eb});var socket=require(_0x7b4f('0x10'))(new Redis(config[_0x7b4f('0xe')]));require(_0x7b4f('0x11'))[_0x7b4f('0x12')](socket);function respondWithRpcPromise(_0x5462ff,_0x3e27a3,_0x4a202b){return new BPromise(function(_0x239e2c,_0xc39404){return client['request'](_0x5462ff,_0x4a202b)[_0x7b4f('0x13')](function(_0x40f834){logger[_0x7b4f('0x14')](_0x7b4f('0x15'),_0x3e27a3,'request\x20sent');logger[_0x7b4f('0x16')](_0x7b4f('0x17'),_0x3e27a3,'request\x20sent',JSON[_0x7b4f('0x18')](_0x40f834));if(_0x40f834[_0x7b4f('0x19')]){if(_0x40f834[_0x7b4f('0x19')][_0x7b4f('0x1a')]===0x1f4){logger['error']('SmsMessage,\x20%s,\x20%s',_0x3e27a3,_0x40f834[_0x7b4f('0x19')][_0x7b4f('0x1b')]);return _0xc39404(_0x40f834[_0x7b4f('0x19')][_0x7b4f('0x1b')]);}logger[_0x7b4f('0x19')]('SmsMessage,\x20%s,\x20%s',_0x3e27a3,_0x40f834['error'][_0x7b4f('0x1b')]);return _0x239e2c(_0x40f834[_0x7b4f('0x19')]['message']);}else{logger[_0x7b4f('0x14')]('SmsMessage,\x20%s,\x20%s',_0x3e27a3,_0x7b4f('0x1c'));_0x239e2c(_0x40f834['result'][_0x7b4f('0x1b')]);}})[_0x7b4f('0x1d')](function(_0x137122){logger[_0x7b4f('0x19')](_0x7b4f('0x15'),_0x3e27a3,_0x137122);_0xc39404(_0x137122);});});}exports[_0x7b4f('0x1e')]=function(_0x4287c0){var _0x1c90e7=this;return new Promise(function(_0x216ed4,_0x242c49){return db[_0x7b4f('0x1f')][_0x7b4f('0x20')](_0x4287c0[_0x7b4f('0x21')],{'raw':_0x4287c0[_0x7b4f('0x22')]?_0x4287c0['options']['raw']===undefined?!![]:![]:!![]})['then'](function(_0x53488c){logger[_0x7b4f('0x14')]('CreateSmsMessage',_0x4287c0);logger[_0x7b4f('0x16')](_0x7b4f('0x1e'),_0x4287c0,JSON[_0x7b4f('0x18')](_0x53488c));_0x216ed4(_0x53488c);})[_0x7b4f('0x1d')](function(_0x299fff){logger['error'](_0x7b4f('0x1e'),_0x299fff[_0x7b4f('0x1b')],_0x4287c0);_0x242c49(_0x1c90e7[_0x7b4f('0x19')](0x1f4,_0x299fff[_0x7b4f('0x1b')]));});});};