mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Show relevant decline responses in the conversation
* If the user has already declined, we don't show that the other introducee has declined as well. The backend doesn't have that information, so this is compatible with the principle of showing what we know. * If the user has already accepted or hasn't yet responded, we show the decline response in the private conversation with the introducer. If the user hasn't yet responded, we hide the accept/decline buttons in the introduction request message. Messages an introducee receives in a `FINISHED` state are now being ignored and deleted. Closes #295
This commit is contained in:
@@ -12,16 +12,27 @@ public interface ProtocolEngine<A, S, M> {
|
||||
StateUpdate<S, M> onMessageDelivered(S localState, M delivered);
|
||||
|
||||
class StateUpdate<S, M> {
|
||||
public final boolean deleteMessages;
|
||||
public final boolean deleteMessage;
|
||||
public final boolean deleteState;
|
||||
public final S localState;
|
||||
public final List<M> toSend;
|
||||
public final List<Event> toBroadcast;
|
||||
|
||||
public StateUpdate(boolean deleteMessages, boolean deleteState,
|
||||
/**
|
||||
* This class represents an update of the local protocol state.
|
||||
* It only shows how the state should be updated,
|
||||
* but does not carry out the updates on its own.
|
||||
*
|
||||
* @param deleteMessage whether to delete the message that triggered the state update. This will be ignored for {@link ProtocolEngine#onLocalAction}.
|
||||
* @param deleteState whether to delete the localState {@link S}
|
||||
* @param localState the new local state
|
||||
* @param toSend a list of messages to be sent as part of the state update
|
||||
* @param toBroadcast a list of events to broadcast as result of the state update
|
||||
*/
|
||||
public StateUpdate(boolean deleteMessage, boolean deleteState,
|
||||
S localState, List<M> toSend, List<Event> toBroadcast) {
|
||||
|
||||
this.deleteMessages = deleteMessages;
|
||||
this.deleteMessage = deleteMessage;
|
||||
this.deleteState = deleteState;
|
||||
this.localState = localState;
|
||||
this.toSend = toSend;
|
||||
|
||||
@@ -2,19 +2,24 @@ package org.briarproject.api.introduction;
|
||||
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import static org.briarproject.api.introduction.IntroductionConstants.ROLE_INTRODUCEE;
|
||||
import static org.briarproject.api.introduction.IntroductionConstants.ROLE_INTRODUCER;
|
||||
|
||||
abstract public class IntroductionMessage {
|
||||
|
||||
private final SessionId sessionId;
|
||||
private final MessageId messageId;
|
||||
private final int role;
|
||||
private final long time;
|
||||
private final boolean local, sent, seen, read;
|
||||
|
||||
public IntroductionMessage(SessionId sessionId, MessageId messageId,
|
||||
long time, boolean local, boolean sent, boolean seen,
|
||||
int role, long time, boolean local, boolean sent, boolean seen,
|
||||
boolean read) {
|
||||
|
||||
this.sessionId = sessionId;
|
||||
this.messageId = messageId;
|
||||
this.role = role;
|
||||
this.time = time;
|
||||
this.local = local;
|
||||
this.sent = sent;
|
||||
@@ -50,5 +55,13 @@ abstract public class IntroductionMessage {
|
||||
return read;
|
||||
}
|
||||
|
||||
public boolean isIntroducer() {
|
||||
return role == ROLE_INTRODUCER;
|
||||
}
|
||||
|
||||
public boolean isIntroducee() {
|
||||
return role == ROLE_INTRODUCEE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,13 @@ public class IntroductionRequest extends IntroductionResponse {
|
||||
private final boolean answered, exists, introducesOtherIdentity;
|
||||
|
||||
public IntroductionRequest(SessionId sessionId, MessageId messageId,
|
||||
long time, boolean local, boolean sent, boolean seen, boolean read,
|
||||
AuthorId authorId, String name, boolean accepted, String message,
|
||||
boolean answered, boolean exists, boolean introducesOtherIdentity) {
|
||||
int role, long time, boolean local, boolean sent, boolean seen,
|
||||
boolean read, AuthorId authorId, String name, boolean accepted,
|
||||
String message, boolean answered, boolean exists,
|
||||
boolean introducesOtherIdentity) {
|
||||
|
||||
super(sessionId, messageId, time, local, sent, seen, read, authorId,
|
||||
name, accepted);
|
||||
super(sessionId, messageId, role, time, local, sent, seen, read,
|
||||
authorId, name, accepted);
|
||||
|
||||
this.message = message;
|
||||
this.answered = answered;
|
||||
|
||||
@@ -10,10 +10,11 @@ public class IntroductionResponse extends IntroductionMessage {
|
||||
private final boolean accepted;
|
||||
|
||||
public IntroductionResponse(SessionId sessionId, MessageId messageId,
|
||||
long time, boolean local, boolean sent, boolean seen, boolean read,
|
||||
AuthorId remoteAuthorId, String name, boolean accepted) {
|
||||
int role, long time, boolean local, boolean sent, boolean seen,
|
||||
boolean read, AuthorId remoteAuthorId, String name,
|
||||
boolean accepted) {
|
||||
|
||||
super(sessionId, messageId, time, local, sent, seen, read);
|
||||
super(sessionId, messageId, role, time, local, sent, seen, read);
|
||||
|
||||
this.remoteAuthorId = remoteAuthorId;
|
||||
this.name = name;
|
||||
@@ -28,4 +29,7 @@ public class IntroductionResponse extends IntroductionMessage {
|
||||
return accepted;
|
||||
}
|
||||
|
||||
public AuthorId getRemoteAuthorId() {
|
||||
return remoteAuthorId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user