Skip to content

Commit

Permalink
fix: Don't update last event timestamp on injected events (WEBAPP-6411)…
Browse files Browse the repository at this point in the history
… (#7313)
  • Loading branch information
bennycode committed Sep 20, 2019
1 parent 885364e commit ec0d698
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/script/event/EventRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class EventRepository {

/**
* Get the last notification.
* @returns {Promise<string>} Resolves with the last handled notification ID
* @returns {Promise<{eventDate: string, notificationId: string}>} Resolves with the last handled notification ID and time
*/
getStreamState() {
return this.notificationService
Expand Down Expand Up @@ -672,7 +672,10 @@ export class EventRepository {
const isInjectedEvent = source === EventRepository.SOURCE.INJECTED;
const canSetEventDate = !isInjectedEvent && eventDate;
if (canSetEventDate) {
this._updateLastEventDate(eventDate);
// HOTFIX: The "conversation.voice-channel-deactivate" event is the ONLY event which we inject with a source set to WebSocket. This is wrong but changing it will break our current conversation archive functionality (WEBAPP-6435). That's why we need to explicitly list the "conversation.voice-channel-deactivate" here because injected events should NEVER modify the last event timestamp which we use to query the backend's notification stream.
if (event.type !== ClientEvent.CONVERSATION.VOICE_CHANNEL_DEACTIVATE) {
this._updateLastEventDate(eventDate);
}
}

const isCallEvent = event.type === ClientEvent.CALL.E_CALL;
Expand Down Expand Up @@ -925,7 +928,7 @@ export class EventRepository {
}

const eventIsoDate = new Date(time).toISOString();
const logMessage = `Ignored outdated '${type}' event (${eventIsoDate}) in conversation '${conversationId}'`;
const logMessage = `Ignored outdated calling event '${type}' (${eventIsoDate}) in conversation '${conversationId}'`;
const logObject = {
eventJson: JSON.stringify(event),
eventObject: event,
Expand Down

0 comments on commit ec0d698

Please sign in to comment.