mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Store and expose time a blog post was received
This is useful when sorting blog posts in the combined feed. It ensures you do not miss older posts that were just synced to you.
This commit is contained in:
@@ -32,6 +32,7 @@ public interface BlogConstants {
|
||||
String KEY_DESCRIPTION = "description";
|
||||
String KEY_TITLE = "title";
|
||||
String KEY_TIMESTAMP = "timestamp";
|
||||
String KEY_TIME_RECEIVED = "timeReceived";
|
||||
String KEY_PARENT = "parent";
|
||||
String KEY_AUTHOR_ID = "id";
|
||||
String KEY_AUTHOR_NAME = "name";
|
||||
|
||||
@@ -11,18 +11,25 @@ public class BlogPostHeader extends PostHeader {
|
||||
|
||||
@Nullable
|
||||
private final String title;
|
||||
private final long timeReceived;
|
||||
|
||||
public BlogPostHeader(@Nullable String title, @NotNull MessageId id,
|
||||
@Nullable MessageId parentId, long timestamp,
|
||||
@Nullable MessageId parentId, long timestamp, long timeReceived,
|
||||
@NotNull Author author, @NotNull Status authorStatus,
|
||||
@NotNull String contentType, boolean read) {
|
||||
super(id, parentId, timestamp, author, authorStatus, contentType, read);
|
||||
|
||||
this.title = title;
|
||||
this.timeReceived = timeReceived;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public long getTimeReceived() {
|
||||
return timeReceived;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import static org.briarproject.api.blogs.BlogConstants.KEY_PARENT;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_PUBLIC_KEY;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_READ;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_TIMESTAMP;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_TIME_RECEIVED;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_TITLE;
|
||||
import static org.briarproject.api.contact.ContactManager.AddContactHook;
|
||||
import static org.briarproject.api.contact.ContactManager.RemoveContactHook;
|
||||
@@ -376,6 +377,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
|
||||
String title = meta.getOptionalString(KEY_TITLE);
|
||||
long timestamp = meta.getLong(KEY_TIMESTAMP);
|
||||
long timeReceived = meta.getLong(KEY_TIME_RECEIVED, timestamp);
|
||||
MessageId parentId = null;
|
||||
if (meta.containsKey(KEY_PARENT))
|
||||
parentId = new MessageId(meta.getRaw(KEY_PARENT));
|
||||
@@ -394,7 +396,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
|
||||
String contentType = meta.getString(KEY_CONTENT_TYPE);
|
||||
boolean read = meta.getBoolean(KEY_READ);
|
||||
return new BlogPostHeader(title, id, parentId, timestamp, author,
|
||||
authorStatus, contentType, read);
|
||||
return new BlogPostHeader(title, id, parentId, timestamp, timeReceived,
|
||||
author, authorStatus, contentType, read);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import static org.briarproject.api.blogs.BlogConstants.KEY_PARENT;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_PUBLIC_KEY;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_READ;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_TIMESTAMP;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_TIME_RECEIVED;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_TITLE;
|
||||
import static org.briarproject.api.blogs.BlogConstants.MAX_BLOG_POST_BODY_LENGTH;
|
||||
import static org.briarproject.api.blogs.BlogConstants.MAX_BLOG_POST_TITLE_LENGTH;
|
||||
@@ -119,6 +120,7 @@ class BlogPostValidator extends BdfMessageValidator {
|
||||
);
|
||||
meta.put(KEY_AUTHOR, author);
|
||||
meta.put(KEY_TIMESTAMP, m.getTimestamp());
|
||||
meta.put(KEY_TIME_RECEIVED, clock.currentTimeMillis());
|
||||
if (parent != null) {
|
||||
meta.put(KEY_PARENT, parent);
|
||||
dependencies = Collections.singletonList(new MessageId(parent));
|
||||
|
||||
Reference in New Issue
Block a user