Skip to content

Commit

Permalink
SAK-49529 add event annc.available.announcement to bulk delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ern committed Dec 4, 2023
1 parent d20f572 commit 37c917e
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@
@Slf4j
@Component
public class AnnouncementsUserNotificationHandler extends AbstractUserNotificationHandler {

private static final String ADD_EVENT = AnnouncementService.SECURE_ANNC_ADD;
private static final String UPDATE_EVENT = AnnouncementService.EVENT_ANNC_UPDATE_AVAILABILITY;

@Resource
private AnnouncementService announcementService;

Expand Down Expand Up @@ -119,8 +115,9 @@ public Optional<List<UserNotificationData>> handleEvent(Event event) {
}

// remove user notifications for the message that was deleted or those that have been updated and are not visible (draft or future)
// annc.available.announcement
if ((AnnouncementService.SECURE_ANNC_REMOVE_OWN.equals(eventName) || AnnouncementService.SECURE_ANNC_REMOVE_ANY.equals(eventName))
|| (UPDATE_EVENT.equals(eventName) && (isDraftMessage || isFutureMessage))) {
|| (AnnouncementService.EVENT_ANNC_UPDATE_AVAILABILITY.equals(eventName) && (isDraftMessage || isFutureMessage))) {

// remove user notifications
try {
Expand All @@ -135,8 +132,9 @@ public Optional<List<UserNotificationData>> handleEvent(Event event) {
eventQuery.where(
queryBuilder.and(
queryBuilder.or(
queryBuilder.equal(eventQueryTable.get("event"), ADD_EVENT),
queryBuilder.equal(eventQueryTable.get("event"), UPDATE_EVENT))),
queryBuilder.equal(eventQueryTable.get("event"), AnnouncementService.SECURE_ANNC_ADD),
queryBuilder.equal(eventQueryTable.get("event"), AnnouncementService.EVENT_AVAILABLE_ANNC),
queryBuilder.equal(eventQueryTable.get("event"), AnnouncementService.EVENT_ANNC_UPDATE_AVAILABILITY))),
queryBuilder.equal(eventQueryTable.get("ref"), eventResource));
session.createQuery(eventQuery).list().forEach(session::detach);

Expand All @@ -146,8 +144,9 @@ public Optional<List<UserNotificationData>> handleEvent(Event event) {
eventDeleteQuery.where(
queryBuilder.and(
queryBuilder.or(
queryBuilder.equal(eventDeleteQueryTable.get("event"), ADD_EVENT),
queryBuilder.equal(eventDeleteQueryTable.get("event"), UPDATE_EVENT))),
queryBuilder.equal(eventQueryTable.get("event"), AnnouncementService.SECURE_ANNC_ADD),
queryBuilder.equal(eventQueryTable.get("event"), AnnouncementService.EVENT_AVAILABLE_ANNC),
queryBuilder.equal(eventQueryTable.get("event"), AnnouncementService.EVENT_ANNC_UPDATE_AVAILABILITY))),
queryBuilder.equal(eventDeleteQueryTable.get("ref"), eventResource));
session.createQuery(eventDeleteQuery).executeUpdate();
});
Expand Down

0 comments on commit 37c917e

Please sign in to comment.