Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.17] Fix notification settings creation #2287

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
@Startup
public class NotificationServiceImpl implements NotificationService {
private static final Logger log = Logger.getLogger(NotificationServiceImpl.class);
//@formatter:off
private static final String GET_NOTIFICATIONS = """
//@formatter:off
private static final String GET_NOTIFICATIONS = """
WITH ens AS (
SELECT ns.*, watch_id FROM notificationsettings ns
JOIN watch_users wu ON NOT ns.isteam AND ns.name = wu.users
Expand All @@ -60,7 +60,7 @@ WITH ens AS (
WHERE testid = ?
AND name NOT IN (SELECT optout FROM watch_optout WHERE ens.watch_id = watch_optout.watch_id)
""";
//@formatter:on
//@formatter:on
public final Map<String, NotificationPlugin> plugins = new HashMap<>();

@Inject
Expand Down Expand Up @@ -147,6 +147,7 @@ public List<NotificationSettings> settings(String name, boolean team) {
@RolesAllowed({ Roles.VIEWER, Roles.TESTER, Roles.ADMIN })
@Transactional
@Override
// remove and re-create the settings for the user
public void updateSettings(String name, boolean team, NotificationSettings[] settings) {
NotificationSettingsDAO.delete("name = ?1 AND isTeam = ?2", name, team);
Arrays.stream(settings).map(NotificationSettingsMapper::to).forEach(ns -> {
Expand All @@ -158,9 +159,11 @@ public void updateSettings(String name, boolean team, NotificationSettings[] set
}
throw ServiceException.badRequest("Invalid method " + ns.method);
}
// reset the id
ns.id = null;
ns.name = name;
ns.isTeam = team;
em.merge(ns);
ns.persist();
});
}

Expand Down