Backend for Automatic Personal Blogs

When a contact is added, her personal blog will also be added automatically.
Also, when a new identity is added, a personal blog for that identity is created.

Part of #436
This commit is contained in:
Torsten Grote
2016-06-21 17:00:13 -03:00
parent 30fe9f6e2a
commit a8f51fcb8a
8 changed files with 135 additions and 11 deletions

View File

@@ -11,13 +11,16 @@ public class Blog extends Forum {
private final String description;
@NotNull
private final Author author;
private final boolean permanent;
public Blog(@NotNull Group group, @NotNull String name,
@NotNull String description, @NotNull Author author) {
@NotNull String description, @NotNull Author author,
boolean permanent) {
super(group, name, null);
this.description = description;
this.author = author;
this.permanent = permanent;
}
@NotNull
@@ -29,4 +32,8 @@ public class Blog extends Forum {
public Author getAuthor() {
return author;
}
public boolean isPermanent() {
return permanent;
}
}

View File

@@ -19,6 +19,9 @@ public interface BlogConstants {
/** The maximum length of a blog post's body in bytes. */
int MAX_BLOG_POST_BODY_LENGTH = MAX_MESSAGE_BODY_LENGTH - 1024;
/** The internal name of personal blogs that are created automatically */
String PERSONAL_BLOG_NAME = "briar.PERSONAL_BLOG_NAME";
/* Blog Sharing Constants */
String BLOG_TITLE = "blogTitle";
String BLOG_DESC = "blogDescription";

View File

@@ -1,6 +1,7 @@
package org.briarproject.api.blogs;
import org.briarproject.api.FormatException;
import org.briarproject.api.contact.Contact;
import org.briarproject.api.identity.Author;
import org.briarproject.api.sync.Group;
import org.jetbrains.annotations.NotNull;
@@ -11,6 +12,9 @@ public interface BlogFactory {
Blog createBlog(@NotNull String name, @NotNull String description,
@NotNull Author author);
/** Creates a personal blog for a given author. */
Blog createPersonalBlog(@NotNull Author author);
/** Parses a blog with the given Group and description */
Blog parseBlog(@NotNull Group g, @NotNull String description)
throws FormatException;

View File

@@ -2,6 +2,7 @@ package org.briarproject.api.blogs;
import org.briarproject.api.db.DbException;
import org.briarproject.api.db.Transaction;
import org.briarproject.api.identity.Author;
import org.briarproject.api.identity.LocalAuthor;
import org.briarproject.api.sync.ClientId;
import org.briarproject.api.sync.GroupId;
@@ -31,9 +32,12 @@ public interface BlogManager {
/** Returns the blog with the given ID. */
Blog getBlog(Transaction txn, GroupId g) throws DbException;
/** Returns all blogs to which the localAuthor created. */
/** Returns all blogs owned by the given localAuthor. */
Collection<Blog> getBlogs(LocalAuthor localAuthor) throws DbException;
/** Returns only the personal blog of the given author. */
Blog getPersonalBlog(Author author) throws DbException;
/** Returns all blogs to which the user subscribes. */
Collection<Blog> getBlogs() throws DbException;