Built motion from commit (unavailable).|2.4.20
[motion2.git] / server / api / openchannelMessage / openchannelMessage.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 _0x0c3a=['OpenchannelMessage','body','options','raw','then','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','redis','localhost','socket.io-emitter','./openchannelMessage.socket','request','info','OpenchannelMessage,\x20%s,\x20%s','debug','OpenchannelMessage,\x20%s,\x20%s,\x20%s','error','code','message','request\x20sent','result','catch','CreateOpenchannelMessage'];(function(_0x125c92,_0x56d2dd){var _0x2152c6=function(_0x4f5a2a){while(--_0x4f5a2a){_0x125c92['push'](_0x125c92['shift']());}};_0x2152c6(++_0x56d2dd);}(_0x0c3a,0x171));var _0xa0c3=function(_0x4f8941,_0x1b7bc5){_0x4f8941=_0x4f8941-0x0;var _0x181f3b=_0x0c3a[_0x4f8941];return _0x181f3b;};'use strict';var _=require(_0xa0c3('0x0'));var util=require(_0xa0c3('0x1'));var moment=require(_0xa0c3('0x2'));var BPromise=require(_0xa0c3('0x3'));var rs=require(_0xa0c3('0x4'));var fs=require('fs');var Redis=require(_0xa0c3('0x5'));var db=require(_0xa0c3('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xa0c3('0x7'))(_0xa0c3('0x8'));var config=require('../../config/environment');var jayson=require(_0xa0c3('0x9'));var client=jayson[_0xa0c3('0xa')]['http']({'port':0x232a});config[_0xa0c3('0xb')]=_['defaults'](config['redis'],{'host':_0xa0c3('0xc'),'port':0x18eb});var socket=require(_0xa0c3('0xd'))(new Redis(config[_0xa0c3('0xb')]));require(_0xa0c3('0xe'))['register'](socket);function respondWithRpcPromise(_0x4122b7,_0x2c0801,_0x58078b){return new BPromise(function(_0x47fa6f,_0x187dcc){return client[_0xa0c3('0xf')](_0x4122b7,_0x58078b)['then'](function(_0x30522f){logger[_0xa0c3('0x10')](_0xa0c3('0x11'),_0x2c0801,'request\x20sent');logger[_0xa0c3('0x12')](_0xa0c3('0x13'),_0x2c0801,'request\x20sent',JSON['stringify'](_0x30522f));if(_0x30522f[_0xa0c3('0x14')]){if(_0x30522f[_0xa0c3('0x14')][_0xa0c3('0x15')]===0x1f4){logger[_0xa0c3('0x14')](_0xa0c3('0x11'),_0x2c0801,_0x30522f['error'][_0xa0c3('0x16')]);return _0x187dcc(_0x30522f['error'][_0xa0c3('0x16')]);}logger['error']('OpenchannelMessage,\x20%s,\x20%s',_0x2c0801,_0x30522f['error'][_0xa0c3('0x16')]);return _0x47fa6f(_0x30522f[_0xa0c3('0x14')][_0xa0c3('0x16')]);}else{logger['info'](_0xa0c3('0x11'),_0x2c0801,_0xa0c3('0x17'));_0x47fa6f(_0x30522f[_0xa0c3('0x18')][_0xa0c3('0x16')]);}})[_0xa0c3('0x19')](function(_0x42b62d){logger[_0xa0c3('0x14')]('OpenchannelMessage,\x20%s,\x20%s',_0x2c0801,_0x42b62d);_0x187dcc(_0x42b62d);});});}exports[_0xa0c3('0x1a')]=function(_0x4c310d){var _0x112c23=this;return new Promise(function(_0x23df7b,_0x46732e){return db[_0xa0c3('0x1b')]['create'](_0x4c310d[_0xa0c3('0x1c')],{'raw':_0x4c310d[_0xa0c3('0x1d')]?_0x4c310d[_0xa0c3('0x1d')][_0xa0c3('0x1e')]===undefined?!![]:![]:!![]})[_0xa0c3('0x1f')](function(_0xdb5807){logger[_0xa0c3('0x10')]('CreateOpenchannelMessage',_0x4c310d);logger[_0xa0c3('0x12')](_0xa0c3('0x1a'),_0x4c310d,JSON[_0xa0c3('0x20')](_0xdb5807));_0x23df7b(_0xdb5807);})['catch'](function(_0x47b303){logger[_0xa0c3('0x14')](_0xa0c3('0x1a'),_0x47b303[_0xa0c3('0x16')],_0x4c310d);_0x46732e(_0x112c23[_0xa0c3('0x14')](0x1f4,_0x47b303[_0xa0c3('0x16')]));});});};