Merge branch '1822-rss-feeds-backend' into 'master'

Resolve "Import RSS feeds shared by other apps"

See merge request briar/briar!1763
This commit is contained in:
Torsten Grote
2023-01-25 11:39:34 +00:00
24 changed files with 1176 additions and 291 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> {
public class 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() {
@@ -95,12 +69,7 @@ public class Feed implements Comparable<Feed> {
}
@Override
public int compareTo(Feed o) {
if (this == o) return 0;
long aTime = getAdded(), bTime = o.getAdded();
if (aTime > bTime) return -1;
if (aTime < bTime) return 1;
return 0;
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

@@ -6,6 +6,7 @@ import org.briarproject.bramble.api.sync.ClientId;
import org.briarproject.nullsafety.NotNullByDefault;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@NotNullByDefault
@@ -22,10 +23,17 @@ public interface FeedManager {
int MAJOR_VERSION = 0;
/**
* Adds an RSS feed as a new dedicated blog.
* Adds an RSS feed as a new dedicated blog, or updates the existing blog
* if a blog for the feed already exists.
*/
Feed addFeed(String url) throws DbException, IOException;
/**
* Adds an RSS feed as a new dedicated blog, or updates the existing blog
* if a blog for the feed already exists.
*/
Feed addFeed(InputStream in) throws DbException, IOException;
/**
* Removes an RSS feed.
*/

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;
}
}