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:
Torsten Grote
2016-08-09 19:39:57 -03:00
parent 84d4bf2205
commit caee7fe61b
7 changed files with 433 additions and 70 deletions

View File

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

View File

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

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