Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / chatInteraction / chatInteraction.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 _0xacfa=['ChatInteraction,\x20%s,\x20%s','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','UpdateChatInteraction','ChatInteraction','update','body','options','raw','where','attributes','limit','AddTagsToChatInteraction','find','addTags','ids','AddTags','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','defaults','localhost','./chatInteraction.socket','request','then'];(function(_0x2e5a17,_0x558f0e){var _0x24f53d=function(_0x564eb5){while(--_0x564eb5){_0x2e5a17['push'](_0x2e5a17['shift']());}};_0x24f53d(++_0x558f0e);}(_0xacfa,0xdf));var _0xaacf=function(_0x5d0a06,_0x2f8043){_0x5d0a06=_0x5d0a06-0x0;var _0x2350ca=_0xacfa[_0x5d0a06];return _0x2350ca;};'use strict';var _=require(_0xaacf('0x0'));var util=require(_0xaacf('0x1'));var moment=require(_0xaacf('0x2'));var BPromise=require(_0xaacf('0x3'));var rs=require(_0xaacf('0x4'));var fs=require('fs');var Redis=require(_0xaacf('0x5'));var db=require(_0xaacf('0x6'))['db'];var utils=require(_0xaacf('0x7'));var logger=require(_0xaacf('0x8'))('rpc');var config=require('../../config/environment');var jayson=require(_0xaacf('0x9'));var client=jayson[_0xaacf('0xa')][_0xaacf('0xb')]({'port':0x232a});config['redis']=_[_0xaacf('0xc')](config['redis'],{'host':_0xaacf('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xaacf('0xe'))['register'](socket);function respondWithRpcPromise(_0xcda731,_0x88bd13,_0x339c8d){return new BPromise(function(_0x3d3418,_0x2041fd){return client[_0xaacf('0xf')](_0xcda731,_0x339c8d)[_0xaacf('0x10')](function(_0xc6c6aa){logger['info'](_0xaacf('0x11'),_0x88bd13,'request\x20sent');logger[_0xaacf('0x12')](_0xaacf('0x13'),_0x88bd13,'request\x20sent',JSON[_0xaacf('0x14')](_0xc6c6aa));if(_0xc6c6aa[_0xaacf('0x15')]){if(_0xc6c6aa[_0xaacf('0x15')]['code']===0x1f4){logger[_0xaacf('0x15')](_0xaacf('0x11'),_0x88bd13,_0xc6c6aa[_0xaacf('0x15')][_0xaacf('0x16')]);return _0x2041fd(_0xc6c6aa[_0xaacf('0x15')][_0xaacf('0x16')]);}logger[_0xaacf('0x15')](_0xaacf('0x11'),_0x88bd13,_0xc6c6aa[_0xaacf('0x15')][_0xaacf('0x16')]);return _0x3d3418(_0xc6c6aa[_0xaacf('0x15')][_0xaacf('0x16')]);}else{logger[_0xaacf('0x17')](_0xaacf('0x11'),_0x88bd13,'request\x20sent');_0x3d3418(_0xc6c6aa[_0xaacf('0x18')][_0xaacf('0x16')]);}})['catch'](function(_0x18368a){logger['error'](_0xaacf('0x11'),_0x88bd13,_0x18368a);_0x2041fd(_0x18368a);});});}exports[_0xaacf('0x19')]=function(_0x47e4a){var _0x200354=this;return new Promise(function(_0x1b90d0,_0x49e84f){return db[_0xaacf('0x1a')][_0xaacf('0x1b')](_0x47e4a[_0xaacf('0x1c')],{'raw':_0x47e4a['options']?_0x47e4a[_0xaacf('0x1d')][_0xaacf('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x47e4a[_0xaacf('0x1d')]?_0x47e4a[_0xaacf('0x1d')][_0xaacf('0x1f')]||null:null,'attributes':_0x47e4a[_0xaacf('0x1d')]?_0x47e4a[_0xaacf('0x1d')][_0xaacf('0x20')]||null:null,'limit':_0x47e4a[_0xaacf('0x1d')]?_0x47e4a[_0xaacf('0x1d')][_0xaacf('0x21')]||null:null})['then'](function(_0xe01471){logger['info'](_0xaacf('0x19'),_0x47e4a);logger[_0xaacf('0x12')](_0xaacf('0x19'),_0x47e4a,JSON[_0xaacf('0x14')](_0xe01471));_0x1b90d0(_0xe01471);})['catch'](function(_0x3891b2){logger[_0xaacf('0x15')](_0xaacf('0x19'),_0x3891b2[_0xaacf('0x16')],_0x47e4a);_0x49e84f(_0x200354['error'](0x1f4,_0x3891b2[_0xaacf('0x16')]));});});};exports[_0xaacf('0x22')]=function(_0x4a9501){return new Promise(function(_0x4da9ba,_0x49eab2){return db['ChatInteraction'][_0xaacf('0x23')]({'where':_0x4a9501[_0xaacf('0x1d')]?_0x4a9501['options'][_0xaacf('0x1f')]||null:null})['then'](function(_0x41f768){if(_0x41f768){return _0x41f768[_0xaacf('0x24')](_0x4a9501[_0xaacf('0x1c')][_0xaacf('0x25')],_['omit'](_0x4a9501[_0xaacf('0x1c')],[_0xaacf('0x25'),'id'])||{});}})['spread'](function(_0x20162f){logger[_0xaacf('0x17')](_0xaacf('0x26'),_0x4a9501);logger[_0xaacf('0x12')](_0xaacf('0x26'),_0x4a9501,JSON[_0xaacf('0x14')](_0x20162f));_0x4da9ba(_0x20162f);})[_0xaacf('0x27')](function(_0x3a0426){logger[_0xaacf('0x15')](_0xaacf('0x26'),_0x3a0426['message'],_0x4a9501);_0x49eab2(_this[_0xaacf('0x15')](0x1f4,_0x3a0426['message']));});});};