mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
upgrade feed url from http to https if able
This commit is contained in:
@@ -164,6 +164,14 @@ public class FeedUtils {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static boolean isHttp(String url) {
|
||||
return url.startsWith("http://");
|
||||
}
|
||||
|
||||
public static boolean isHttps(String url) {
|
||||
return url.startsWith("https://");
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the url. The resulting url is not meant to be fetched but rather used as a mean to identify a feed and avoid duplicates
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.cache.CacheService;
|
||||
import com.commafeed.backend.dao.FeedDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||
import com.commafeed.backend.feed.FeedQueues;
|
||||
@@ -37,6 +38,7 @@ public class FeedSubscriptionService {
|
||||
}
|
||||
}
|
||||
|
||||
private final FeedDAO feedDAO;
|
||||
private final FeedEntryStatusDAO feedEntryStatusDAO;
|
||||
private final FeedSubscriptionDAO feedSubscriptionDAO;
|
||||
private final FeedService feedService;
|
||||
@@ -64,6 +66,12 @@ public class FeedSubscriptionService {
|
||||
|
||||
Feed feed = feedService.findOrCreate(url);
|
||||
|
||||
// upgrade feed to https if it was using http
|
||||
if (FeedUtils.isHttp(feed.getUrl()) && FeedUtils.isHttps(url)) {
|
||||
feed.setUrl(url);
|
||||
feedDAO.saveOrUpdate(feed);
|
||||
}
|
||||
|
||||
FeedSubscription sub = feedSubscriptionDAO.findByFeed(user, feed);
|
||||
if (sub == null) {
|
||||
sub = new FeedSubscription();
|
||||
|
||||
Reference in New Issue
Block a user