Built motion from commit (unavailable).|2.5.15
[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 _0xfc70=['create','body','options','then','lodash','util','bluebird','randomstring','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','socket.io-emitter','register','request','info','SmsMessage,\x20%s,\x20%s','debug','SmsMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','catch','CreateSmsMessage','SmsMessage'];(function(_0x24259d,_0x64a194){var _0x5a701=function(_0x204516){while(--_0x204516){_0x24259d['push'](_0x24259d['shift']());}};_0x5a701(++_0x64a194);}(_0xfc70,0x160));var _0x0fc7=function(_0x2ed1de,_0x37454a){_0x2ed1de=_0x2ed1de-0x0;var _0x58a8f9=_0xfc70[_0x2ed1de];return _0x58a8f9;};'use strict';var _=require(_0x0fc7('0x0'));var util=require(_0x0fc7('0x1'));var moment=require('moment');var BPromise=require(_0x0fc7('0x2'));var rs=require(_0x0fc7('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x0fc7('0x4'))(_0x0fc7('0x5'));var config=require(_0x0fc7('0x6'));var jayson=require(_0x0fc7('0x7'));var client=jayson['client'][_0x0fc7('0x8')]({'port':0x232a});config[_0x0fc7('0x9')]=_[_0x0fc7('0xa')](config[_0x0fc7('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x0fc7('0xb'))(new Redis(config[_0x0fc7('0x9')]));require('./smsMessage.socket')[_0x0fc7('0xc')](socket);function respondWithRpcPromise(_0x412fcc,_0x1fa0d4,_0x5bc563){return new BPromise(function(_0x1a5b8a,_0x15c2d9){return client[_0x0fc7('0xd')](_0x412fcc,_0x5bc563)['then'](function(_0x4f1696){logger[_0x0fc7('0xe')](_0x0fc7('0xf'),_0x1fa0d4,'request\x20sent');logger[_0x0fc7('0x10')](_0x0fc7('0x11'),_0x1fa0d4,_0x0fc7('0x12'),JSON[_0x0fc7('0x13')](_0x4f1696));if(_0x4f1696[_0x0fc7('0x14')]){if(_0x4f1696['error']['code']===0x1f4){logger['error']('SmsMessage,\x20%s,\x20%s',_0x1fa0d4,_0x4f1696[_0x0fc7('0x14')]['message']);return _0x15c2d9(_0x4f1696['error'][_0x0fc7('0x15')]);}logger[_0x0fc7('0x14')](_0x0fc7('0xf'),_0x1fa0d4,_0x4f1696[_0x0fc7('0x14')][_0x0fc7('0x15')]);return _0x1a5b8a(_0x4f1696[_0x0fc7('0x14')][_0x0fc7('0x15')]);}else{logger[_0x0fc7('0xe')](_0x0fc7('0xf'),_0x1fa0d4,_0x0fc7('0x12'));_0x1a5b8a(_0x4f1696['result']['message']);}})[_0x0fc7('0x16')](function(_0x5bfaf5){logger[_0x0fc7('0x14')](_0x0fc7('0xf'),_0x1fa0d4,_0x5bfaf5);_0x15c2d9(_0x5bfaf5);});});}exports[_0x0fc7('0x17')]=function(_0xa5529f){var _0x13c8c9=this;return new Promise(function(_0x467e50,_0x39dafc){return db[_0x0fc7('0x18')][_0x0fc7('0x19')](_0xa5529f[_0x0fc7('0x1a')],{'raw':_0xa5529f[_0x0fc7('0x1b')]?_0xa5529f[_0x0fc7('0x1b')]['raw']===undefined?!![]:![]:!![]})[_0x0fc7('0x1c')](function(_0x22f34d){logger[_0x0fc7('0xe')]('CreateSmsMessage',_0xa5529f);logger[_0x0fc7('0x10')](_0x0fc7('0x17'),_0xa5529f,JSON[_0x0fc7('0x13')](_0x22f34d));_0x467e50(_0x22f34d);})[_0x0fc7('0x16')](function(_0x5f4cc9){logger['error'](_0x0fc7('0x17'),_0x5f4cc9[_0x0fc7('0x15')],_0xa5529f);_0x39dafc(_0x13c8c9['error'](0x1f4,_0x5f4cc9[_0x0fc7('0x15')]));});});};