2014-08-08 16:49:02 +02:00
|
|
|
package com.commafeed;
|
|
|
|
|
|
2024-01-09 14:53:13 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
2024-01-08 20:42:45 +01:00
|
|
|
import java.time.Instant;
|
|
|
|
|
import java.time.temporal.ChronoUnit;
|
2024-01-09 14:53:13 +01:00
|
|
|
import java.util.Properties;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2014-09-22 09:51:55 +02:00
|
|
|
import com.commafeed.backend.cache.RedisPoolFactory;
|
2019-04-22 20:30:06 +02:00
|
|
|
import com.commafeed.frontend.session.SessionHandlerFactory;
|
2014-08-08 16:49:02 +02:00
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
|
|
2023-12-17 14:11:15 +01:00
|
|
|
import io.dropwizard.core.Configuration;
|
2019-04-22 20:30:06 +02:00
|
|
|
import io.dropwizard.db.DataSourceFactory;
|
2023-12-21 20:27:30 +01:00
|
|
|
import io.dropwizard.util.Duration;
|
2023-12-17 14:11:15 +01:00
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
import jakarta.validation.constraints.Min;
|
|
|
|
|
import jakarta.validation.constraints.NotBlank;
|
|
|
|
|
import jakarta.validation.constraints.NotNull;
|
|
|
|
|
import jakarta.validation.constraints.Positive;
|
2019-04-22 20:30:06 +02:00
|
|
|
import lombok.Getter;
|
2023-05-30 10:53:28 +02:00
|
|
|
import lombok.Setter;
|
2019-04-22 20:30:06 +02:00
|
|
|
|
2014-08-08 16:49:02 +02:00
|
|
|
@Getter
|
2023-05-30 10:53:28 +02:00
|
|
|
@Setter
|
2024-01-15 09:53:52 +01:00
|
|
|
public class CommaFeedConfiguration extends Configuration {
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2022-01-02 20:55:46 +01:00
|
|
|
public enum CacheType {
|
2014-08-09 13:26:03 +02:00
|
|
|
NOOP, REDIS
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-08 16:49:02 +02:00
|
|
|
@Valid
|
|
|
|
|
@NotNull
|
|
|
|
|
@JsonProperty("database")
|
2022-01-02 20:55:46 +01:00
|
|
|
private final DataSourceFactory dataSourceFactory = new DataSourceFactory();
|
2014-09-22 09:51:55 +02:00
|
|
|
|
|
|
|
|
@Valid
|
|
|
|
|
@NotNull
|
|
|
|
|
@JsonProperty("redis")
|
2022-01-02 20:55:46 +01:00
|
|
|
private final RedisPoolFactory redisPoolFactory = new RedisPoolFactory();
|
2014-09-22 09:51:55 +02:00
|
|
|
|
2014-08-18 13:09:54 +02:00
|
|
|
@Valid
|
|
|
|
|
@NotNull
|
|
|
|
|
@JsonProperty("session")
|
2022-01-02 20:55:46 +01:00
|
|
|
private final SessionHandlerFactory sessionHandlerFactory = new SessionHandlerFactory();
|
2014-08-08 16:49:02 +02:00
|
|
|
|
|
|
|
|
@Valid
|
|
|
|
|
@NotNull
|
|
|
|
|
@JsonProperty("app")
|
|
|
|
|
private ApplicationSettings applicationSettings;
|
|
|
|
|
|
2022-11-15 10:48:51 +01:00
|
|
|
private final String version;
|
|
|
|
|
private final String gitCommit;
|
2022-01-02 20:55:46 +01:00
|
|
|
|
|
|
|
|
public CommaFeedConfiguration() {
|
2024-01-09 14:53:13 +01:00
|
|
|
Properties properties = new Properties();
|
|
|
|
|
try (InputStream stream = getClass().getResourceAsStream("/git.properties")) {
|
|
|
|
|
if (stream != null) {
|
|
|
|
|
properties.load(stream);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
2014-08-16 17:27:27 +02:00
|
|
|
|
2024-01-09 14:53:13 +01:00
|
|
|
this.version = properties.getProperty("git.build.version", "unknown");
|
|
|
|
|
this.gitCommit = properties.getProperty("git.commit.id.abbrev", "unknown");
|
2014-08-16 17:27:27 +02:00
|
|
|
}
|
|
|
|
|
|
2014-08-08 16:49:02 +02:00
|
|
|
@Getter
|
2023-05-30 10:53:28 +02:00
|
|
|
@Setter
|
2014-08-08 16:49:02 +02:00
|
|
|
public static class ApplicationSettings {
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@NotBlank
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
2014-08-08 16:49:02 +02:00
|
|
|
private String publicUrl;
|
|
|
|
|
|
2023-06-13 10:47:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Valid
|
|
|
|
|
private Boolean hideFromWebCrawlers = true;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Boolean allowRegistrations;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2023-05-31 07:31:40 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Valid
|
|
|
|
|
private Boolean strictPasswordPolicy = true;
|
|
|
|
|
|
2014-12-04 10:52:41 +01:00
|
|
|
@NotNull
|
|
|
|
|
@Valid
|
|
|
|
|
private Boolean createDemoAccount;
|
2014-11-23 13:27:34 +01:00
|
|
|
|
2014-08-08 16:49:02 +02:00
|
|
|
private String googleAnalyticsTrackingCode;
|
|
|
|
|
|
2015-06-04 12:28:20 +02:00
|
|
|
private String googleAuthKey;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(1)
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Integer backgroundThreads;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(1)
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Integer databaseUpdateThreads;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2023-07-12 15:20:36 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Positive
|
|
|
|
|
@Valid
|
|
|
|
|
private Integer databaseCleanupBatchSize = 100;
|
|
|
|
|
|
2014-08-08 16:49:02 +02:00
|
|
|
private String smtpHost;
|
|
|
|
|
private int smtpPort;
|
|
|
|
|
private boolean smtpTls;
|
|
|
|
|
private String smtpUserName;
|
|
|
|
|
private String smtpPassword;
|
2014-11-07 09:38:55 +01:00
|
|
|
private String smtpFromAddress;
|
|
|
|
|
|
2017-07-05 21:56:00 -05:00
|
|
|
private boolean graphiteEnabled;
|
|
|
|
|
private String graphitePrefix;
|
|
|
|
|
private String graphiteHost;
|
|
|
|
|
private int graphitePort;
|
|
|
|
|
private int graphiteInterval;
|
|
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Boolean heavyLoad;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Boolean imageProxyEnabled;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(0)
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Integer queryTimeout;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(0)
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Integer keepStatusDays;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2014-12-04 10:22:57 +01:00
|
|
|
@NotNull
|
|
|
|
|
@Min(0)
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Integer maxFeedCapacity;
|
2014-12-04 10:22:57 +01:00
|
|
|
|
2024-01-07 20:43:19 +01:00
|
|
|
@NotNull
|
|
|
|
|
@Min(0)
|
|
|
|
|
@Valid
|
|
|
|
|
private Integer maxEntriesAgeDays = 0;
|
|
|
|
|
|
2023-05-30 08:53:26 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Valid
|
2023-05-30 10:53:28 +02:00
|
|
|
private Integer maxFeedsPerUser = 0;
|
2023-05-30 08:53:26 +02:00
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
|
|
|
|
@Min(0)
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
|
|
|
|
private Integer refreshIntervalMinutes;
|
2014-08-08 16:49:02 +02:00
|
|
|
|
2014-08-16 12:40:39 +02:00
|
|
|
@NotNull
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
2014-08-09 13:26:03 +02:00
|
|
|
private CacheType cache;
|
|
|
|
|
|
2014-12-04 10:52:41 +01:00
|
|
|
@Valid
|
2014-08-08 16:49:02 +02:00
|
|
|
private String announcement;
|
|
|
|
|
|
2018-07-31 15:21:45 +02:00
|
|
|
private String userAgent;
|
|
|
|
|
|
2023-12-21 20:27:30 +01:00
|
|
|
private Boolean websocketEnabled = true;
|
|
|
|
|
|
|
|
|
|
private Duration websocketPingInterval = Duration.minutes(15);
|
|
|
|
|
|
|
|
|
|
private Duration treeReloadInterval = Duration.seconds(30);
|
|
|
|
|
|
2024-01-08 20:42:45 +01:00
|
|
|
public Instant getUnreadThreshold() {
|
|
|
|
|
return getKeepStatusDays() > 0 ? Instant.now().minus(getKeepStatusDays(), ChronoUnit.DAYS) : null;
|
2014-08-08 16:49:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|