use of io.lumeer.engine.api.event.CreateOrUpdateUserNotification in project engine by Lumeer.
the class MongoUserNotificationDao method updateNotifications.
@Override
public void updateNotifications(final String searchField, final String searchId, final Map<String, String> updates) {
final List<Bson> sets = updates.entrySet().stream().map(e -> Updates.set(e.getKey(), e.getValue())).collect(Collectors.toList());
final UpdateResult result = databaseCollection().updateMany(Filters.eq(searchField, searchId), Updates.combine(sets));
if (result.getModifiedCount() > 0 && createOrUpdateUserNotificationEvent != null) {
final List<UserNotification> updatedNotifications = databaseCollection().find(Filters.eq(searchField, searchId)).into(new ArrayList<>());
updatedNotifications.forEach(notification -> createOrUpdateUserNotificationEvent.fire(new CreateOrUpdateUserNotification(notification)));
}
}
use of io.lumeer.engine.api.event.CreateOrUpdateUserNotification in project engine by Lumeer.
the class PusherFacade method createUserNotification.
public void createUserNotification(@Observes final CreateOrUpdateUserNotification createOrUpdateUserNotification) {
if (isEnabled()) {
try {
UserNotification notification = createOrUpdateUserNotification.getUserNotification();
Event event = createEventForObject(notification, CREATE_EVENT_SUFFIX, notification.getUserId());
sendNotificationsBatch(Collections.singletonList(event));
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
Aggregations