mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Change Blog Paradigm to Short-Form
Removes teaser and makes body mandatory. It also adds support for deleting blogs and introduces a getAuthorStatus() method to the IdentityManager that takes a running transaction.
This commit is contained in:
@@ -16,9 +16,6 @@ public interface BlogConstants {
|
||||
/** The length of a blog post's title in UTF-8 bytes. */
|
||||
int MAX_BLOG_POST_TITLE_LENGTH = 100;
|
||||
|
||||
/** The length of a blog post's teaser in UTF-8 bytes. */
|
||||
int MAX_BLOG_POST_TEASER_LENGTH = 240;
|
||||
|
||||
/** The maximum length of a blog post's body in bytes. */
|
||||
int MAX_BLOG_POST_BODY_LENGTH = MAX_MESSAGE_BODY_LENGTH - 1024;
|
||||
|
||||
@@ -31,8 +28,6 @@ public interface BlogConstants {
|
||||
// Metadata keys
|
||||
String KEY_DESCRIPTION = "description";
|
||||
String KEY_TITLE = "title";
|
||||
String KEY_TEASER = "teaser";
|
||||
String KEY_HAS_BODY = "hasBody";
|
||||
String KEY_TIMESTAMP = "timestamp";
|
||||
String KEY_PARENT = "parent";
|
||||
String KEY_AUTHOR_ID = "id";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.api.blogs;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
@@ -20,6 +19,9 @@ public interface BlogManager {
|
||||
Blog addBlog(LocalAuthor localAuthor, String name, String description)
|
||||
throws DbException;
|
||||
|
||||
/** Removes and deletes a blog. */
|
||||
void removeBlog(Blog b) throws DbException;
|
||||
|
||||
/** Stores a local blog post. */
|
||||
void addLocalPost(BlogPost p) throws DbException;
|
||||
|
||||
@@ -45,4 +47,11 @@ public interface BlogManager {
|
||||
/** Marks a blog post as read or unread. */
|
||||
void setReadFlag(MessageId m, boolean read) throws DbException;
|
||||
|
||||
/** Registers a hook to be called whenever a blog is removed. */
|
||||
void registerRemoveBlogHook(RemoveBlogHook hook);
|
||||
|
||||
interface RemoveBlogHook {
|
||||
void removingBlog(Transaction txn, Blog b) throws DbException;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,43 +1,27 @@
|
||||
package org.briarproject.api.blogs;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import org.briarproject.api.forum.ForumPost;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BlogPost extends ForumPost {
|
||||
|
||||
@Nullable
|
||||
private final String title;
|
||||
@NotNull
|
||||
private final String teaser;
|
||||
private final boolean hasBody;
|
||||
|
||||
public BlogPost(@Nullable String title, @NotNull String teaser,
|
||||
boolean hasBody, @NotNull Message message,
|
||||
@Nullable MessageId parent, @NotNull Author author,
|
||||
public BlogPost(@Nullable String title, @NotNull Message message,
|
||||
@Nullable MessageId parent, @NotNull Author author,
|
||||
@NotNull String contentType) {
|
||||
super(message, parent, author, contentType);
|
||||
|
||||
this.title = title;
|
||||
this.teaser = teaser;
|
||||
this.hasBody = hasBody;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTeaser() {
|
||||
return teaser;
|
||||
}
|
||||
|
||||
public boolean hasBody() {
|
||||
return hasBody;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import java.security.GeneralSecurityException;
|
||||
public interface BlogPostFactory {
|
||||
|
||||
BlogPost createBlogPost(@NotNull GroupId groupId, @Nullable String title,
|
||||
@NotNull String teaser, long timestamp, @Nullable MessageId parent,
|
||||
long timestamp, @Nullable MessageId parent,
|
||||
@NotNull LocalAuthor author, @NotNull String contentType,
|
||||
@Nullable byte[] body)
|
||||
@NotNull byte[] body)
|
||||
throws FormatException, GeneralSecurityException;
|
||||
}
|
||||
|
||||
@@ -11,33 +11,18 @@ public class BlogPostHeader extends PostHeader {
|
||||
|
||||
@Nullable
|
||||
private final String title;
|
||||
@NotNull
|
||||
private final String teaser;
|
||||
private final boolean hasBody;
|
||||
|
||||
public BlogPostHeader(@Nullable String title, @NotNull String teaser,
|
||||
boolean hasBody, @NotNull MessageId id,
|
||||
public BlogPostHeader(@Nullable String title, @NotNull MessageId id,
|
||||
@Nullable MessageId parentId, long timestamp,
|
||||
@NotNull Author author, @NotNull Status authorStatus,
|
||||
@NotNull String contentType, boolean read) {
|
||||
super(id, parentId, timestamp, author, authorStatus, contentType, read);
|
||||
|
||||
this.title = title;
|
||||
this.teaser = teaser;
|
||||
this.hasBody = hasBody;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTeaser() {
|
||||
return teaser;
|
||||
}
|
||||
|
||||
public boolean hasBody() {
|
||||
return hasBody;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.briarproject.api.event;
|
||||
|
||||
import org.briarproject.api.blogs.BlogPostHeader;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
/** An event that is broadcast when a blog post was added to the database. */
|
||||
public class BlogPostAddedEvent extends Event {
|
||||
|
||||
private final GroupId groupId;
|
||||
private final BlogPostHeader header;
|
||||
private final boolean local;
|
||||
|
||||
public BlogPostAddedEvent(GroupId groupId, BlogPostHeader header,
|
||||
boolean local) {
|
||||
|
||||
this.groupId = groupId;
|
||||
this.header = header;
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public BlogPostHeader getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return local;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,9 @@ public interface IdentityManager {
|
||||
/** Returns the trust-level status of the author */
|
||||
Status getAuthorStatus(AuthorId a) throws DbException;
|
||||
|
||||
/** Returns the trust-level status of the author */
|
||||
Status getAuthorStatus(Transaction txn, AuthorId a) throws DbException;
|
||||
|
||||
interface AddIdentityHook {
|
||||
void addingIdentity(Transaction txn, LocalAuthor a) throws DbException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user