Built motion from commit (unavailable).|2.5.13
[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 _0x75b2=['options','raw','lodash','moment','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','socket.io-emitter','./chatMessage.socket','register','request','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateChatMessage','ChatMessage','body'];(function(_0x15417a,_0x4458ad){var _0x206f1e=function(_0x15e458){while(--_0x15e458){_0x15417a['push'](_0x15417a['shift']());}};_0x206f1e(++_0x4458ad);}(_0x75b2,0x122));var _0x275b=function(_0x3de92a,_0x2c7307){_0x3de92a=_0x3de92a-0x0;var _0x576839=_0x75b2[_0x3de92a];return _0x576839;};'use strict';var _=require(_0x275b('0x0'));var util=require('util');var moment=require(_0x275b('0x1'));var BPromise=require('bluebird');var rs=require(_0x275b('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x275b('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x275b('0x4'))(_0x275b('0x5'));var config=require(_0x275b('0x6'));var jayson=require(_0x275b('0x7'));var client=jayson[_0x275b('0x8')]['http']({'port':0x232a});config[_0x275b('0x9')]=_[_0x275b('0xa')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x275b('0xb'))(new Redis(config[_0x275b('0x9')]));require(_0x275b('0xc'))[_0x275b('0xd')](socket);function respondWithRpcPromise(_0x1fbc3e,_0x3c57bd,_0x2398a0){return new BPromise(function(_0x21b1f9,_0x27e0fd){return client[_0x275b('0xe')](_0x1fbc3e,_0x2398a0)[_0x275b('0xf')](function(_0x4bef39){logger[_0x275b('0x10')](_0x275b('0x11'),_0x3c57bd,_0x275b('0x12'));logger[_0x275b('0x13')](_0x275b('0x14'),_0x3c57bd,_0x275b('0x12'),JSON[_0x275b('0x15')](_0x4bef39));if(_0x4bef39['error']){if(_0x4bef39[_0x275b('0x16')][_0x275b('0x17')]===0x1f4){logger[_0x275b('0x16')](_0x275b('0x11'),_0x3c57bd,_0x4bef39['error'][_0x275b('0x18')]);return _0x27e0fd(_0x4bef39[_0x275b('0x16')][_0x275b('0x18')]);}logger[_0x275b('0x16')](_0x275b('0x11'),_0x3c57bd,_0x4bef39['error'][_0x275b('0x18')]);return _0x21b1f9(_0x4bef39[_0x275b('0x16')][_0x275b('0x18')]);}else{logger[_0x275b('0x10')](_0x275b('0x11'),_0x3c57bd,_0x275b('0x12'));_0x21b1f9(_0x4bef39[_0x275b('0x19')][_0x275b('0x18')]);}})[_0x275b('0x1a')](function(_0x5ab2ad){logger[_0x275b('0x16')](_0x275b('0x11'),_0x3c57bd,_0x5ab2ad);_0x27e0fd(_0x5ab2ad);});});}exports[_0x275b('0x1b')]=function(_0xe1b96a){var _0x2fbdc2=this;return new Promise(function(_0x8cc926,_0x1c42f1){return db[_0x275b('0x1c')]['create'](_0xe1b96a[_0x275b('0x1d')],{'raw':_0xe1b96a[_0x275b('0x1e')]?_0xe1b96a[_0x275b('0x1e')][_0x275b('0x1f')]===undefined?!![]:![]:!![]})[_0x275b('0xf')](function(_0x23e793){logger[_0x275b('0x10')](_0x275b('0x1b'),_0xe1b96a);logger[_0x275b('0x13')](_0x275b('0x1b'),_0xe1b96a,JSON[_0x275b('0x15')](_0x23e793));_0x8cc926(_0x23e793);})[_0x275b('0x1a')](function(_0x314177){logger[_0x275b('0x16')](_0x275b('0x1b'),_0x314177[_0x275b('0x18')],_0xe1b96a);_0x1c42f1(_0x2fbdc2['error'](0x1f4,_0x314177['message']));});});};