notification fixes

This commit is contained in:
Efstratios Giannopoulos 2024-05-13 14:40:19 +03:00
parent 035185d7fb
commit 7947df3a3a
2 changed files with 4 additions and 3 deletions

View File

@ -120,7 +120,7 @@ public class NotificationBuilder extends BaseBuilder<Notification, NotificationE
Map<UUID, User> itemMap;
if (!fields.hasOtherField(this.asIndexer(User._id))) {
itemMap = this.asEmpty(
data.stream().map(NotificationEntity::getUserId).distinct().collect(Collectors.toList()),
data.stream().map(NotificationEntity::getUserId).filter(Objects::nonNull).distinct().collect(Collectors.toList()),
x -> {
User item = new User();
item.setId(x);
@ -129,7 +129,7 @@ public class NotificationBuilder extends BaseBuilder<Notification, NotificationE
User::getId);
} else {
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id);
UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(NotificationEntity::getUserId).distinct().collect(Collectors.toList()));
UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().map(NotificationEntity::getUserId).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId);
}
if (!fields.hasField(User._id)) {

View File

@ -158,6 +158,7 @@ public class NotificationServiceImpl implements NotificationService {
}
private List<NotificationContactType> orderContactTypesFromPreferences(NotificationEntity notification) {
if (notification.getUserId() == null) return null;
Ordering ordering = new Ordering();
ordering.addAscending(UserNotificationPreference._ordinal);
UserNotificationPreferenceQuery query = this.queryFactory.query(UserNotificationPreferenceQuery.class).userId(notification.getUserId()).type(notification.getType()).isActives(IsActive.Active);
@ -175,7 +176,7 @@ public class NotificationServiceImpl implements NotificationService {
}
private List<NotificationContactType> orderContactTypes(NotificationEntity notification) {
List<NotificationContactType> contactTypes = this.channelResolutionService.resolve(notification.getType(), notification.getUserId());
List<NotificationContactType> contactTypes = notification.getUserId() == null ? this.channelResolutionService.resolve(notification.getType()): this.channelResolutionService.resolve(notification.getType(), notification.getUserId());
if (notification.getContactTypeHint() == null) return contactTypes;
List<NotificationContactType> ordered = new ArrayList<>(Collections.singleton(notification.getContactTypeHint()));