mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Validate New Messages for Reblogging and Comments of Blog Posts
Also includes unit tests for the new message types. Closes #591
This commit is contained in:
@@ -29,16 +29,19 @@ public interface BlogConstants {
|
||||
String BLOG_PUBLIC_KEY = "blogPublicKey";
|
||||
|
||||
// Metadata keys
|
||||
String KEY_TYPE = "type";
|
||||
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";
|
||||
String KEY_PUBLIC_KEY = "publicKey";
|
||||
String KEY_AUTHOR = "author";
|
||||
String KEY_CONTENT_TYPE = "contentType";
|
||||
String KEY_READ = "read";
|
||||
String KEY_COMMENT = "comment";
|
||||
String KEY_ORIGINAL_MSG_ID = "originalMessageId";
|
||||
String KEY_CURRENT_MSG_ID = "currentMessageId";
|
||||
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ public class BlogPostHeader extends PostHeader {
|
||||
private final long timeReceived;
|
||||
|
||||
public BlogPostHeader(@Nullable String title, @NotNull MessageId id,
|
||||
@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);
|
||||
long timestamp, long timeReceived, @NotNull Author author,
|
||||
@NotNull Status authorStatus, @NotNull String contentType,
|
||||
boolean read) {
|
||||
super(id, null, timestamp, author, authorStatus, contentType, read);
|
||||
|
||||
this.title = title;
|
||||
this.timeReceived = timeReceived;
|
||||
|
||||
33
briar-api/src/org/briarproject/api/blogs/MessageType.java
Normal file
33
briar-api/src/org/briarproject/api/blogs/MessageType.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package org.briarproject.api.blogs;
|
||||
|
||||
public enum MessageType {
|
||||
POST(0),
|
||||
COMMENT(1),
|
||||
WRAPPED_POST(2),
|
||||
WRAPPED_COMMENT(3);
|
||||
|
||||
int value;
|
||||
|
||||
MessageType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static MessageType valueOf(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return POST;
|
||||
case 1:
|
||||
return COMMENT;
|
||||
case 2:
|
||||
return WRAPPED_POST;
|
||||
case 3:
|
||||
return WRAPPED_COMMENT;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public int getInt() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user