Skip to content

Commit

Permalink
Merge pull request RocketChat#558 from assistify/release/0.70.4-0.9.5
Browse files Browse the repository at this point in the history
Release/0.70.4 0.9.5
  • Loading branch information
vickyokrm authored Jan 8, 2019
2 parents 7e96eca + dbd1d9c commit a52e00c
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 22 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Assistify 0.9.5

General bug-fix release.

# Assistify 0.9.4

This is a Live chat bugfix release.
Expand Down
22 changes: 15 additions & 7 deletions packages/assistify-ai/client/views/app/tabbar/smarti.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
/* globals TAPi18n, RocketChat */

Template.AssistifySmarti.onCreated(function() {
this.helpRequest = new ReactiveVar(null);
this.room = new ReactiveVar(null);
this.smartiLoaded = new ReactiveVar(false);
this.maxTriesLoading = 10;
this.timeoutMs = 2000;
this.currentTryLoading = new ReactiveVar(0);
this.reactOnSmartiDirty = new ReactiveVar(true);

const instance = this;

this.autorun(() => {
if (instance.data.rid) {
const helpRequest = RocketChat.models.Rooms.findOne(instance.data.rid);
instance.helpRequest.set(helpRequest);
const room = RocketChat.models.Rooms.findOne(instance.data.rid);
instance.room.set(room);
}
});

/*
Once this template is created (meaning: Once the tab is opened),
the user is interested in what Smarti is analyzing =>
Hook into an event issued by the backend to allow requesting an analysis
*/
RocketChat.Notifications.onRoom(instance.data.rid, 'assistify-smarti-dirty', () => {
if (this.reactOnSmartiDirty.get()) {
Meteor.call('analyze', instance.data.rid);
}
});
});

Template.AssistifySmarti.onDestroyed(function() {
this.reactOnSmartiDirty.set(false);
clearTimeout(this.loading);
});

Expand Down Expand Up @@ -89,10 +101,6 @@ Template.AssistifySmarti.helpers({
const instance = Template.instance();
return { roomId: instance.data.rid };
},
helpRequestByRoom() {
const instance = Template.instance();
return instance.helpRequest.get();
},
loadingClass() {
const instance = Template.instance();
if (instance.smartiLoaded.get()) {
Expand Down
5 changes: 1 addition & 4 deletions packages/assistify-ai/server/SmartiProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ export class SmartiProxy {
} catch (error) {

if (error && onError) {
const recoveryResult = onError(error);
if (recoveryResult !== undefined) {
return recoveryResult;
}
return onError(error);
}

SystemLogger.error('Could not complete', method, 'to', url, error.response);
Expand Down
22 changes: 15 additions & 7 deletions packages/assistify-ai/server/lib/SmartiAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ function terminateCurrentSync() {
syncTimer = 0;
}

function notifyClientsSmartiDirty(roomId, conversationId) {
RocketChat.Notifications.notifyRoom(roomId, 'assistify-smarti-dirty', {
roomId,
conversationId,
});
}
/**
* The SmartiAdpater can be understood as an interface for all interaction with Smarti triggered by Rocket.Chat server.
* The SmartiAdapter sould not expose any methods that can directly be called by the client.
Expand Down Expand Up @@ -111,7 +117,7 @@ export class SmartiAdapter {

if (request_result) {
Meteor.defer(() => SmartiAdapter._markMessageAsSynced(message._id));
SmartiAdapter._getAnalysisResult(message.rid, conversationId);
notifyClientsSmartiDirty(message.rid, conversationId);
// autosync: If a room was not in sync, but the new message could be synced, try to sync the room again
Meteor.defer(() => SmartiAdapter._tryResync(message.rid, false));
} else {
Expand All @@ -136,7 +142,7 @@ export class SmartiAdapter {
if (conversationId) {
SystemLogger.debug(`Smarti - Deleting message ${ message.rid } from conversation ${ conversationId }.`);
SmartiProxy.propagateToSmarti(verbs.delete, `conversation/${ conversationId }/message/${ message._id }`);
SmartiAdapter._getAnalysisResult(message.rid, conversationId);
notifyClientsSmartiDirty(message.rid, conversationId);
} else {
SystemLogger.error(`Smarti - deleting message from conversation faild after delete message [ id: ${ message._id } ] from room [ id: ${ message.rid } ]`);
}
Expand Down Expand Up @@ -237,11 +243,13 @@ export class SmartiAdapter {
/**
* Updates the mapping and triggers an asynchronous analysis.
*/
static _getAnalysisResult(roomId, conversationId) {

// conversation updated or created => request analysis results
SystemLogger.debug(`Smarti - conversation updated or created -> get analysis result asynch [ callback=${ SmartiAdapter.rocketWebhookUrl } ] for conversation: ${ conversationId } and room: ${ roomId }`);
SmartiProxy.propagateToSmarti(verbs.get, `conversation/${ conversationId }/analysis`, { callback: SmartiAdapter.rocketWebhookUrl }); // asynch
static triggerAnalysis(roomId) {
const conversationId = SmartiAdapter.getConversationId(roomId);
if (conversationId) {
SmartiProxy.propagateToSmarti(verbs.get, `conversation/${ conversationId }/analysis`, { callback: SmartiAdapter.rocketWebhookUrl }); // asynch
} else {
SystemLogger.error(`No conversation found for roomId ${ roomId }`);
}
}

/**
Expand Down
15 changes: 15 additions & 0 deletions packages/assistify-ai/server/methods/SmartiWidgetBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ Meteor.methods({
});
},

/**
* This method provides the client a handler to request the asynchronous analysis of a room's messages
* It can e. g. be issued from the widget once it's opened
* @param {*} roomId The ID of the Rocket.Chat room which shall be analyzed
*/
analyze(roomId) {
return RocketChat.RateLimiter.limitFunction(
SmartiAdapter.triggerAnalysis, 5, 1000, {
userId(userId) {
return !RocketChat.authz.hasPermission(userId, 'send-many-messages');
},
}
)(roomId);
},

/**
* Returns the query builder results for the given conversation (used by Smarti widget)
*
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/rocketchat.info
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.70.4-0.9.2"
"version": "0.70.4-0.9.5"
}
2 changes: 1 addition & 1 deletion packages/rocketchat-livechat/.app/client/lib/_livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ this.Livechat = new (class Livechat {
this._agent.set(result);
}
});
this.stream.on(this._room.get(), { token: visitor.getToken() }, (eventData) => {
this.stream.on(this._room.get(), { visitorToken: visitor.getToken() }, (eventData) => {
if (!eventData || !eventData.type) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-livechat/.app/client/views/poweredBy.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template name="poweredBy">
<p class="powered-by">
{{_ "Powered_by"}}
<a href="https://rocket.chat" target="_blank">
<img class="logo" src="images/logo/logo.svg?v=1">
<a href="http://assistify.de" target="_blank">
<img class="logo" src="/images/logo/assistify_keyImage.png">
</a>
</p>
</template>
Binary file added public/images/logo/assistify_keyImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a52e00c

Please sign in to comment.