Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / chatMessage / chatMessage.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 _0xcd3a=['raw','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./chatMessage.socket','request','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','CreateChatMessage','create','body','options'];(function(_0x526aeb,_0x33c315){var _0xe874c4=function(_0x1dd7e1){while(--_0x1dd7e1){_0x526aeb['push'](_0x526aeb['shift']());}};_0xe874c4(++_0x33c315);}(_0xcd3a,0x8e));var _0xacd3=function(_0x1daba6,_0x2dfd65){_0x1daba6=_0x1daba6-0x0;var _0x2f8a91=_0xcd3a[_0x1daba6];return _0x2f8a91;};'use strict';var _=require('lodash');var util=require(_0xacd3('0x0'));var moment=require(_0xacd3('0x1'));var BPromise=require(_0xacd3('0x2'));var rs=require(_0xacd3('0x3'));var fs=require('fs');var Redis=require(_0xacd3('0x4'));var db=require(_0xacd3('0x5'))['db'];var utils=require(_0xacd3('0x6'));var logger=require(_0xacd3('0x7'))(_0xacd3('0x8'));var config=require('../../config/environment');var jayson=require(_0xacd3('0x9'));var client=jayson[_0xacd3('0xa')][_0xacd3('0xb')]({'port':0x232a});config[_0xacd3('0xc')]=_[_0xacd3('0xd')](config['redis'],{'host':_0xacd3('0xe'),'port':0x18eb});var socket=require(_0xacd3('0xf'))(new Redis(config[_0xacd3('0xc')]));require(_0xacd3('0x10'))['register'](socket);function respondWithRpcPromise(_0x14ac53,_0x51bcae,_0x3c6b24){return new BPromise(function(_0x3512e8,_0x2bf95b){return client[_0xacd3('0x11')](_0x14ac53,_0x3c6b24)[_0xacd3('0x12')](function(_0x13254c){logger[_0xacd3('0x13')](_0xacd3('0x14'),_0x51bcae,_0xacd3('0x15'));logger[_0xacd3('0x16')](_0xacd3('0x17'),_0x51bcae,'request\x20sent',JSON[_0xacd3('0x18')](_0x13254c));if(_0x13254c[_0xacd3('0x19')]){if(_0x13254c[_0xacd3('0x19')][_0xacd3('0x1a')]===0x1f4){logger[_0xacd3('0x19')](_0xacd3('0x14'),_0x51bcae,_0x13254c[_0xacd3('0x19')][_0xacd3('0x1b')]);return _0x2bf95b(_0x13254c[_0xacd3('0x19')]['message']);}logger[_0xacd3('0x19')](_0xacd3('0x14'),_0x51bcae,_0x13254c[_0xacd3('0x19')]['message']);return _0x3512e8(_0x13254c[_0xacd3('0x19')][_0xacd3('0x1b')]);}else{logger[_0xacd3('0x13')](_0xacd3('0x14'),_0x51bcae,_0xacd3('0x15'));_0x3512e8(_0x13254c[_0xacd3('0x1c')][_0xacd3('0x1b')]);}})['catch'](function(_0x103dcb){logger[_0xacd3('0x19')](_0xacd3('0x14'),_0x51bcae,_0x103dcb);_0x2bf95b(_0x103dcb);});});}exports[_0xacd3('0x1d')]=function(_0x295b47){var _0x1ebedb=this;return new Promise(function(_0x4a0b08,_0x10ca0f){return db['ChatMessage'][_0xacd3('0x1e')](_0x295b47[_0xacd3('0x1f')],{'raw':_0x295b47[_0xacd3('0x20')]?_0x295b47['options'][_0xacd3('0x21')]===undefined?!![]:![]:!![]})[_0xacd3('0x12')](function(_0x3f1029){logger[_0xacd3('0x13')](_0xacd3('0x1d'),_0x295b47);logger[_0xacd3('0x16')](_0xacd3('0x1d'),_0x295b47,JSON[_0xacd3('0x18')](_0x3f1029));_0x4a0b08(_0x3f1029);})[_0xacd3('0x22')](function(_0x34de83){logger[_0xacd3('0x19')](_0xacd3('0x1d'),_0x34de83['message'],_0x295b47);_0x10ca0f(_0x1ebedb[_0xacd3('0x19')](0x1f4,_0x34de83[_0xacd3('0x1b')]));});});};