Search in sources :

Example 1 with RemoveUserNotification

use of io.lumeer.engine.api.event.RemoveUserNotification in project engine by Lumeer.

the class MongoUserNotificationDao method removeNotifications.

@Override
public void removeNotifications(final String searchField, final String searchId, final Set<String> users) {
    Bson filter = createRemoveNotificationsFilter(searchField, searchId, users);
    final List<UserNotification> deletedNotifications = databaseCollection().find(filter).into(new ArrayList<>());
    final DeleteResult result = databaseCollection().deleteMany(filter);
    if (result.getDeletedCount() > 0 && removeUserNotificationEvent != null) {
        deletedNotifications.forEach(notification -> removeUserNotificationEvent.fire(new RemoveUserNotification(notification)));
    }
}
Also used : RemoveUserNotification(io.lumeer.engine.api.event.RemoveUserNotification) UserNotification(io.lumeer.api.model.UserNotification) CreateOrUpdateUserNotification(io.lumeer.engine.api.event.CreateOrUpdateUserNotification) RemoveUserNotification(io.lumeer.engine.api.event.RemoveUserNotification) DeleteResult(com.mongodb.client.result.DeleteResult) Bson(org.bson.conversions.Bson)

Example 2 with RemoveUserNotification

use of io.lumeer.engine.api.event.RemoveUserNotification in project engine by Lumeer.

the class PusherFacade method removeUserNotification.

public void removeUserNotification(@Observes final RemoveUserNotification removeUserNotification) {
    if (isEnabled()) {
        try {
            UserNotification notification = removeUserNotification.getUserNotification();
            Event event = createEventForRemove(notification.getClass().getSimpleName(), new ResourceId(getAppId(), notification.getId()), notification.getUserId());
            sendNotificationsBatch(Collections.singletonList(event));
        } catch (Exception e) {
            log.log(Level.WARNING, "Unable to send push notification: ", e);
        }
    }
}
Also used : CreateOrUpdateUserNotification(io.lumeer.engine.api.event.CreateOrUpdateUserNotification) RemoveUserNotification(io.lumeer.engine.api.event.RemoveUserNotification) UserNotification(io.lumeer.api.model.UserNotification) OrganizationUserEvent(io.lumeer.engine.api.event.OrganizationUserEvent) ResourceVariableEvent(io.lumeer.engine.api.event.ResourceVariableEvent) SelectionListEvent(io.lumeer.engine.api.event.SelectionListEvent) Event(org.marvec.pusher.data.Event)

Aggregations

UserNotification (io.lumeer.api.model.UserNotification)2 CreateOrUpdateUserNotification (io.lumeer.engine.api.event.CreateOrUpdateUserNotification)2 RemoveUserNotification (io.lumeer.engine.api.event.RemoveUserNotification)2 DeleteResult (com.mongodb.client.result.DeleteResult)1 OrganizationUserEvent (io.lumeer.engine.api.event.OrganizationUserEvent)1 ResourceVariableEvent (io.lumeer.engine.api.event.ResourceVariableEvent)1 SelectionListEvent (io.lumeer.engine.api.event.SelectionListEvent)1 Bson (org.bson.conversions.Bson)1 Event (org.marvec.pusher.data.Event)1