Store additional properties of RSS feed in metadata.

This commit is contained in:
akwizgran
2022-12-09 17:57:20 +00:00
parent 1a2f85f701
commit b920382e44
9 changed files with 146 additions and 55 deletions

View File

@@ -5,47 +5,27 @@ import org.briarproject.bramble.api.sync.GroupId;
import org.briarproject.briar.api.blog.Blog;
import org.briarproject.nullsafety.NotNullByDefault;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
@Immutable
@NotNullByDefault
public class Feed implements Comparable<Feed> {
private final String url;
private final Blog blog;
private final LocalAuthor localAuthor;
@Nullable
private final String description, rssAuthor;
private final RssProperties properties;
private final long added, updated, lastEntryTime;
public Feed(String url, Blog blog, LocalAuthor localAuthor,
@Nullable String description, @Nullable String rssAuthor,
public Feed(Blog blog, LocalAuthor localAuthor, RssProperties properties,
long added, long updated, long lastEntryTime) {
this.url = url;
this.blog = blog;
this.localAuthor = localAuthor;
this.description = description;
this.rssAuthor = rssAuthor;
this.properties = properties;
this.added = added;
this.updated = updated;
this.lastEntryTime = lastEntryTime;
}
public Feed(String url, Blog blog, LocalAuthor localAuthor,
@Nullable String description, @Nullable String rssAuthor,
long added) {
this(url, blog, localAuthor, description, rssAuthor, added, 0L, 0L);
}
public Feed(String url, Blog blog, LocalAuthor localAuthor, long added) {
this(url, blog, localAuthor, null, null, added, 0L, 0L);
}
public String getUrl() {
return url;
}
public GroupId getBlogId() {
return blog.getId();
}
@@ -62,14 +42,8 @@ public class Feed implements Comparable<Feed> {
return blog.getName();
}
@Nullable
public String getDescription() {
return description;
}
@Nullable
public String getRssAuthor() {
return rssAuthor;
public RssProperties getProperties() {
return properties;
}
public long getAdded() {
@@ -103,4 +77,8 @@ public class Feed implements Comparable<Feed> {
return 0;
}
@Override
public int hashCode() {
return blog.hashCode();
}
}

View File

@@ -22,6 +22,9 @@ public interface FeedConstants {
String KEY_FEED_PRIVATE_KEY = "feedPrivateKey";
String KEY_FEED_DESC = "feedDesc";
String KEY_FEED_RSS_AUTHOR = "feedRssAuthor";
String KEY_FEED_RSS_TITLE = "feedRssTitle";
String KEY_FEED_RSS_LINK = "feedRssLink";
String KEY_FEED_RSS_URI = "feedRssUri";
String KEY_FEED_ADDED = "feedAdded";
String KEY_FEED_UPDATED = "feedUpdated";
String KEY_FEED_LAST_ENTRY = "feedLastEntryTime";

View File

@@ -0,0 +1,86 @@
package org.briarproject.briar.api.feed;
import org.briarproject.nullsafety.NotNullByDefault;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
/**
* The properties of an RSS feed, which may have been imported from a URL
* or a file.
*/
@Immutable
@NotNullByDefault
public class RssProperties {
@Nullable
private final String url, title, description, author, link, uri;
public RssProperties(@Nullable String url, @Nullable String title,
@Nullable String description, @Nullable String author,
@Nullable String link, @Nullable String uri) {
this.url = url;
this.title = title;
this.description = description;
this.author = author;
this.link = link;
this.uri = uri;
}
/**
* Returns the URL from which the RSS feed was imported, or null if the
* feed was imported from a file.
*/
@Nullable
public String getUrl() {
return url;
}
/**
* Returns the title property of the RSS feed, or null if no title was
* specified.
*/
@Nullable
public String getTitle() {
return title;
}
/**
* Returns the description property of the RSS feed, or null if no
* description was specified.
*/
@Nullable
public String getDescription() {
return description;
}
/**
* Returns the author property of the RSS feed, or null if no author was
* specified.
*/
@Nullable
public String getAuthor() {
return author;
}
/**
* Returns the link property of the RSS feed, or null if no link was
* specified. This is usually the URL of a webpage where the equivalent
* content can be viewed in a browser.
*/
@Nullable
public String getLink() {
return link;
}
/**
* Returns the URI property of the RSS feed, or null if no URI was
* specified. This may be a URL from which the feed can be downloaded,
* or it may be an opaque identifier such as a number that serves to
* distinguish this feed from other feeds produced by the same creator.
*/
@Nullable
public String getUri() {
return uri;
}
}