IQSS / IQSS/dataverse

Working around warning log, notification type enum and notification muted

Open
#9,450 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature: Notifications Type: Bug User Role: Depositor
Dominant language
Java
Stars
1.1k
Forks
564
Avg merge
2d 2h
Merged PRs (30d)
29

Description

Hello Dataverse Team,

I would like to share an analysis with you regarding some specific log (nothing major here ^^) :

[2023-03-16T08:57:09.548+0100] [Payara 5.2022.4] [WARNING] [] [edu.harvard.iq.dataverse.util.BundleUtil] [tid: _ThreadID=177 _ThreadName=http-thread-pool::jk-connector(2)] [timeMillis: 1678953429548] [levelValue: 900] [[
  Could not find key "notification.typeDescription.GLOBUSDOWNLOADCOMPLETEDWITHERRORS" in bundle file: ]]

We have the same log with those keys :

notification.typeDescription.GLOBUSDOWNLOADCOMPLETED
notification.typeDescription.GLOBUSDOWNLOADCOMPLETEDWITHERRORS
notification.typeDescription.GLOBUSUPLOADCOMPLETED
notification.typeDescription.GLOBUSUPLOADCOMPLETEDWITHERRORS

In Bundle.properties file it is said that

# Notification types descriptions as presentend to the user. Leave the description empty or leave it out entirely in order to make it not selectable for muting by the user.

Which, in my opinion, is a bit of a strange way to handle "notification to be seen or not".
Checking the java code, UserNotification.hasDescription() seems to be used to "to make it not selectable for muting by the user" :
in DataverseUserPage.init()

notificationTypeList = Arrays.asList(Type.values()).stream()
                    .filter(x -> !Type.CONFIRMEMAIL.equals(x) && x.hasDescription() && !settingsWrapper.isAlwaysMuted(x))
                    .collect(Collectors.toList());

This filter make sense but I think we miss this filter when getting the description getDescription() :
in Notifications.getMutedEmailsForUser()

authenticatedUser.getMutedEmails().stream().forEach(
            x -> mutedEmails.add(jsonObjectBuilder().add("name", x.name()).add("description", x.getDescription()))
        );

or in Notifications.getMutedNotificationsForUser()

authenticatedUser.getMutedNotifications().stream().forEach(
            x -> mutedNotifications.add(jsonObjectBuilder().add("name", x.name()).add("description", x.getDescription()))
        );

this does trigger the WARNING log to be prompted.


I don't know what is the best way to fix this :

  1. Adding keys in Bundle.properties and filtering all keys with !Type.GLOBUSDOWNLOADCOMPLETED.equals(x) ?
  2. Adding .filter(x -> x.hasDescription()) before a x.getDescription() loop ?
  3. Change UserNotification.Type enum style to add a boolean attribut like allowedToBeMutedByUser = true/false and use it depending on java code purposes ?

In the meantime I decided to add empty keys in Bundle.properties

notification.typeDescription.GLOBUSDOWNLOADCOMPLETED=
notification.typeDescription.GLOBUSDOWNLOADCOMPLETEDWITHERRORS=
notification.typeDescription.GLOBUSUPLOADCOMPLETED=
notification.typeDescription.GLOBUSUPLOADCOMPLETEDWITHERRORS=

This removes the warnings but if a random person add some value in the future, we will experience issues.

What do you think about it ?
Regards

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with UserNotification.java and compare the hasDescription() handling in DataverseUserPage.java with the muted-email and muted-notification responses in Notifications.java. Review the related entries in Bundle.properties and define consistent behavior for missing descriptions; done means the affected endpoints no longer emit warning logs for these notification types and their mute metadata is correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.