Skip to content

Commit

Permalink
Put logs in UserEventDispatcher.
Browse files Browse the repository at this point in the history
  • Loading branch information
surli committed Feb 16, 2024
1 parent 0a345f7 commit 8898d14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ private CompletableFuture<?> dispatch(Event event, DocumentReference user, boole
// Get the entity id
String entityId = this.entityReferenceSerializer.serialize(user);
CompletableFuture<?> result = new CompletableFuture<>();
this.logger.debug("Dispatching event [{}] to user [{}]", event, user);

// Make sure the event is not already pre filtered
// Make sure the user asked to be alerted about this event
Expand Down Expand Up @@ -322,10 +323,10 @@ private boolean isPrefiltered(Event event, String entityId, boolean mail)
}

try (EventSearchResult result = this.events.search(eventQuery)) {
this.logger.debug("[{}] is prefiltered? [{}]", event, result.getTotalHits() > 0);
return result.getTotalHits() > 0;
} catch (Exception e) {
this.logger.error("Failed to check status for event [{}] and entity [{}]", event.getId(), entityId, e);

return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void initialize() throws InitializationException
*/
public boolean isListening(Event event, DocumentReference user, NotificationFormat format)
{
boolean result = false;
try {
if (hasAccess(user, event) && isEventAfterUserCreationDate(event, user)
&& (hasCorrespondingNotificationPreference(user, event, format)
Expand All @@ -121,13 +122,14 @@ public boolean isListening(Event event, DocumentReference user, NotificationForm
true, NotificationFilter.FilteringPhase.PRE_FILTERING));
filters.sort(null);

return !isEventFiltered(filters, event, user, format);
result = !isEventFiltered(filters, event, user, format);
}
} catch (NotificationException e) {
this.logger.error("Failed to get event filters for user [{}]", user, e);
}

return false;
this.logger.debug("event [{}] is listened by [{}] with format [{}]: [{}]", event, user, format, result);
return result;
}

private boolean hasAccess(DocumentReference user, Event event)
Expand Down

0 comments on commit 8898d14

Please sign in to comment.