This commit is contained in:
Athou
2026-02-18 16:03:43 +01:00
parent 77bb948bf2
commit 2be61e8b1c
73 changed files with 1691 additions and 1556 deletions

View File

@@ -52,4 +52,7 @@ public class ServerInfo implements Serializable {
@Schema(required = true)
private int minimumPasswordLength;
@Schema(required = true)
private boolean pushNotificationsEnabled;
}

View File

@@ -5,6 +5,7 @@ import java.io.Serializable;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import com.commafeed.backend.model.UserSettings.IconDisplayMode;
import com.commafeed.backend.model.UserSettings.PushNotificationType;
import com.commafeed.backend.model.UserSettings.ReadingMode;
import com.commafeed.backend.model.UserSettings.ReadingOrder;
import com.commafeed.backend.model.UserSettings.ScrollMode;
@@ -81,28 +82,25 @@ public class Settings implements Serializable {
@Schema(description = "sharing settings", required = true)
private SharingSettings sharingSettings = new SharingSettings();
@Schema(description = "notification settings", required = true)
private NotificationSettings notificationSettings = new NotificationSettings();
@Schema(description = "push notification settings", required = true)
private PushNotificationSettings pushNotificationSettings = new PushNotificationSettings();
@Schema(description = "User notification settings")
@Data
public static class NotificationSettings implements Serializable {
@Schema(required = true)
private boolean enabled;
@Schema(description = "notification provider type: ntfy, gotify, or pushover")
private String type;
public static class PushNotificationSettings implements Serializable {
@Schema(description = "notification provider type")
private PushNotificationType type;
@Schema(description = "server URL for ntfy or gotify")
private String serverUrl;
@Schema(description = "API token for gotify or pushover")
private String token;
@Schema(description = "user Id")
private String userId;
@Schema(description = "user key for pushover")
private String userKey;
@Schema(description = "user secret for authentication with the service")
private String userSecret;
@Schema(description = "topic for ntfy")
@Schema(description = "topic")
private String topic;
}

View File

@@ -65,8 +65,8 @@ public class Subscription implements Serializable {
@Schema(description = "JEXL legacy filter")
private String filterLegacy;
@Schema(description = "whether to send notifications for new entries of this feed", required = true)
private boolean notifyOnNewEntries;
@Schema(description = "whether to send push notifications for new entries of this feed", required = true)
private boolean pushNotificationsEnabled;
public static Subscription build(FeedSubscription subscription, UnreadCount unreadCount) {
FeedCategory category = subscription.getCategory();
@@ -88,7 +88,7 @@ public class Subscription implements Serializable {
sub.setCategoryId(category == null ? null : String.valueOf(category.getId()));
sub.setFilter(subscription.getFilter());
sub.setFilterLegacy(subscription.getFilterLegacy());
sub.setNotifyOnNewEntries(subscription.isNotifyOnNewEntries());
sub.setPushNotificationsEnabled(subscription.isPushNotificationsEnabled());
return sub;
}

View File

@@ -31,7 +31,7 @@ public class FeedModificationRequest implements Serializable {
@Size(max = 4096)
private String filter;
@Schema(description = "whether to send notifications for new entries of this feed")
private Boolean notifyOnNewEntries;
@Schema(description = "whether to send push notifications for new entries of this feed")
private boolean pushNotificationsEnabled;
}

View File

@@ -28,7 +28,7 @@ public class SubscribeRequest implements Serializable {
@Size(max = 128)
private String categoryId;
@Schema(description = "whether to send notifications for new entries of this feed")
private boolean notifyOnNewEntries = true;
@Schema(description = "whether to send push notifications for new entries of this feed")
private boolean pushNotificationsEnabled;
}

View File

@@ -366,7 +366,7 @@ public class FeedREST {
FeedInfo info = fetchFeedInternal(prependHttp(req.getUrl()));
User user = authenticationContext.getCurrentUser();
long subscriptionId = feedSubscriptionService.subscribe(user, info.getUrl(), req.getTitle(), category, 0,
req.isNotifyOnNewEntries());
req.isPushNotificationsEnabled());
return Response.ok(subscriptionId).build();
} catch (Exception e) {
log.error("Failed to subscribe to URL {}: {}", req.getUrl(), e.getMessage(), e);
@@ -385,7 +385,7 @@ public class FeedREST {
Preconditions.checkNotNull(url);
FeedInfo info = fetchFeedInternal(prependHttp(url));
User user = authenticationContext.getCurrentUser();
feedSubscriptionService.subscribe(user, info.getUrl(), info.getTitle(), null, 0, true);
feedSubscriptionService.subscribe(user, info.getUrl(), info.getTitle(), null, 0, false);
} catch (Exception e) {
log.info("Could not subscribe to url {} : {}", url, e.getMessage());
}
@@ -439,9 +439,7 @@ public class FeedREST {
subscription.setFilterLegacy(null);
}
if (req.getNotifyOnNewEntries() != null) {
subscription.setNotifyOnNewEntries(req.getNotifyOnNewEntries());
}
subscription.setPushNotificationsEnabled(req.isPushNotificationsEnabled());
if (StringUtils.isNotBlank(req.getName())) {
subscription.setTitle(req.getName());

View File

@@ -62,6 +62,7 @@ public class ServerREST {
infos.setForceRefreshCooldownDuration(config.feedRefresh().forceRefreshCooldownDuration().toMillis());
infos.setInitialSetupRequired(databaseStartupService.isInitialSetupRequired());
infos.setMinimumPasswordLength(config.users().minimumPasswordLength());
infos.setPushNotificationsEnabled(config.pushNotifications().enabled());
return infos;
}

View File

@@ -43,7 +43,6 @@ import com.commafeed.backend.model.UserRole;
import com.commafeed.backend.model.UserRole.Role;
import com.commafeed.backend.model.UserSettings;
import com.commafeed.backend.model.UserSettings.IconDisplayMode;
import com.commafeed.backend.model.UserSettings.NotificationType;
import com.commafeed.backend.model.UserSettings.ReadingMode;
import com.commafeed.backend.model.UserSettings.ReadingOrder;
import com.commafeed.backend.model.UserSettings.ScrollMode;
@@ -127,14 +126,11 @@ public class UserREST {
s.setDisablePullToRefresh(settings.isDisablePullToRefresh());
s.setPrimaryColor(settings.getPrimaryColor());
s.getNotificationSettings().setEnabled(settings.isNotificationEnabled());
if (settings.getNotificationType() != null) {
s.getNotificationSettings().setType(settings.getNotificationType().name().toLowerCase());
}
s.getNotificationSettings().setServerUrl(settings.getNotificationServerUrl());
s.getNotificationSettings().setToken(settings.getNotificationToken());
s.getNotificationSettings().setUserKey(settings.getNotificationUserKey());
s.getNotificationSettings().setTopic(settings.getNotificationTopic());
s.getPushNotificationSettings().setType(settings.getPushNotificationType());
s.getPushNotificationSettings().setServerUrl(settings.getPushNotificationServerUrl());
s.getPushNotificationSettings().setUserId(settings.getPushNotificationUserId());
s.getPushNotificationSettings().setUserSecret(settings.getPushNotificationUserSecret());
s.getPushNotificationSettings().setTopic(settings.getPushNotificationTopic());
} else {
s.setReadingMode(ReadingMode.UNREAD);
s.setReadingOrder(ReadingOrder.DESC);
@@ -200,16 +196,11 @@ public class UserREST {
s.setDisablePullToRefresh(settings.isDisablePullToRefresh());
s.setPrimaryColor(settings.getPrimaryColor());
s.setNotificationEnabled(settings.getNotificationSettings().isEnabled());
if (settings.getNotificationSettings().getType() != null) {
s.setNotificationType(NotificationType.valueOf(settings.getNotificationSettings().getType().toUpperCase()));
} else {
s.setNotificationType(null);
}
s.setNotificationServerUrl(settings.getNotificationSettings().getServerUrl());
s.setNotificationToken(settings.getNotificationSettings().getToken());
s.setNotificationUserKey(settings.getNotificationSettings().getUserKey());
s.setNotificationTopic(settings.getNotificationSettings().getTopic());
s.setPushNotificationType(settings.getPushNotificationSettings().getType());
s.setPushNotificationServerUrl(settings.getPushNotificationSettings().getServerUrl());
s.setPushNotificationUserId(settings.getPushNotificationSettings().getUserId());
s.setPushNotificationUserSecret(settings.getPushNotificationSettings().getUserSecret());
s.setPushNotificationTopic(settings.getPushNotificationSettings().getTopic());
s.setEmail(settings.getSharingSettings().isEmail());
s.setGmail(settings.getSharingSettings().isGmail());