mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Ensure that attachment has expected group ID when loading.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.briar.api.attachment;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@@ -9,14 +10,21 @@ import javax.annotation.concurrent.Immutable;
|
||||
@NotNullByDefault
|
||||
public class AttachmentHeader {
|
||||
|
||||
private final GroupId groupId;
|
||||
private final MessageId messageId;
|
||||
private final String contentType;
|
||||
|
||||
public AttachmentHeader(MessageId messageId, String contentType) {
|
||||
public AttachmentHeader(GroupId groupId, MessageId messageId,
|
||||
String contentType) {
|
||||
this.groupId = groupId;
|
||||
this.messageId = messageId;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public MessageId getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
@@ -27,13 +35,15 @@ public class AttachmentHeader {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof AttachmentHeader &&
|
||||
messageId.equals(((AttachmentHeader) o).messageId);
|
||||
if (o instanceof AttachmentHeader) {
|
||||
AttachmentHeader h = (AttachmentHeader) o;
|
||||
return groupId.equals(h.groupId) && messageId.equals(h.messageId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return messageId.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.briar.api.identity;
|
||||
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||
@@ -17,7 +18,8 @@ public class AuthorInfoTest extends BrambleTestCase {
|
||||
|
||||
private final String contentType = getRandomString(MAX_CONTENT_TYPE_BYTES);
|
||||
private final AttachmentHeader avatarHeader =
|
||||
new AttachmentHeader(new MessageId(getRandomId()), contentType);
|
||||
new AttachmentHeader(new GroupId(getRandomId()),
|
||||
new MessageId(getRandomId()), contentType);
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
|
||||
Reference in New Issue
Block a user