mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
more config checks on startup
This commit is contained in:
@@ -7,6 +7,9 @@ app:
|
|||||||
# wether to allow user registrations
|
# wether to allow user registrations
|
||||||
allowRegistrations: false
|
allowRegistrations: false
|
||||||
|
|
||||||
|
# create a demo account the first time the app starts
|
||||||
|
createDemoAccount: false
|
||||||
|
|
||||||
# put your google analytics tracking code here
|
# put your google analytics tracking code here
|
||||||
googleAnalyticsTrackingCode:
|
googleAnalyticsTrackingCode:
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ app:
|
|||||||
# wether to allow user registrations
|
# wether to allow user registrations
|
||||||
allowRegistrations: true
|
allowRegistrations: true
|
||||||
|
|
||||||
|
# create a demo account the first time the app starts
|
||||||
|
createDemoAccount: false
|
||||||
|
|
||||||
# put your google analytics tracking code here
|
# put your google analytics tracking code here
|
||||||
googleAnalyticsTrackingCode:
|
googleAnalyticsTrackingCode:
|
||||||
|
|
||||||
|
|||||||
@@ -64,64 +64,74 @@ public class CommaFeedConfiguration extends Configuration {
|
|||||||
public static class ApplicationSettings {
|
public static class ApplicationSettings {
|
||||||
@NotNull
|
@NotNull
|
||||||
@NotBlank
|
@NotBlank
|
||||||
|
@Valid
|
||||||
private String publicUrl;
|
private String publicUrl;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private boolean allowRegistrations;
|
@Valid
|
||||||
|
private Boolean allowRegistrations;
|
||||||
|
|
||||||
private boolean createDemoAccount;
|
@NotNull
|
||||||
|
@Valid
|
||||||
|
private Boolean createDemoAccount;
|
||||||
|
|
||||||
private String googleAnalyticsTrackingCode;
|
private String googleAnalyticsTrackingCode;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(1)
|
@Min(1)
|
||||||
private int backgroundThreads;
|
@Valid
|
||||||
|
private Integer backgroundThreads;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(1)
|
@Min(1)
|
||||||
private int databaseUpdateThreads;
|
@Valid
|
||||||
|
private Integer databaseUpdateThreads;
|
||||||
|
|
||||||
private String smtpHost;
|
private String smtpHost;
|
||||||
|
|
||||||
private int smtpPort;
|
private int smtpPort;
|
||||||
|
|
||||||
private boolean smtpTls;
|
private boolean smtpTls;
|
||||||
|
|
||||||
private String smtpUserName;
|
private String smtpUserName;
|
||||||
|
|
||||||
private String smtpPassword;
|
private String smtpPassword;
|
||||||
|
|
||||||
private String smtpFromAddress;
|
private String smtpFromAddress;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private boolean heavyLoad;
|
@Valid
|
||||||
|
private Boolean heavyLoad;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private boolean pubsubhubbub;
|
@Valid
|
||||||
|
private Boolean pubsubhubbub;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private boolean imageProxyEnabled;
|
@Valid
|
||||||
|
private Boolean imageProxyEnabled;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(0)
|
@Min(0)
|
||||||
private int queryTimeout;
|
@Valid
|
||||||
|
private Integer queryTimeout;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(0)
|
@Min(0)
|
||||||
private int keepStatusDays;
|
@Valid
|
||||||
|
private Integer keepStatusDays;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(0)
|
@Min(0)
|
||||||
private int maxFeedCapacity;
|
@Valid
|
||||||
|
private Integer maxFeedCapacity;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(0)
|
@Min(0)
|
||||||
private int refreshIntervalMinutes;
|
@Valid
|
||||||
|
private Integer refreshIntervalMinutes;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Valid
|
||||||
private CacheType cache;
|
private CacheType cache;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Valid
|
||||||
private String announcement;
|
private String announcement;
|
||||||
|
|
||||||
public Date getUnreadThreshold() {
|
public Date getUnreadThreshold() {
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class FeedQueues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Date getLastLoginThreshold() {
|
private Date getLastLoginThreshold() {
|
||||||
if (config.getApplicationSettings().isHeavyLoad()) {
|
if (config.getApplicationSettings().getHeavyLoad()) {
|
||||||
return DateUtils.addDays(new Date(), -30);
|
return DateUtils.addDays(new Date(), -30);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class FeedRefreshUpdater implements Managed {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getApplicationSettings().isPubsubhubbub()) {
|
if (config.getApplicationSettings().getPubsubhubbub()) {
|
||||||
handlePubSub(feed);
|
handlePubSub(feed);
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class FeedRefreshWorker implements Managed {
|
|||||||
// stops here if NotModifiedException or any other exception is thrown
|
// stops here if NotModifiedException or any other exception is thrown
|
||||||
List<FeedEntry> entries = fetchedFeed.getEntries();
|
List<FeedEntry> entries = fetchedFeed.getEntries();
|
||||||
|
|
||||||
if (config.getApplicationSettings().isHeavyLoad()) {
|
if (config.getApplicationSettings().getHeavyLoad()) {
|
||||||
disabledUntil = FeedUtils.buildDisabledUntil(fetchedFeed.getFeed().getLastEntryDate(), fetchedFeed.getFeed()
|
disabledUntil = FeedUtils.buildDisabledUntil(fetchedFeed.getFeed().getLastEntryDate(), fetchedFeed.getFeed()
|
||||||
.getAverageEntryInterval(), disabledUntil);
|
.getAverageEntryInterval(), disabledUntil);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ public class FeedRefreshWorker implements Managed {
|
|||||||
} catch (NotModifiedException e) {
|
} catch (NotModifiedException e) {
|
||||||
log.debug("Feed not modified : {} - {}", feed.getUrl(), e.getMessage());
|
log.debug("Feed not modified : {} - {}", feed.getUrl(), e.getMessage());
|
||||||
|
|
||||||
if (config.getApplicationSettings().isHeavyLoad()) {
|
if (config.getApplicationSettings().getHeavyLoad()) {
|
||||||
disabledUntil = FeedUtils.buildDisabledUntil(feed.getLastEntryDate(), feed.getAverageEntryInterval(), disabledUntil);
|
disabledUntil = FeedUtils.buildDisabledUntil(feed.getLastEntryDate(), feed.getAverageEntryInterval(), disabledUntil);
|
||||||
}
|
}
|
||||||
feed.setErrorCount(0);
|
feed.setErrorCount(0);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class StartupService implements Managed {
|
|||||||
try {
|
try {
|
||||||
userService.register(CommaFeedApplication.USERNAME_ADMIN, "admin", "admin@commafeed.com", Arrays.asList(Role.ADMIN, Role.USER),
|
userService.register(CommaFeedApplication.USERNAME_ADMIN, "admin", "admin@commafeed.com", Arrays.asList(Role.ADMIN, Role.USER),
|
||||||
true);
|
true);
|
||||||
if (config.getApplicationSettings().isCreateDemoAccount()) {
|
if (config.getApplicationSettings().getCreateDemoAccount()) {
|
||||||
userService.register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true);
|
userService.register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class UserService {
|
|||||||
Preconditions.checkNotNull(password);
|
Preconditions.checkNotNull(password);
|
||||||
|
|
||||||
if (!forceRegistration) {
|
if (!forceRegistration) {
|
||||||
Preconditions.checkState(config.getApplicationSettings().isAllowRegistrations(),
|
Preconditions.checkState(config.getApplicationSettings().getAllowRegistrations(),
|
||||||
"Registrations are closed on this CommaFeed instance");
|
"Registrations are closed on this CommaFeed instance");
|
||||||
|
|
||||||
Preconditions.checkNotNull(email);
|
Preconditions.checkNotNull(email);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class PostLoginActivities {
|
|||||||
user.setLastLogin(now);
|
user.setLastLogin(now);
|
||||||
saveUser = true;
|
saveUser = true;
|
||||||
}
|
}
|
||||||
if (config.getApplicationSettings().isHeavyLoad() && user.shouldRefreshFeedsAt(now)) {
|
if (config.getApplicationSettings().getHeavyLoad() && user.shouldRefreshFeedsAt(now)) {
|
||||||
feedSubscriptionService.refreshAll(user);
|
feedSubscriptionService.refreshAll(user);
|
||||||
user.setLastFullRefresh(now);
|
user.setLastFullRefresh(now);
|
||||||
saveUser = true;
|
saveUser = true;
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class CategoryREST {
|
|||||||
for (FeedEntryStatus status : list) {
|
for (FeedEntryStatus status : list) {
|
||||||
entries.getEntries().add(
|
entries.getEntries().add(
|
||||||
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
|
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
|
||||||
.isImageProxyEnabled()));
|
.getImageProxyEnabled()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (STARRED.equals(id)) {
|
} else if (STARRED.equals(id)) {
|
||||||
@@ -152,7 +152,7 @@ public class CategoryREST {
|
|||||||
for (FeedEntryStatus status : starred) {
|
for (FeedEntryStatus status : starred) {
|
||||||
entries.getEntries().add(
|
entries.getEntries().add(
|
||||||
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
|
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
|
||||||
.isImageProxyEnabled()));
|
.getImageProxyEnabled()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FeedCategory parent = feedCategoryDAO.findById(user, Long.valueOf(id));
|
FeedCategory parent = feedCategoryDAO.findById(user, Long.valueOf(id));
|
||||||
@@ -166,7 +166,7 @@ public class CategoryREST {
|
|||||||
for (FeedEntryStatus status : list) {
|
for (FeedEntryStatus status : list) {
|
||||||
entries.getEntries().add(
|
entries.getEntries().add(
|
||||||
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
|
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
|
||||||
.isImageProxyEnabled()));
|
.getImageProxyEnabled()));
|
||||||
}
|
}
|
||||||
entries.setName(parent.getName());
|
entries.setName(parent.getName());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ public class FeedREST {
|
|||||||
for (FeedEntryStatus status : list) {
|
for (FeedEntryStatus status : list) {
|
||||||
entries.getEntries().add(
|
entries.getEntries().add(
|
||||||
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
|
Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
|
||||||
.isImageProxyEnabled()));
|
.getImageProxyEnabled()));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasMore = entries.getEntries().size() > limit;
|
boolean hasMore = entries.getEntries().size() > limit;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class PubSubHubbubCallbackREST {
|
|||||||
public Response verify(@QueryParam("hub.mode") String mode, @QueryParam("hub.topic") String topic,
|
public Response verify(@QueryParam("hub.mode") String mode, @QueryParam("hub.topic") String topic,
|
||||||
@QueryParam("hub.challenge") String challenge, @QueryParam("hub.lease_seconds") String leaseSeconds,
|
@QueryParam("hub.challenge") String challenge, @QueryParam("hub.lease_seconds") String leaseSeconds,
|
||||||
@QueryParam("hub.verify_token") String verifyToken) {
|
@QueryParam("hub.verify_token") String verifyToken) {
|
||||||
if (!config.getApplicationSettings().isPubsubhubbub()) {
|
if (!config.getApplicationSettings().getPubsubhubbub()) {
|
||||||
return Response.status(Status.FORBIDDEN).entity("pubsubhubbub is disabled").build();
|
return Response.status(Status.FORBIDDEN).entity("pubsubhubbub is disabled").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class PubSubHubbubCallbackREST {
|
|||||||
@Consumes({ MediaType.APPLICATION_ATOM_XML, "application/rss+xml" })
|
@Consumes({ MediaType.APPLICATION_ATOM_XML, "application/rss+xml" })
|
||||||
public Response callback() {
|
public Response callback() {
|
||||||
|
|
||||||
if (!config.getApplicationSettings().isPubsubhubbub()) {
|
if (!config.getApplicationSettings().getPubsubhubbub()) {
|
||||||
return Response.status(Status.FORBIDDEN).entity("pubsubhubbub is disabled").build();
|
return Response.status(Status.FORBIDDEN).entity("pubsubhubbub is disabled").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class ServerREST {
|
|||||||
infos.setAnnouncement(config.getApplicationSettings().getAnnouncement());
|
infos.setAnnouncement(config.getApplicationSettings().getAnnouncement());
|
||||||
infos.setVersion(config.getVersion());
|
infos.setVersion(config.getVersion());
|
||||||
infos.setGitCommit(config.getGitCommit());
|
infos.setGitCommit(config.getGitCommit());
|
||||||
infos.setAllowRegistrations(config.getApplicationSettings().isAllowRegistrations());
|
infos.setAllowRegistrations(config.getApplicationSettings().getAllowRegistrations());
|
||||||
infos.setGoogleAnalyticsCode(config.getApplicationSettings().getGoogleAnalyticsTrackingCode());
|
infos.setGoogleAnalyticsCode(config.getApplicationSettings().getGoogleAnalyticsTrackingCode());
|
||||||
infos.setSmtpEnabled(StringUtils.isNotBlank(config.getApplicationSettings().getSmtpHost()));
|
infos.setSmtpEnabled(StringUtils.isNotBlank(config.getApplicationSettings().getSmtpHost()));
|
||||||
return Response.ok(infos).build();
|
return Response.ok(infos).build();
|
||||||
@@ -59,7 +59,7 @@ public class ServerREST {
|
|||||||
@ApiOperation(value = "proxy image")
|
@ApiOperation(value = "proxy image")
|
||||||
@Produces("image/png")
|
@Produces("image/png")
|
||||||
public Response get(@SecurityCheck User user, @QueryParam("u") String url) {
|
public Response get(@SecurityCheck User user, @QueryParam("u") String url) {
|
||||||
if (!config.getApplicationSettings().isImageProxyEnabled()) {
|
if (!config.getApplicationSettings().getImageProxyEnabled()) {
|
||||||
return Response.status(Status.FORBIDDEN).build();
|
return Response.status(Status.FORBIDDEN).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user