mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 22:59:54 +01:00
Remove unnecessary information from private message classes
This commit is contained in:
@@ -36,7 +36,6 @@ import org.briarproject.briar.android.fragment.BaseFragment;
|
|||||||
import org.briarproject.briar.android.keyagreement.ContactExchangeActivity;
|
import org.briarproject.briar.android.keyagreement.ContactExchangeActivity;
|
||||||
import org.briarproject.briar.android.view.BriarRecyclerView;
|
import org.briarproject.briar.android.view.BriarRecyclerView;
|
||||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||||
import org.briarproject.briar.api.client.BaseMessageHeader;
|
|
||||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||||
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
||||||
import org.briarproject.briar.api.introduction.IntroductionResponse;
|
import org.briarproject.briar.api.introduction.IntroductionResponse;
|
||||||
@@ -283,7 +282,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateItem(ContactId c, BaseMessageHeader h) {
|
private void updateItem(ContactId c, PrivateMessageHeader h) {
|
||||||
runOnUiThreadUnlessDestroyed(() -> {
|
runOnUiThreadUnlessDestroyed(() -> {
|
||||||
adapter.incrementRevision();
|
adapter.incrementRevision();
|
||||||
int position = adapter.findItemPosition(c);
|
int position = adapter.findItemPosition(c);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.briarproject.briar.R;
|
|||||||
import org.briarproject.briar.android.contact.ConversationRequestItem.RequestType;
|
import org.briarproject.briar.android.contact.ConversationRequestItem.RequestType;
|
||||||
import org.briarproject.briar.api.blog.BlogInvitationRequest;
|
import org.briarproject.briar.api.blog.BlogInvitationRequest;
|
||||||
import org.briarproject.briar.api.blog.BlogInvitationResponse;
|
import org.briarproject.briar.api.blog.BlogInvitationResponse;
|
||||||
import org.briarproject.briar.api.client.BaseMessageHeader;
|
|
||||||
import org.briarproject.briar.api.forum.ForumInvitationRequest;
|
import org.briarproject.briar.api.forum.ForumInvitationRequest;
|
||||||
import org.briarproject.briar.api.forum.ForumInvitationResponse;
|
import org.briarproject.briar.api.forum.ForumInvitationResponse;
|
||||||
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
import org.briarproject.briar.api.introduction.IntroductionRequest;
|
||||||
@@ -92,7 +91,7 @@ abstract class ConversationItem {
|
|||||||
if (ir.isLocal()) {
|
if (ir.isLocal()) {
|
||||||
String text = ctx.getString(R.string.introduction_request_sent,
|
String text = ctx.getString(R.string.introduction_request_sent,
|
||||||
contactName, ir.getName());
|
contactName, ir.getName());
|
||||||
return new ConversationNoticeOutItem(ir.getMessageId(),
|
return new ConversationNoticeOutItem(ir.getId(),
|
||||||
ir.getGroupId(), text, ir.getMessage(), ir.getTimestamp(),
|
ir.getGroupId(), text, ir.getMessage(), ir.getTimestamp(),
|
||||||
ir.isSent(), ir.isSeen());
|
ir.isSent(), ir.isSeen());
|
||||||
} else {
|
} else {
|
||||||
@@ -109,7 +108,7 @@ abstract class ConversationItem {
|
|||||||
text = ctx.getString(R.string.introduction_request_received,
|
text = ctx.getString(R.string.introduction_request_received,
|
||||||
contactName, ir.getName());
|
contactName, ir.getName());
|
||||||
}
|
}
|
||||||
return new ConversationRequestItem(ir.getMessageId(),
|
return new ConversationRequestItem(ir.getId(),
|
||||||
ir.getGroupId(), INTRODUCTION, ir.getSessionId(), text,
|
ir.getGroupId(), INTRODUCTION, ir.getSessionId(), text,
|
||||||
ir.getMessage(), ir.getTimestamp(), ir.isRead(), null,
|
ir.getMessage(), ir.getTimestamp(), ir.isRead(), null,
|
||||||
ir.wasAnswered(), false);
|
ir.wasAnswered(), false);
|
||||||
@@ -132,9 +131,8 @@ abstract class ConversationItem {
|
|||||||
R.string.introduction_response_declined_sent,
|
R.string.introduction_response_declined_sent,
|
||||||
ir.getName());
|
ir.getName());
|
||||||
}
|
}
|
||||||
return new ConversationNoticeOutItem(ir.getMessageId(),
|
return new ConversationNoticeOutItem(ir.getId(), ir.getGroupId(),
|
||||||
ir.getGroupId(), text, null, ir.getTimestamp(), ir.isSent(),
|
text, null, ir.getTimestamp(), ir.isSent(), ir.isSeen());
|
||||||
ir.isSeen());
|
|
||||||
} else {
|
} else {
|
||||||
String text;
|
String text;
|
||||||
if (ir.wasAccepted()) {
|
if (ir.wasAccepted()) {
|
||||||
@@ -152,9 +150,8 @@ abstract class ConversationItem {
|
|||||||
contactName, ir.getName());
|
contactName, ir.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ConversationNoticeInItem(ir.getMessageId(),
|
return new ConversationNoticeInItem(ir.getId(), ir.getGroupId(),
|
||||||
ir.getGroupId(), text, null, ir.getTimestamp(),
|
text, null, ir.getTimestamp(), ir.isRead());
|
||||||
ir.isRead());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,12 +269,10 @@ abstract class ConversationItem {
|
|||||||
/**
|
/**
|
||||||
* This method should not be used to display the resulting ConversationItem
|
* This method should not be used to display the resulting ConversationItem
|
||||||
* in the UI, but only to update list information based on the
|
* in the UI, but only to update list information based on the
|
||||||
* BaseMessageHeader.
|
* PrivateMessageHeader.
|
||||||
**/
|
**/
|
||||||
static ConversationItem from(Context ctx, BaseMessageHeader h) {
|
static ConversationItem from(Context ctx, PrivateMessageHeader h) {
|
||||||
if (h instanceof PrivateMessageHeader) {
|
if(h instanceof IntroductionRequest) {
|
||||||
return from((PrivateMessageHeader) h);
|
|
||||||
} else if(h instanceof IntroductionRequest) {
|
|
||||||
return from(ctx, "", (IntroductionRequest) h);
|
return from(ctx, "", (IntroductionRequest) h);
|
||||||
} else if(h instanceof IntroductionResponse) {
|
} else if(h instanceof IntroductionResponse) {
|
||||||
return from(ctx, "", (IntroductionResponse) h);
|
return from(ctx, "", (IntroductionResponse) h);
|
||||||
@@ -286,7 +281,7 @@ abstract class ConversationItem {
|
|||||||
} else if(h instanceof InvitationResponse) {
|
} else if(h instanceof InvitationResponse) {
|
||||||
return from(ctx, "", (InvitationResponse) h);
|
return from(ctx, "", (InvitationResponse) h);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown message header");
|
return from(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class ForumControllerImpl extends
|
|||||||
(ForumInvitationResponse) f.getResponse();
|
(ForumInvitationResponse) f.getResponse();
|
||||||
if (r.getShareableId().equals(getGroupId()) && r.wasAccepted()) {
|
if (r.getShareableId().equals(getGroupId()) && r.wasAccepted()) {
|
||||||
LOG.info("Forum invitation was accepted");
|
LOG.info("Forum invitation was accepted");
|
||||||
onForumInvitationAccepted(r.getContactId());
|
onForumInvitationAccepted(f.getContactId());
|
||||||
}
|
}
|
||||||
} else if (e instanceof ContactLeftShareableEvent) {
|
} else if (e instanceof ContactLeftShareableEvent) {
|
||||||
ContactLeftShareableEvent c = (ContactLeftShareableEvent) e;
|
ContactLeftShareableEvent c = (ContactLeftShareableEvent) e;
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class GroupControllerImpl extends
|
|||||||
(GroupInvitationResponse) g.getResponse();
|
(GroupInvitationResponse) g.getResponse();
|
||||||
if (getGroupId().equals(r.getShareableId()) && r.wasAccepted()) {
|
if (getGroupId().equals(r.getShareableId()) && r.wasAccepted()) {
|
||||||
listener.runOnUiThreadUnlessDestroyed(
|
listener.runOnUiThreadUnlessDestroyed(
|
||||||
() -> listener.onInvitationAccepted(r.getContactId()));
|
() -> listener.onInvitationAccepted(g.getContactId()));
|
||||||
}
|
}
|
||||||
} else if (e instanceof GroupDissolvedEvent) {
|
} else if (e instanceof GroupDissolvedEvent) {
|
||||||
GroupDissolvedEvent g = (GroupDissolvedEvent) e;
|
GroupDissolvedEvent g = (GroupDissolvedEvent) e;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class BlogInvitationRequest extends InvitationRequest<Blog> {
|
|||||||
SessionId sessionId, Blog blog, ContactId contactId,
|
SessionId sessionId, Blog blog, ContactId contactId,
|
||||||
@Nullable String message, boolean available, boolean canBeOpened) {
|
@Nullable String message, boolean available, boolean canBeOpened) {
|
||||||
super(id, groupId, time, local, sent, seen, read, sessionId, blog,
|
super(id, groupId, time, local, sent, seen, read, sessionId, blog,
|
||||||
contactId, message, available, canBeOpened);
|
message, available, canBeOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBlogAuthorName() {
|
public String getBlogAuthorName() {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.briarproject.briar.api.blog;
|
package org.briarproject.briar.api.blog;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
@@ -12,10 +11,9 @@ public class BlogInvitationResponse extends InvitationResponse {
|
|||||||
|
|
||||||
public BlogInvitationResponse(MessageId id, GroupId groupId, long time,
|
public BlogInvitationResponse(MessageId id, GroupId groupId, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read,
|
boolean local, boolean sent, boolean seen, boolean read,
|
||||||
SessionId sessionId, GroupId blogId, ContactId contactId,
|
SessionId sessionId, GroupId blogId, boolean accept) {
|
||||||
boolean accept) {
|
|
||||||
super(id, groupId, time, local, sent, seen, read, sessionId, blogId,
|
super(id, groupId, time, local, sent, seen, read, sessionId, blogId,
|
||||||
contactId, accept);
|
accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
package org.briarproject.briar.api.client;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
@NotNullByDefault
|
|
||||||
public abstract class BaseMessageHeader {
|
|
||||||
|
|
||||||
private final MessageId id;
|
|
||||||
private final GroupId groupId;
|
|
||||||
private final long timestamp;
|
|
||||||
private final boolean local, sent, seen, read;
|
|
||||||
|
|
||||||
public BaseMessageHeader(MessageId id, GroupId groupId, long timestamp,
|
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
|
||||||
|
|
||||||
this.id = id;
|
|
||||||
this.groupId = groupId;
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
this.local = local;
|
|
||||||
this.sent = sent;
|
|
||||||
this.seen = seen;
|
|
||||||
this.read = read;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageId getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GroupId getGroupId() {
|
|
||||||
return groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLocal() {
|
|
||||||
return local;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSent() {
|
|
||||||
return sent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSeen() {
|
|
||||||
return seen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRead() {
|
|
||||||
return read;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@ public class ForumInvitationRequest extends InvitationRequest<Forum> {
|
|||||||
SessionId sessionId, Forum forum, ContactId contactId,
|
SessionId sessionId, Forum forum, ContactId contactId,
|
||||||
@Nullable String message, boolean available, boolean canBeOpened) {
|
@Nullable String message, boolean available, boolean canBeOpened) {
|
||||||
super(id, groupId, time, local, sent, seen, read, sessionId, forum,
|
super(id, groupId, time, local, sent, seen, read, sessionId, forum,
|
||||||
contactId, message, available, canBeOpened);
|
message, available, canBeOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getForumName() {
|
public String getForumName() {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.briarproject.briar.api.forum;
|
package org.briarproject.briar.api.forum;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
@@ -15,10 +14,9 @@ public class ForumInvitationResponse extends InvitationResponse {
|
|||||||
|
|
||||||
public ForumInvitationResponse(MessageId id, GroupId groupId, long time,
|
public ForumInvitationResponse(MessageId id, GroupId groupId, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read,
|
boolean local, boolean sent, boolean seen, boolean read,
|
||||||
SessionId sessionId, GroupId forumId, ContactId contactId,
|
SessionId sessionId, GroupId forumId, boolean accept) {
|
||||||
boolean accept) {
|
|
||||||
super(id, groupId, time, local, sent, seen, read, sessionId, forumId,
|
super(id, groupId, time, local, sent, seen, read, sessionId, forumId,
|
||||||
contactId, accept);
|
accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,26 @@ package org.briarproject.briar.api.introduction;
|
|||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.client.BaseMessageHeader;
|
|
||||||
import org.briarproject.briar.api.client.SessionId;
|
import org.briarproject.briar.api.client.SessionId;
|
||||||
|
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
import static org.briarproject.briar.api.introduction.Role.INTRODUCER;
|
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class IntroductionMessage extends BaseMessageHeader {
|
public abstract class IntroductionMessage extends PrivateMessageHeader {
|
||||||
|
|
||||||
private final SessionId sessionId;
|
private final SessionId sessionId;
|
||||||
private final MessageId messageId;
|
|
||||||
private final Role role;
|
|
||||||
|
|
||||||
IntroductionMessage(SessionId sessionId, MessageId messageId,
|
IntroductionMessage(SessionId sessionId, MessageId messageId,
|
||||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
GroupId groupId, long time, boolean local, boolean sent,
|
||||||
boolean seen, boolean read) {
|
boolean seen, boolean read) {
|
||||||
|
|
||||||
super(messageId, groupId, time, local, sent, seen, read);
|
super(messageId, groupId, time, local, sent, seen, read);
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.messageId = messageId;
|
|
||||||
this.role = role;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionId getSessionId() {
|
public SessionId getSessionId() {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageId getMessageId() {
|
|
||||||
return messageId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIntroducer() {
|
|
||||||
return role == INTRODUCER;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.briarproject.briar.api.introduction;
|
package org.briarproject.briar.api.introduction;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
@@ -10,25 +11,28 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class IntroductionRequest extends IntroductionResponse {
|
public class IntroductionRequest extends IntroductionMessage {
|
||||||
|
|
||||||
|
private final Author introducedAuthor;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String message;
|
private final String message;
|
||||||
private final boolean answered, exists;
|
private final boolean answered, exists;
|
||||||
|
|
||||||
public IntroductionRequest(SessionId sessionId, MessageId messageId,
|
public IntroductionRequest(SessionId sessionId, MessageId messageId,
|
||||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
GroupId groupId, long time, boolean local, boolean sent,
|
||||||
boolean seen, boolean read, String name, boolean accepted,
|
boolean seen, boolean read, Author introducedAuthor,
|
||||||
@Nullable String message, boolean answered, boolean exists) {
|
@Nullable String message, boolean answered, boolean exists) {
|
||||||
|
super(sessionId, messageId, groupId, time, local, sent, seen, read);
|
||||||
super(sessionId, messageId, groupId, role, time, local, sent, seen,
|
this.introducedAuthor = introducedAuthor;
|
||||||
read, name, accepted);
|
|
||||||
|
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.answered = answered;
|
this.answered = answered;
|
||||||
this.exists = exists;
|
this.exists = exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return introducedAuthor.getName();
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
|
|||||||
@@ -7,20 +7,22 @@ import org.briarproject.briar.api.client.SessionId;
|
|||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
|
import static org.briarproject.briar.api.introduction.Role.INTRODUCER;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class IntroductionResponse extends IntroductionMessage {
|
public class IntroductionResponse extends IntroductionMessage {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final Role role;
|
||||||
private final boolean accepted;
|
private final boolean accepted;
|
||||||
|
|
||||||
public IntroductionResponse(SessionId sessionId, MessageId messageId,
|
public IntroductionResponse(SessionId sessionId, MessageId messageId,
|
||||||
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
GroupId groupId, Role role, long time, boolean local, boolean sent,
|
||||||
boolean seen, boolean read, String name, boolean accepted) {
|
boolean seen, boolean read, String name, boolean accepted) {
|
||||||
super(sessionId, messageId, groupId, role, time, local, sent, seen,
|
super(sessionId, messageId, groupId, time, local, sent, seen, read);
|
||||||
read);
|
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.role = role;
|
||||||
this.accepted = accepted;
|
this.accepted = accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,6 +30,10 @@ public class IntroductionResponse extends IntroductionMessage {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIntroducer() {
|
||||||
|
return role == INTRODUCER;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean wasAccepted() {
|
public boolean wasAccepted() {
|
||||||
return accepted;
|
return accepted;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,55 @@ package org.briarproject.briar.api.messaging;
|
|||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.client.BaseMessageHeader;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class PrivateMessageHeader extends BaseMessageHeader {
|
public class PrivateMessageHeader {
|
||||||
|
|
||||||
|
private final MessageId id;
|
||||||
|
private final GroupId groupId;
|
||||||
|
private final long timestamp;
|
||||||
|
private final boolean local, sent, seen, read;
|
||||||
|
|
||||||
public PrivateMessageHeader(MessageId id, GroupId groupId, long timestamp,
|
public PrivateMessageHeader(MessageId id, GroupId groupId, long timestamp,
|
||||||
boolean local, boolean read, boolean sent, boolean seen) {
|
boolean local, boolean read, boolean sent, boolean seen) {
|
||||||
|
this.id = id;
|
||||||
|
this.groupId = groupId;
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.local = local;
|
||||||
|
this.sent = sent;
|
||||||
|
this.seen = seen;
|
||||||
|
this.read = read;
|
||||||
|
}
|
||||||
|
|
||||||
super(id, groupId, timestamp, local, sent, seen, read);
|
public MessageId getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupId getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLocal() {
|
||||||
|
return local;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSent() {
|
||||||
|
return sent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSeen() {
|
||||||
|
return seen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRead() {
|
||||||
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class GroupInvitationRequest extends InvitationRequest<PrivateGroup> {
|
|||||||
SessionId sessionId, PrivateGroup shareable, ContactId contactId,
|
SessionId sessionId, PrivateGroup shareable, ContactId contactId,
|
||||||
@Nullable String message, boolean available, boolean canBeOpened) {
|
@Nullable String message, boolean available, boolean canBeOpened) {
|
||||||
super(id, groupId, time, local, sent, seen, read, sessionId, shareable,
|
super(id, groupId, time, local, sent, seen, read, sessionId, shareable,
|
||||||
contactId, message, available, canBeOpened);
|
message, available, canBeOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.briarproject.briar.api.privategroup.invitation;
|
package org.briarproject.briar.api.privategroup.invitation;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
@@ -15,10 +14,9 @@ public class GroupInvitationResponse extends InvitationResponse {
|
|||||||
|
|
||||||
public GroupInvitationResponse(MessageId id, GroupId groupId, long time,
|
public GroupInvitationResponse(MessageId id, GroupId groupId, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read,
|
boolean local, boolean sent, boolean seen, boolean read,
|
||||||
SessionId sessionId, GroupId shareableId, ContactId contactId,
|
SessionId sessionId, GroupId shareableId, boolean accept) {
|
||||||
boolean accept) {
|
|
||||||
super(id, groupId, time, local, sent, seen, read, sessionId,
|
super(id, groupId, time, local, sent, seen, read, sessionId,
|
||||||
shareableId, contactId, accept);
|
shareableId, accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,28 @@
|
|||||||
package org.briarproject.briar.api.sharing;
|
package org.briarproject.briar.api.sharing;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.client.BaseMessageHeader;
|
|
||||||
import org.briarproject.briar.api.client.SessionId;
|
import org.briarproject.briar.api.client.SessionId;
|
||||||
|
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class InvitationMessage extends BaseMessageHeader {
|
public abstract class InvitationMessage extends PrivateMessageHeader {
|
||||||
|
|
||||||
private final SessionId sessionId;
|
private final SessionId sessionId;
|
||||||
private final ContactId contactId;
|
|
||||||
|
|
||||||
public InvitationMessage(MessageId id, GroupId groupId, long time,
|
public InvitationMessage(MessageId id, GroupId groupId, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read,
|
boolean local, boolean sent, boolean seen, boolean read,
|
||||||
SessionId sessionId, ContactId contactId) {
|
SessionId sessionId) {
|
||||||
|
|
||||||
super(id, groupId, time, local, sent, seen, read);
|
super(id, groupId, time, local, sent, seen, read);
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.contactId = contactId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionId getSessionId() {
|
public SessionId getSessionId() {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactId getContactId() {
|
|
||||||
return contactId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.briarproject.briar.api.sharing;
|
package org.briarproject.briar.api.sharing;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
@@ -11,7 +10,8 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class InvitationRequest<S extends Shareable> extends InvitationMessage {
|
public abstract class InvitationRequest<S extends Shareable>
|
||||||
|
extends InvitationMessage {
|
||||||
|
|
||||||
private final S shareable;
|
private final S shareable;
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -20,9 +20,9 @@ public class InvitationRequest<S extends Shareable> extends InvitationMessage {
|
|||||||
|
|
||||||
public InvitationRequest(MessageId id, GroupId groupId, long time,
|
public InvitationRequest(MessageId id, GroupId groupId, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read,
|
boolean local, boolean sent, boolean seen, boolean read,
|
||||||
SessionId sessionId, S shareable, ContactId contactId,
|
SessionId sessionId, S shareable,
|
||||||
@Nullable String message, boolean available, boolean canBeOpened) {
|
@Nullable String message, boolean available, boolean canBeOpened) {
|
||||||
super(id, groupId, time, local, sent, seen, read, sessionId, contactId);
|
super(id, groupId, time, local, sent, seen, read, sessionId);
|
||||||
this.shareable = shareable;
|
this.shareable = shareable;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.available = available;
|
this.available = available;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.briarproject.briar.api.sharing;
|
package org.briarproject.briar.api.sharing;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
@@ -10,7 +9,7 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class InvitationResponse extends InvitationMessage {
|
public abstract class InvitationResponse extends InvitationMessage {
|
||||||
|
|
||||||
private final GroupId shareableId;
|
private final GroupId shareableId;
|
||||||
private final boolean accept;
|
private final boolean accept;
|
||||||
@@ -18,8 +17,8 @@ public class InvitationResponse extends InvitationMessage {
|
|||||||
public InvitationResponse(MessageId id, GroupId groupId,
|
public InvitationResponse(MessageId id, GroupId groupId,
|
||||||
long time, boolean local, boolean sent, boolean seen,
|
long time, boolean local, boolean sent, boolean seen,
|
||||||
boolean read, SessionId sessionId, GroupId shareableId,
|
boolean read, SessionId sessionId, GroupId shareableId,
|
||||||
ContactId contactId, boolean accept) {
|
boolean accept) {
|
||||||
super(id, groupId, time, local, sent, seen, read, sessionId, contactId);
|
super(id, groupId, time, local, sent, seen, read, sessionId);
|
||||||
this.shareableId = shareableId;
|
this.shareableId = shareableId;
|
||||||
this.accept = accept;
|
this.accept = accept;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.briarproject.briar.api.sharing;
|
package org.briarproject.briar.api.sharing;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.Group;
|
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -9,8 +8,6 @@ public interface Shareable {
|
|||||||
|
|
||||||
GroupId getId();
|
GroupId getId();
|
||||||
|
|
||||||
Group getGroup();
|
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
import static org.briarproject.briar.api.introduction.Role.INTRODUCEE;
|
|
||||||
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_AUTH;
|
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_AUTH;
|
||||||
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_RESPONSES;
|
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_RESPONSES;
|
||||||
import static org.briarproject.briar.introduction.IntroduceeState.LOCAL_ACCEPTED;
|
import static org.briarproject.briar.introduction.IntroduceeState.LOCAL_ACCEPTED;
|
||||||
@@ -255,11 +254,10 @@ class IntroduceeProtocolEngine
|
|||||||
localAuthor.getId());
|
localAuthor.getId());
|
||||||
boolean contactExists = contactManager
|
boolean contactExists = contactManager
|
||||||
.contactExists(txn, m.getAuthor().getId(), localAuthor.getId());
|
.contactExists(txn, m.getAuthor().getId(), localAuthor.getId());
|
||||||
IntroductionRequest request =
|
IntroductionRequest request = new IntroductionRequest(s.getSessionId(),
|
||||||
new IntroductionRequest(s.getSessionId(), m.getMessageId(),
|
m.getMessageId(), m.getGroupId(), m.getTimestamp(), false,
|
||||||
m.getGroupId(), INTRODUCEE, m.getTimestamp(), false,
|
false, false, false, m.getAuthor(), m.getMessage(), false,
|
||||||
false, false, false, m.getAuthor().getName(), false,
|
contactExists);
|
||||||
m.getMessage(), false, contactExists);
|
|
||||||
IntroductionRequestReceivedEvent e =
|
IntroductionRequestReceivedEvent e =
|
||||||
new IntroductionRequestReceivedEvent(c.getId(), request);
|
new IntroductionRequestReceivedEvent(c.getId(), request);
|
||||||
txn.attach(e);
|
txn.attach(e);
|
||||||
|
|||||||
@@ -472,10 +472,9 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
localAuthor.getId());
|
localAuthor.getId());
|
||||||
|
|
||||||
return new IntroductionRequest(sessionId, m, contactGroupId,
|
return new IntroductionRequest(sessionId, m, contactGroupId,
|
||||||
role, meta.getTimestamp(), meta.isLocal(),
|
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
||||||
status.isSent(), status.isSeen(), meta.isRead(),
|
status.isSeen(), meta.isRead(), author, message,
|
||||||
author.getName(), false, message, !meta.isAvailableToAnswer(),
|
!meta.isAvailableToAnswer(), contactExists);
|
||||||
contactExists);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntroductionResponse parseInvitationResponse(GroupId contactGroupId,
|
private IntroductionResponse parseInvitationResponse(GroupId contactGroupId,
|
||||||
|
|||||||
@@ -258,6 +258,6 @@ class CreatorProtocolEngine extends AbstractProtocolEngine<CreatorSession> {
|
|||||||
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
||||||
return new GroupInvitationResponse(m.getId(), m.getContactGroupId(),
|
return new GroupInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||||
m.getTimestamp(), false, false, true, false, sessionId,
|
m.getTimestamp(), false, false, true, false, sessionId,
|
||||||
m.getPrivateGroupId(), c, accept);
|
m.getPrivateGroupId(), accept);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
|||||||
return new GroupInvitationResponse(m, contactGroupId,
|
return new GroupInvitationResponse(m, contactGroupId,
|
||||||
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
||||||
status.isSeen(), meta.isRead(), sessionId,
|
status.isSeen(), meta.isRead(), sessionId,
|
||||||
meta.getPrivateGroupId(), c, accept);
|
meta.getPrivateGroupId(), accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -30,11 +30,10 @@ public class BlogInvitationFactoryImpl
|
|||||||
@Override
|
@Override
|
||||||
public BlogInvitationResponse createInvitationResponse(MessageId id,
|
public BlogInvitationResponse createInvitationResponse(MessageId id,
|
||||||
GroupId contactGroupId, long time, boolean local, boolean sent,
|
GroupId contactGroupId, long time, boolean local, boolean sent,
|
||||||
boolean seen, boolean read, GroupId shareableId,
|
boolean seen, boolean read, GroupId shareableId, boolean accept) {
|
||||||
ContactId contactId, boolean accept) {
|
|
||||||
SessionId sessionId = new SessionId(shareableId.getBytes());
|
SessionId sessionId = new SessionId(shareableId.getBytes());
|
||||||
return new BlogInvitationResponse(id, contactGroupId, time, local,
|
return new BlogInvitationResponse(id, contactGroupId, time, local,
|
||||||
sent, seen, read, sessionId, shareableId, contactId, accept);
|
sent, seen, read, sessionId, shareableId, accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
|
|||||||
BlogInvitationResponse response = invitationFactory
|
BlogInvitationResponse response = invitationFactory
|
||||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||||
m.getTimestamp(), false, false, true, false,
|
m.getTimestamp(), false, false, true, false,
|
||||||
m.getShareableId(), contactId, true);
|
m.getShareableId(), true);
|
||||||
return new BlogInvitationResponseReceivedEvent(contactId, response);
|
return new BlogInvitationResponseReceivedEvent(contactId, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
|
|||||||
BlogInvitationResponse response = invitationFactory
|
BlogInvitationResponse response = invitationFactory
|
||||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||||
m.getTimestamp(), false, false, true, false,
|
m.getTimestamp(), false, false, true, false,
|
||||||
m.getShareableId(), contactId, true);
|
m.getShareableId(), true);
|
||||||
return new BlogInvitationResponseReceivedEvent(contactId, response);
|
return new BlogInvitationResponseReceivedEvent(contactId, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ class BlogSharingManagerImpl extends SharingManagerImpl<Blog>
|
|||||||
|
|
||||||
// Pre-share both blogs, if they have not been shared already
|
// Pre-share both blogs, if they have not been shared already
|
||||||
try {
|
try {
|
||||||
preShareShareable(txn, c, ourBlog);
|
preShareGroup(txn, c, ourBlog.getGroup());
|
||||||
preShareShareable(txn, c, theirBlog);
|
preShareGroup(txn, c, theirBlog.getGroup());
|
||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ public class ForumInvitationFactoryImpl
|
|||||||
public ForumInvitationResponse createInvitationResponse(MessageId id,
|
public ForumInvitationResponse createInvitationResponse(MessageId id,
|
||||||
GroupId contactGroupId, long time, boolean local, boolean sent,
|
GroupId contactGroupId, long time, boolean local, boolean sent,
|
||||||
boolean seen, boolean read, GroupId shareableId,
|
boolean seen, boolean read, GroupId shareableId,
|
||||||
ContactId contactId, boolean accept) {
|
boolean accept) {
|
||||||
SessionId sessionId = new SessionId(shareableId.getBytes());
|
SessionId sessionId = new SessionId(shareableId.getBytes());
|
||||||
return new ForumInvitationResponse(id, contactGroupId, time, local,
|
return new ForumInvitationResponse(id, contactGroupId, time, local,
|
||||||
sent, seen, read, sessionId, shareableId, contactId, accept);
|
sent, seen, read, sessionId, shareableId, accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
|
|||||||
ForumInvitationResponse response = invitationFactory
|
ForumInvitationResponse response = invitationFactory
|
||||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||||
m.getTimestamp(), false, false, true, false,
|
m.getTimestamp(), false, false, true, false,
|
||||||
m.getShareableId(), contactId, true);
|
m.getShareableId(), true);
|
||||||
return new ForumInvitationResponseReceivedEvent(contactId, response);
|
return new ForumInvitationResponseReceivedEvent(contactId, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
|
|||||||
ForumInvitationResponse response = invitationFactory
|
ForumInvitationResponse response = invitationFactory
|
||||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||||
m.getTimestamp(), false, false, true, false,
|
m.getTimestamp(), false, false, true, false,
|
||||||
m.getShareableId(), contactId, true);
|
m.getShareableId(), true);
|
||||||
return new ForumInvitationResponseReceivedEvent(contactId, response);
|
return new ForumInvitationResponseReceivedEvent(contactId, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ public interface InvitationFactory<S extends Shareable, I extends InvitationResp
|
|||||||
I createInvitationResponse(MessageId id,
|
I createInvitationResponse(MessageId id,
|
||||||
GroupId contactGroupId, long time, boolean local, boolean sent,
|
GroupId contactGroupId, long time, boolean local, boolean sent,
|
||||||
boolean seen, boolean read, GroupId shareableId,
|
boolean seen, boolean read, GroupId shareableId,
|
||||||
ContactId contactId, boolean accept);
|
boolean accept);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,29 +156,29 @@ abstract class SharingManagerImpl<S extends Shareable>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given Shareable and initializes a session between us
|
* Adds the given Group and initializes a session between us
|
||||||
* and the Contact c in state SHARING.
|
* and the Contact c in state SHARING.
|
||||||
* If a session already exists, this does nothing.
|
* If a session already exists, this does nothing.
|
||||||
*/
|
*/
|
||||||
void preShareShareable(Transaction txn, Contact c, S shareable)
|
void preShareGroup(Transaction txn, Contact c, Group g)
|
||||||
throws DbException, FormatException {
|
throws DbException, FormatException {
|
||||||
// Return if a session already exists with the contact
|
// Return if a session already exists with the contact
|
||||||
GroupId contactGroupId = getContactGroup(c).getId();
|
GroupId contactGroupId = getContactGroup(c).getId();
|
||||||
StoredSession existingSession = getSession(txn, contactGroupId,
|
StoredSession existingSession = getSession(txn, contactGroupId,
|
||||||
getSessionId(shareable.getId()));
|
getSessionId(g.getId()));
|
||||||
if (existingSession != null) return;
|
if (existingSession != null) return;
|
||||||
|
|
||||||
// Add the shareable
|
// Add the shareable's group
|
||||||
db.addGroup(txn, shareable.getGroup());
|
db.addGroup(txn, g);
|
||||||
|
|
||||||
// Apply the client's visibility
|
// Apply the client's visibility
|
||||||
Visibility client = clientVersioningManager.getClientVisibility(txn,
|
Visibility client = clientVersioningManager.getClientVisibility(txn,
|
||||||
c.getId(), getShareableClientId(), getShareableMajorVersion());
|
c.getId(), getShareableClientId(), getShareableMajorVersion());
|
||||||
db.setGroupVisibility(txn, c.getId(), shareable.getId(), client);
|
db.setGroupVisibility(txn, c.getId(), g.getId(), client);
|
||||||
|
|
||||||
// Initialize session in sharing state
|
// Initialize session in sharing state
|
||||||
Session session = new Session(SHARING, contactGroupId,
|
Session session = new Session(SHARING, contactGroupId, g.getId(),
|
||||||
shareable.getId(), null, null, 0, 0);
|
null, null, 0, 0);
|
||||||
MessageId storageId = createStorageId(txn, contactGroupId);
|
MessageId storageId = createStorageId(txn, contactGroupId);
|
||||||
storeSession(txn, storageId, session);
|
storeSession(txn, storageId, session);
|
||||||
}
|
}
|
||||||
@@ -343,11 +343,11 @@ abstract class SharingManagerImpl<S extends Shareable>
|
|||||||
parseInvitationRequest(txn, c, m, meta, status));
|
parseInvitationRequest(txn, c, m, meta, status));
|
||||||
} else if (type == ACCEPT) {
|
} else if (type == ACCEPT) {
|
||||||
messages.add(
|
messages.add(
|
||||||
parseInvitationResponse(c, contactGroupId, m, meta,
|
parseInvitationResponse(contactGroupId, m, meta,
|
||||||
status, true));
|
status, true));
|
||||||
} else if (type == DECLINE) {
|
} else if (type == DECLINE) {
|
||||||
messages.add(
|
messages.add(
|
||||||
parseInvitationResponse(c, contactGroupId, m, meta,
|
parseInvitationResponse(contactGroupId, m, meta,
|
||||||
status, false));
|
status, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,13 +374,12 @@ abstract class SharingManagerImpl<S extends Shareable>
|
|||||||
meta.isAvailableToAnswer(), canBeOpened);
|
meta.isAvailableToAnswer(), canBeOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InvitationResponse parseInvitationResponse(ContactId c,
|
private InvitationResponse parseInvitationResponse(GroupId contactGroupId,
|
||||||
GroupId contactGroupId, MessageId m, MessageMetadata meta,
|
MessageId m, MessageMetadata meta, MessageStatus status,
|
||||||
MessageStatus status, boolean accept)
|
boolean accept) {
|
||||||
throws DbException, FormatException {
|
|
||||||
return invitationFactory.createInvitationResponse(m, contactGroupId,
|
return invitationFactory.createInvitationResponse(m, contactGroupId,
|
||||||
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
||||||
status.isSeen(), meta.isRead(), meta.getShareableId(), c,
|
status.isSeen(), meta.isRead(), meta.getShareableId(),
|
||||||
accept);
|
accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ public class GroupInvitationIntegrationTest
|
|||||||
assertEquals(msg, request.getMessage());
|
assertEquals(msg, request.getMessage());
|
||||||
assertEquals(author0, request.getShareable().getCreator());
|
assertEquals(author0, request.getShareable().getCreator());
|
||||||
assertEquals(timestamp, request.getTimestamp());
|
assertEquals(timestamp, request.getTimestamp());
|
||||||
assertEquals(contactId0From1, request.getContactId());
|
|
||||||
assertEquals(privateGroup0.getName(), request.getShareable().getName());
|
assertEquals(privateGroup0.getName(), request.getShareable().getName());
|
||||||
assertFalse(request.isLocal());
|
assertFalse(request.isLocal());
|
||||||
assertFalse(request.isRead());
|
assertFalse(request.isRead());
|
||||||
@@ -126,7 +125,6 @@ public class GroupInvitationIntegrationTest
|
|||||||
if (m instanceof GroupInvitationResponse) {
|
if (m instanceof GroupInvitationResponse) {
|
||||||
foundResponse = true;
|
foundResponse = true;
|
||||||
InvitationResponse response = (GroupInvitationResponse) m;
|
InvitationResponse response = (GroupInvitationResponse) m;
|
||||||
assertEquals(contactId0From1, response.getContactId());
|
|
||||||
assertTrue(response.isLocal());
|
assertTrue(response.isLocal());
|
||||||
assertFalse(response.wasAccepted());
|
assertFalse(response.wasAccepted());
|
||||||
}
|
}
|
||||||
@@ -143,7 +141,6 @@ public class GroupInvitationIntegrationTest
|
|||||||
if (m instanceof GroupInvitationResponse) {
|
if (m instanceof GroupInvitationResponse) {
|
||||||
foundResponse = true;
|
foundResponse = true;
|
||||||
InvitationResponse response = (GroupInvitationResponse) m;
|
InvitationResponse response = (GroupInvitationResponse) m;
|
||||||
assertEquals(contactId0From1, response.getContactId());
|
|
||||||
assertFalse(response.isLocal());
|
assertFalse(response.isLocal());
|
||||||
assertFalse(response.wasAccepted());
|
assertFalse(response.wasAccepted());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -706,7 +706,6 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
for (InvitationMessage m : messages) {
|
for (InvitationMessage m : messages) {
|
||||||
assertEquals(contactGroup.getId(), m.getGroupId());
|
assertEquals(contactGroup.getId(), m.getGroupId());
|
||||||
assertEquals(contactId, m.getContactId());
|
|
||||||
if (m.getId().equals(message.getId())) {
|
if (m.getId().equals(message.getId())) {
|
||||||
assertTrue(m instanceof GroupInvitationRequest);
|
assertTrue(m instanceof GroupInvitationRequest);
|
||||||
assertEquals(time1, m.getTimestamp());
|
assertEquals(time1, m.getTimestamp());
|
||||||
|
|||||||
@@ -153,18 +153,14 @@ public class BlogSharingIntegrationTest
|
|||||||
// check other things are alright with the message
|
// check other things are alright with the message
|
||||||
for (InvitationMessage m : list) {
|
for (InvitationMessage m : list) {
|
||||||
if (m instanceof BlogInvitationRequest) {
|
if (m instanceof BlogInvitationRequest) {
|
||||||
BlogInvitationRequest invitation =
|
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||||
(BlogInvitationRequest) m;
|
|
||||||
assertFalse(invitation.isAvailable());
|
assertFalse(invitation.isAvailable());
|
||||||
assertEquals(blog2.getAuthor().getName(),
|
assertEquals(blog2.getAuthor().getName(),
|
||||||
invitation.getBlogAuthorName());
|
invitation.getBlogAuthorName());
|
||||||
assertFalse(invitation.getShareable().isRssFeed());
|
assertFalse(invitation.getShareable().isRssFeed());
|
||||||
assertEquals(contactId1From0, invitation.getContactId());
|
|
||||||
assertEquals("Hi!", invitation.getMessage());
|
assertEquals("Hi!", invitation.getMessage());
|
||||||
} else {
|
} else {
|
||||||
BlogInvitationResponse response =
|
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||||
(BlogInvitationResponse) m;
|
|
||||||
assertEquals(contactId0From1, response.getContactId());
|
|
||||||
assertTrue(response.wasAccepted());
|
assertTrue(response.wasAccepted());
|
||||||
assertTrue(response.isLocal());
|
assertTrue(response.isLocal());
|
||||||
}
|
}
|
||||||
@@ -228,18 +224,14 @@ public class BlogSharingIntegrationTest
|
|||||||
// check other things are alright with the message
|
// check other things are alright with the message
|
||||||
for (InvitationMessage m : list) {
|
for (InvitationMessage m : list) {
|
||||||
if (m instanceof BlogInvitationRequest) {
|
if (m instanceof BlogInvitationRequest) {
|
||||||
BlogInvitationRequest invitation =
|
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||||
(BlogInvitationRequest) m;
|
|
||||||
assertFalse(invitation.isAvailable());
|
assertFalse(invitation.isAvailable());
|
||||||
assertEquals(rssBlog.getAuthor().getName(),
|
assertEquals(rssBlog.getAuthor().getName(),
|
||||||
invitation.getBlogAuthorName());
|
invitation.getBlogAuthorName());
|
||||||
assertTrue(invitation.getShareable().isRssFeed());
|
assertTrue(invitation.getShareable().isRssFeed());
|
||||||
assertEquals(contactId1From0, invitation.getContactId());
|
|
||||||
assertEquals("Hi!", invitation.getMessage());
|
assertEquals("Hi!", invitation.getMessage());
|
||||||
} else {
|
} else {
|
||||||
BlogInvitationResponse response =
|
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||||
(BlogInvitationResponse) m;
|
|
||||||
assertEquals(contactId0From1, response.getContactId());
|
|
||||||
assertTrue(response.wasAccepted());
|
assertTrue(response.wasAccepted());
|
||||||
assertTrue(response.isLocal());
|
assertTrue(response.isLocal());
|
||||||
}
|
}
|
||||||
@@ -291,17 +283,13 @@ public class BlogSharingIntegrationTest
|
|||||||
// check things are alright with the message
|
// check things are alright with the message
|
||||||
for (InvitationMessage m : list) {
|
for (InvitationMessage m : list) {
|
||||||
if (m instanceof BlogInvitationRequest) {
|
if (m instanceof BlogInvitationRequest) {
|
||||||
BlogInvitationRequest invitation =
|
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||||
(BlogInvitationRequest) m;
|
|
||||||
assertFalse(invitation.isAvailable());
|
assertFalse(invitation.isAvailable());
|
||||||
assertEquals(blog2.getAuthor().getName(),
|
assertEquals(blog2.getAuthor().getName(),
|
||||||
invitation.getBlogAuthorName());
|
invitation.getBlogAuthorName());
|
||||||
assertEquals(contactId1From0, invitation.getContactId());
|
|
||||||
assertEquals(null, invitation.getMessage());
|
assertEquals(null, invitation.getMessage());
|
||||||
} else {
|
} else {
|
||||||
BlogInvitationResponse response =
|
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||||
(BlogInvitationResponse) m;
|
|
||||||
assertEquals(contactId0From1, response.getContactId());
|
|
||||||
assertFalse(response.wasAccepted());
|
assertFalse(response.wasAccepted());
|
||||||
assertTrue(response.isLocal());
|
assertTrue(response.isLocal());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,13 +141,11 @@ public class ForumSharingIntegrationTest
|
|||||||
(ForumInvitationRequest) m;
|
(ForumInvitationRequest) m;
|
||||||
assertFalse(invitation.isAvailable());
|
assertFalse(invitation.isAvailable());
|
||||||
assertEquals(forum0.getName(), invitation.getForumName());
|
assertEquals(forum0.getName(), invitation.getForumName());
|
||||||
assertEquals(contactId1From0, invitation.getContactId());
|
|
||||||
assertEquals("Hi!", invitation.getMessage());
|
assertEquals("Hi!", invitation.getMessage());
|
||||||
assertTrue(invitation.canBeOpened());
|
assertTrue(invitation.canBeOpened());
|
||||||
} else {
|
} else {
|
||||||
ForumInvitationResponse response =
|
ForumInvitationResponse response =
|
||||||
(ForumInvitationResponse) m;
|
(ForumInvitationResponse) m;
|
||||||
assertEquals(contactId0From1, response.getContactId());
|
|
||||||
assertTrue(response.wasAccepted());
|
assertTrue(response.wasAccepted());
|
||||||
assertTrue(response.isLocal());
|
assertTrue(response.isLocal());
|
||||||
}
|
}
|
||||||
@@ -196,17 +194,13 @@ public class ForumSharingIntegrationTest
|
|||||||
// check things are alright with the forum message
|
// check things are alright with the forum message
|
||||||
for (InvitationMessage m : list) {
|
for (InvitationMessage m : list) {
|
||||||
if (m instanceof ForumInvitationRequest) {
|
if (m instanceof ForumInvitationRequest) {
|
||||||
ForumInvitationRequest invitation =
|
ForumInvitationRequest invitation = (ForumInvitationRequest) m;
|
||||||
(ForumInvitationRequest) m;
|
|
||||||
assertFalse(invitation.isAvailable());
|
assertFalse(invitation.isAvailable());
|
||||||
assertEquals(forum0.getName(), invitation.getForumName());
|
assertEquals(forum0.getName(), invitation.getForumName());
|
||||||
assertEquals(contactId1From0, invitation.getContactId());
|
|
||||||
assertEquals(null, invitation.getMessage());
|
assertEquals(null, invitation.getMessage());
|
||||||
assertFalse(invitation.canBeOpened());
|
assertFalse(invitation.canBeOpened());
|
||||||
} else {
|
} else {
|
||||||
ForumInvitationResponse response =
|
ForumInvitationResponse response = (ForumInvitationResponse) m;
|
||||||
(ForumInvitationResponse) m;
|
|
||||||
assertEquals(contactId0From1, response.getContactId());
|
|
||||||
assertFalse(response.wasAccepted());
|
assertFalse(response.wasAccepted());
|
||||||
assertTrue(response.isLocal());
|
assertTrue(response.isLocal());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user