Update message parsing and encoding to include auto-delete timer.

This commit is contained in:
akwizgran
2020-11-19 17:26:52 +00:00
committed by Torsten Grote
parent 7b16e78470
commit c8d1ee878c
27 changed files with 454 additions and 136 deletions

View File

@@ -12,18 +12,20 @@ public abstract class ConversationMessageHeader {
private final MessageId id;
private final GroupId groupId;
private final long timestamp;
private final boolean local, sent, seen, read;
private final long timestamp, autoDeleteTimer;
private final boolean local, read, sent, seen;
public ConversationMessageHeader(MessageId id, GroupId groupId, long timestamp,
boolean local, boolean read, boolean sent, boolean seen) {
public ConversationMessageHeader(MessageId id, GroupId groupId,
long timestamp, boolean local, boolean read, boolean sent,
boolean seen, long autoDeleteTimer) {
this.id = id;
this.groupId = groupId;
this.timestamp = timestamp;
this.local = local;
this.read = read;
this.sent = sent;
this.seen = seen;
this.read = read;
this.autoDeleteTimer = autoDeleteTimer;
}
public MessageId getId() {
@@ -55,4 +57,8 @@ public abstract class ConversationMessageHeader {
}
public abstract <T> T accept(ConversationMessageVisitor<T> v);
public long getAutoDeleteTimer() {
return autoDeleteTimer;
}
}

View File

@@ -20,11 +20,12 @@ public abstract class ConversationRequest<N extends Nameable>
private final String text;
private final boolean answered;
public ConversationRequest(MessageId messageId, GroupId groupId, long time,
boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, N nameable, @Nullable String text,
boolean answered) {
super(messageId, groupId, time, local, read, sent, seen);
public ConversationRequest(MessageId messageId, GroupId groupId,
long timestamp, boolean local, boolean read, boolean sent,
boolean seen, SessionId sessionId, N nameable,
@Nullable String text, boolean answered, long autoDeleteTimer) {
super(messageId, groupId, timestamp, local, read, sent, seen,
autoDeleteTimer);
this.sessionId = sessionId;
this.nameable = nameable;
this.text = text;

View File

@@ -16,8 +16,8 @@ public abstract class ConversationResponse extends ConversationMessageHeader {
public ConversationResponse(MessageId id, GroupId groupId, long time,
boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accepted) {
super(id, groupId, time, local, read, sent, seen);
SessionId sessionId, boolean accepted, long autoDeleteTimer) {
super(id, groupId, time, local, read, sent, seen, autoDeleteTimer);
this.sessionId = sessionId;
this.accepted = accepted;
}

View File

@@ -18,12 +18,12 @@ public class IntroductionRequest extends ConversationRequest<Author> {
private final AuthorInfo authorInfo;
public IntroductionRequest(MessageId messageId, GroupId groupId,
long time, boolean local, boolean read, boolean sent, boolean seen,
public IntroductionRequest(MessageId messageId, GroupId groupId, long time,
boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, Author author, @Nullable String text,
boolean answered, AuthorInfo authorInfo) {
boolean answered, AuthorInfo authorInfo, long autoDeleteTimer) {
super(messageId, groupId, time, local, read, sent, seen, sessionId,
author, text, answered);
author, text, answered, autoDeleteTimer);
this.authorInfo = authorInfo;
}

View File

@@ -25,9 +25,10 @@ public class IntroductionResponse extends ConversationResponse {
public IntroductionResponse(MessageId messageId, GroupId groupId, long time,
boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accepted, Author author,
AuthorInfo introducedAuthorInfo, Role role, boolean canSucceed) {
AuthorInfo introducedAuthorInfo, Role role, boolean canSucceed,
long autoDeleteTimer) {
super(messageId, groupId, time, local, read, sent, seen, sessionId,
accepted);
accepted, autoDeleteTimer);
this.introducedAuthor = author;
this.introducedAuthorInfo = introducedAuthorInfo;
this.ourRole = role;

View File

@@ -17,16 +17,14 @@ public class PrivateMessageHeader extends ConversationMessageHeader {
private final boolean hasText;
private final List<AttachmentHeader> attachmentHeaders;
private final long autoDeleteTimer;
public PrivateMessageHeader(MessageId id, GroupId groupId, long timestamp,
boolean local, boolean read, boolean sent, boolean seen,
boolean hasText, List<AttachmentHeader> headers,
long autoDeleteTimer) {
super(id, groupId, timestamp, local, read, sent, seen);
super(id, groupId, timestamp, local, read, sent, seen, autoDeleteTimer);
this.hasText = hasText;
this.attachmentHeaders = headers;
this.autoDeleteTimer = autoDeleteTimer;
}
public boolean hasText() {
@@ -37,10 +35,6 @@ public class PrivateMessageHeader extends ConversationMessageHeader {
return attachmentHeaders;
}
public long getAutoDeleteTimer() {
return autoDeleteTimer;
}
@Override
public <T> T accept(ConversationMessageVisitor<T> v) {
return v.visitPrivateMessageHeader(this);

View File

@@ -7,6 +7,8 @@ import org.briarproject.briar.api.conversation.ConversationRequest;
import javax.annotation.Nullable;
import static org.briarproject.bramble.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
public abstract class InvitationRequest<S extends Shareable> extends
ConversationRequest<S> {
@@ -17,7 +19,7 @@ public abstract class InvitationRequest<S extends Shareable> extends
SessionId sessionId, S object, @Nullable String text,
boolean available, boolean canBeOpened) {
super(messageId, groupId, time, local, read, sent, seen, sessionId,
object, text, !available);
object, text, !available, NO_AUTO_DELETE_TIMER);
this.canBeOpened = canBeOpened;
}

View File

@@ -5,6 +5,8 @@ import org.briarproject.bramble.api.sync.MessageId;
import org.briarproject.briar.api.client.SessionId;
import org.briarproject.briar.api.conversation.ConversationResponse;
import static org.briarproject.bramble.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
public abstract class InvitationResponse extends ConversationResponse {
private final GroupId shareableId;
@@ -12,7 +14,8 @@ public abstract class InvitationResponse extends ConversationResponse {
public InvitationResponse(MessageId id, GroupId groupId, long time,
boolean local, boolean read, boolean sent, boolean seen,
SessionId sessionId, boolean accepted, GroupId shareableId) {
super(id, groupId, time, local, read, sent, seen, sessionId, accepted);
super(id, groupId, time, local, read, sent, seen, sessionId, accepted,
NO_AUTO_DELETE_TIMER);
this.shareableId = shareableId;
}