Built motion from commit e02f907f.|2.6.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 _0x8f7c=['debug','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','redis','defaults','socket.io-emitter','register','request','then','SmsMessage,\x20%s,\x20%s','request\x20sent','SmsMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateSmsMessage','SmsMessage','create','options','raw','info'];(function(_0x20ea89,_0x1bfce6){var _0x1f06a8=function(_0xc541ce){while(--_0xc541ce){_0x20ea89['push'](_0x20ea89['shift']());}};_0x1f06a8(++_0x1bfce6);}(_0x8f7c,0x64));var _0xc8f7=function(_0x4e00d4,_0xdb24a3){_0x4e00d4=_0x4e00d4-0x0;var _0x335d2c=_0x8f7c[_0x4e00d4];return _0x335d2c;};'use strict';var _=require(_0xc8f7('0x0'));var util=require(_0xc8f7('0x1'));var moment=require('moment');var BPromise=require(_0xc8f7('0x2'));var rs=require(_0xc8f7('0x3'));var fs=require('fs');var Redis=require(_0xc8f7('0x4'));var db=require(_0xc8f7('0x5'))['db'];var utils=require(_0xc8f7('0x6'));var logger=require(_0xc8f7('0x7'))('rpc');var config=require(_0xc8f7('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xc8f7('0x9')][_0xc8f7('0xa')]({'port':0x232a});config[_0xc8f7('0xb')]=_[_0xc8f7('0xc')](config[_0xc8f7('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0xc8f7('0xd'))(new Redis(config[_0xc8f7('0xb')]));require('./smsMessage.socket')[_0xc8f7('0xe')](socket);function respondWithRpcPromise(_0x34d814,_0xea1146,_0x127763){return new BPromise(function(_0x19c8f4,_0x53aa8c){return client[_0xc8f7('0xf')](_0x34d814,_0x127763)[_0xc8f7('0x10')](function(_0x3c7b6c){logger['info'](_0xc8f7('0x11'),_0xea1146,_0xc8f7('0x12'));logger['debug'](_0xc8f7('0x13'),_0xea1146,_0xc8f7('0x12'),JSON[_0xc8f7('0x14')](_0x3c7b6c));if(_0x3c7b6c[_0xc8f7('0x15')]){if(_0x3c7b6c[_0xc8f7('0x15')][_0xc8f7('0x16')]===0x1f4){logger[_0xc8f7('0x15')](_0xc8f7('0x11'),_0xea1146,_0x3c7b6c[_0xc8f7('0x15')][_0xc8f7('0x17')]);return _0x53aa8c(_0x3c7b6c[_0xc8f7('0x15')][_0xc8f7('0x17')]);}logger[_0xc8f7('0x15')](_0xc8f7('0x11'),_0xea1146,_0x3c7b6c[_0xc8f7('0x15')][_0xc8f7('0x17')]);return _0x19c8f4(_0x3c7b6c[_0xc8f7('0x15')]['message']);}else{logger['info'](_0xc8f7('0x11'),_0xea1146,'request\x20sent');_0x19c8f4(_0x3c7b6c[_0xc8f7('0x18')][_0xc8f7('0x17')]);}})[_0xc8f7('0x19')](function(_0x36f35d){logger['error'](_0xc8f7('0x11'),_0xea1146,_0x36f35d);_0x53aa8c(_0x36f35d);});});}exports[_0xc8f7('0x1a')]=function(_0x32d34b){var _0xd5e1fc=this;return new Promise(function(_0x3208c9,_0x1c8ee0){return db[_0xc8f7('0x1b')][_0xc8f7('0x1c')](_0x32d34b['body'],{'raw':_0x32d34b[_0xc8f7('0x1d')]?_0x32d34b['options'][_0xc8f7('0x1e')]===undefined?!![]:![]:!![]})[_0xc8f7('0x10')](function(_0xc98562){logger[_0xc8f7('0x1f')]('CreateSmsMessage',_0x32d34b);logger[_0xc8f7('0x20')](_0xc8f7('0x1a'),_0x32d34b,JSON['stringify'](_0xc98562));_0x3208c9(_0xc98562);})[_0xc8f7('0x19')](function(_0x53cfa9){logger[_0xc8f7('0x15')](_0xc8f7('0x1a'),_0x53cfa9['message'],_0x32d34b);_0x1c8ee0(_0xd5e1fc[_0xc8f7('0x15')](0x1f4,_0x53cfa9[_0xc8f7('0x17')]));});});};