Built motion from commit f7863d46.|2.5.41
[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 _0x0652=['localhost','socket.io-emitter','./chatInteraction.socket','request','info','ChatInteraction,\x20%s,\x20%s','request\x20sent','ChatInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','UpdateChatInteraction','ChatInteraction','update','options','raw','where','attributes','limit','then','AddTagsToChatInteraction','addTags','body','ids','spread','AddTags','debug','lodash','util','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults'];(function(_0x4c47de,_0x51157d){var _0x3d265c=function(_0x5bbbc8){while(--_0x5bbbc8){_0x4c47de['push'](_0x4c47de['shift']());}};_0x3d265c(++_0x51157d);}(_0x0652,0x197));var _0x2065=function(_0x3dc8b9,_0xd3f492){_0x3dc8b9=_0x3dc8b9-0x0;var _0x32aadb=_0x0652[_0x3dc8b9];return _0x32aadb;};'use strict';var _=require(_0x2065('0x0'));var util=require(_0x2065('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x2065('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2065('0x3'))['db'];var utils=require(_0x2065('0x4'));var logger=require(_0x2065('0x5'))(_0x2065('0x6'));var config=require(_0x2065('0x7'));var jayson=require(_0x2065('0x8'));var client=jayson[_0x2065('0x9')][_0x2065('0xa')]({'port':0x232a});config[_0x2065('0xb')]=_[_0x2065('0xc')](config[_0x2065('0xb')],{'host':_0x2065('0xd'),'port':0x18eb});var socket=require(_0x2065('0xe'))(new Redis(config['redis']));require(_0x2065('0xf'))['register'](socket);function respondWithRpcPromise(_0xbcf8e0,_0x3cd744,_0x39ff0c){return new BPromise(function(_0x5d0b69,_0x4b5357){return client[_0x2065('0x10')](_0xbcf8e0,_0x39ff0c)['then'](function(_0x510ec3){logger[_0x2065('0x11')](_0x2065('0x12'),_0x3cd744,_0x2065('0x13'));logger['debug'](_0x2065('0x14'),_0x3cd744,_0x2065('0x13'),JSON[_0x2065('0x15')](_0x510ec3));if(_0x510ec3[_0x2065('0x16')]){if(_0x510ec3['error'][_0x2065('0x17')]===0x1f4){logger[_0x2065('0x16')](_0x2065('0x12'),_0x3cd744,_0x510ec3[_0x2065('0x16')]['message']);return _0x4b5357(_0x510ec3[_0x2065('0x16')][_0x2065('0x18')]);}logger[_0x2065('0x16')](_0x2065('0x12'),_0x3cd744,_0x510ec3[_0x2065('0x16')][_0x2065('0x18')]);return _0x5d0b69(_0x510ec3[_0x2065('0x16')][_0x2065('0x18')]);}else{logger[_0x2065('0x11')]('ChatInteraction,\x20%s,\x20%s',_0x3cd744,'request\x20sent');_0x5d0b69(_0x510ec3[_0x2065('0x19')][_0x2065('0x18')]);}})['catch'](function(_0x31e265){logger[_0x2065('0x16')](_0x2065('0x12'),_0x3cd744,_0x31e265);_0x4b5357(_0x31e265);});});}exports[_0x2065('0x1a')]=function(_0x54af53){var _0x43480b=this;return new Promise(function(_0x2da167,_0x4d72de){return db[_0x2065('0x1b')][_0x2065('0x1c')](_0x54af53['body'],{'raw':_0x54af53['options']?_0x54af53[_0x2065('0x1d')][_0x2065('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x54af53[_0x2065('0x1d')]?_0x54af53[_0x2065('0x1d')][_0x2065('0x1f')]||null:null,'attributes':_0x54af53[_0x2065('0x1d')]?_0x54af53[_0x2065('0x1d')][_0x2065('0x20')]||null:null,'limit':_0x54af53[_0x2065('0x1d')]?_0x54af53[_0x2065('0x1d')][_0x2065('0x21')]||null:null})[_0x2065('0x22')](function(_0x322d9f){logger[_0x2065('0x11')]('UpdateChatInteraction',_0x54af53);logger['debug'](_0x2065('0x1a'),_0x54af53,JSON['stringify'](_0x322d9f));_0x2da167(_0x322d9f);})['catch'](function(_0x56b1ee){logger[_0x2065('0x16')](_0x2065('0x1a'),_0x56b1ee[_0x2065('0x18')],_0x54af53);_0x4d72de(_0x43480b['error'](0x1f4,_0x56b1ee[_0x2065('0x18')]));});});};exports[_0x2065('0x23')]=function(_0x4dc629){return new Promise(function(_0x4bc986,_0x1e3f67){return db[_0x2065('0x1b')]['find']({'where':_0x4dc629[_0x2065('0x1d')]?_0x4dc629[_0x2065('0x1d')][_0x2065('0x1f')]||null:null})['then'](function(_0x1c4d35){if(_0x1c4d35){return _0x1c4d35[_0x2065('0x24')](_0x4dc629[_0x2065('0x25')][_0x2065('0x26')],_['omit'](_0x4dc629[_0x2065('0x25')],[_0x2065('0x26'),'id'])||{});}})[_0x2065('0x27')](function(_0x4c91f0){logger[_0x2065('0x11')](_0x2065('0x28'),_0x4dc629);logger[_0x2065('0x29')](_0x2065('0x28'),_0x4dc629,JSON['stringify'](_0x4c91f0));_0x4bc986(_0x4c91f0);})['catch'](function(_0x15b664){logger[_0x2065('0x16')](_0x2065('0x28'),_0x15b664[_0x2065('0x18')],_0x4dc629);_0x1e3f67(_this[_0x2065('0x16')](0x1f4,_0x15b664[_0x2065('0x18')]));});});};