mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
Don't open unsubscribed shareables
This commit is contained in:
@@ -855,8 +855,9 @@ public class ConversationActivity extends BriarActivity
|
|||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@Override
|
@Override
|
||||||
public void open(ConversationRequestItem item) {
|
public void openRequestedShareable(ConversationRequestItem item) {
|
||||||
if (item.getRequestedGroupId() == null) return;
|
if (item.getRequestedGroupId() == null)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
Intent i;
|
Intent i;
|
||||||
switch (item.getRequestType()) {
|
switch (item.getRequestType()) {
|
||||||
case FORUM:
|
case FORUM:
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class ConversationAdapter
|
|||||||
|
|
||||||
void respondToRequest(ConversationRequestItem item, boolean accept);
|
void respondToRequest(ConversationRequestItem item, boolean accept);
|
||||||
|
|
||||||
void open(ConversationRequestItem item);
|
void openRequestedShareable(ConversationRequestItem item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ abstract class ConversationItem {
|
|||||||
return new ConversationRequestItem(ir.getMessageId(),
|
return new ConversationRequestItem(ir.getMessageId(),
|
||||||
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());
|
ir.wasAnswered(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +203,8 @@ abstract class ConversationItem {
|
|||||||
return new ConversationRequestItem(ir.getId(),
|
return new ConversationRequestItem(ir.getId(),
|
||||||
ir.getGroupId(), type, ir.getSessionId(), text,
|
ir.getGroupId(), type, ir.getSessionId(), text,
|
||||||
ir.getMessage(), ir.getTimestamp(), ir.isRead(),
|
ir.getMessage(), ir.getTimestamp(), ir.isRead(),
|
||||||
ir.getInvitedGroupId(), !ir.isAvailable());
|
ir.getInvitedGroupId(), !ir.isAvailable(),
|
||||||
|
ir.canBeOpened());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,17 +21,19 @@ class ConversationRequestItem extends ConversationNoticeInItem {
|
|||||||
private final GroupId requestedGroupId;
|
private final GroupId requestedGroupId;
|
||||||
private final RequestType requestType;
|
private final RequestType requestType;
|
||||||
private final SessionId sessionId;
|
private final SessionId sessionId;
|
||||||
private boolean answered;
|
private final boolean answered, canBeOpened;
|
||||||
|
|
||||||
ConversationRequestItem(MessageId id, GroupId groupId,
|
ConversationRequestItem(MessageId id, GroupId groupId,
|
||||||
RequestType requestType, SessionId sessionId, String text,
|
RequestType requestType, SessionId sessionId, String text,
|
||||||
@Nullable String msgText, long time, boolean read,
|
@Nullable String msgText, long time, boolean read,
|
||||||
@Nullable GroupId requestedGroupId, boolean answered) {
|
@Nullable GroupId requestedGroupId, boolean answered,
|
||||||
|
boolean canBeOpened) {
|
||||||
super(id, groupId, text, msgText, time, read);
|
super(id, groupId, text, msgText, time, read);
|
||||||
this.requestType = requestType;
|
this.requestType = requestType;
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.requestedGroupId = requestedGroupId;
|
this.requestedGroupId = requestedGroupId;
|
||||||
this.answered = answered;
|
this.answered = answered;
|
||||||
|
this.canBeOpened = canBeOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestType getRequestType() {
|
RequestType getRequestType() {
|
||||||
@@ -51,8 +53,8 @@ class ConversationRequestItem extends ConversationNoticeInItem {
|
|||||||
return answered;
|
return answered;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAnswered(boolean answered) {
|
public boolean canBeOpened() {
|
||||||
this.answered = answered;
|
return canBeOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LayoutRes
|
@LayoutRes
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.briarproject.briar.android.contact.ConversationAdapter.ConversationLi
|
|||||||
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.INTRODUCTION;
|
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -33,27 +32,25 @@ class ConversationRequestViewHolder extends ConversationNoticeInViewHolder {
|
|||||||
final ConversationRequestItem item =
|
final ConversationRequestItem item =
|
||||||
(ConversationRequestItem) conversationItem;
|
(ConversationRequestItem) conversationItem;
|
||||||
|
|
||||||
if (item.getRequestType() == INTRODUCTION && item.wasAnswered()) {
|
if (item.wasAnswered() && item.canBeOpened()) {
|
||||||
acceptButton.setVisibility(GONE);
|
|
||||||
declineButton.setVisibility(GONE);
|
|
||||||
} else if (item.wasAnswered()) {
|
|
||||||
acceptButton.setVisibility(VISIBLE);
|
acceptButton.setVisibility(VISIBLE);
|
||||||
acceptButton.setText(R.string.open);
|
acceptButton.setText(R.string.open);
|
||||||
acceptButton.setOnClickListener(new OnClickListener() {
|
acceptButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
item.setAnswered(true);
|
listener.openRequestedShareable(item);
|
||||||
listener.open(item);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
declineButton.setVisibility(GONE);
|
declineButton.setVisibility(GONE);
|
||||||
|
} else if (item.wasAnswered()) {
|
||||||
|
acceptButton.setVisibility(GONE);
|
||||||
|
declineButton.setVisibility(GONE);
|
||||||
} else {
|
} else {
|
||||||
acceptButton.setVisibility(VISIBLE);
|
acceptButton.setVisibility(VISIBLE);
|
||||||
acceptButton.setText(R.string.accept);
|
acceptButton.setText(R.string.accept);
|
||||||
acceptButton.setOnClickListener(new OnClickListener() {
|
acceptButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
item.setAnswered(true);
|
|
||||||
listener.respondToRequest(item, true);
|
listener.respondToRequest(item, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -61,7 +58,6 @@ class ConversationRequestViewHolder extends ConversationNoticeInViewHolder {
|
|||||||
declineButton.setOnClickListener(new OnClickListener() {
|
declineButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
item.setAnswered(true);
|
|
||||||
listener.respondToRequest(item, false);
|
listener.respondToRequest(item, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ public class BlogInvitationRequest extends InvitationRequest {
|
|||||||
|
|
||||||
public BlogInvitationRequest(MessageId id, SessionId sessionId,
|
public BlogInvitationRequest(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, String blogAuthorName,
|
GroupId groupId, ContactId contactId, String blogAuthorName,
|
||||||
@Nullable String message, @Nullable GroupId blogId,
|
@Nullable String message, GroupId blogId,
|
||||||
boolean available, long time, boolean local, boolean sent,
|
boolean available, boolean canBeOpened, long time,
|
||||||
boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, sessionId, groupId, contactId, message, blogId, available,
|
super(id, sessionId, groupId, contactId, message, blogId, available,
|
||||||
time, local, sent, seen, read);
|
canBeOpened, time, local, sent, seen, read);
|
||||||
this.blogAuthorName = blogAuthorName;
|
this.blogAuthorName = blogAuthorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ public class ForumInvitationRequest extends InvitationRequest {
|
|||||||
public ForumInvitationRequest(MessageId id, SessionId sessionId,
|
public ForumInvitationRequest(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, GroupId forumId,
|
GroupId groupId, ContactId contactId, GroupId forumId,
|
||||||
String forumName, @Nullable String message, boolean available,
|
String forumName, @Nullable String message, boolean available,
|
||||||
long time, boolean local, boolean sent, boolean seen,
|
boolean canBeOpened, long time, boolean local, boolean sent,
|
||||||
boolean read) {
|
boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, sessionId, groupId, contactId, message, forumId, available,
|
super(id, sessionId, groupId, contactId, message, forumId, available,
|
||||||
time, local, sent, seen, read);
|
canBeOpened, time, local, sent, seen, read);
|
||||||
this.forumName = forumName;
|
this.forumName = forumName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ public class GroupInvitationRequest extends InvitationRequest {
|
|||||||
public GroupInvitationRequest(MessageId id, SessionId sessionId,
|
public GroupInvitationRequest(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, @Nullable String message,
|
GroupId groupId, ContactId contactId, @Nullable String message,
|
||||||
GroupId privateGroupId, String groupName, Author creator,
|
GroupId privateGroupId, String groupName, Author creator,
|
||||||
boolean available, long time, boolean local, boolean sent,
|
boolean available, boolean canBeOpened, long time,
|
||||||
boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
super(id, sessionId, groupId, contactId, message, privateGroupId,
|
super(id, sessionId, groupId, contactId, message, privateGroupId,
|
||||||
available, time, local, sent, seen, read);
|
available, canBeOpened, time, local, sent, seen, read);
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ public abstract class InvitationMessage extends BaseMessageHeader {
|
|||||||
|
|
||||||
private final SessionId sessionId;
|
private final SessionId sessionId;
|
||||||
private final ContactId contactId;
|
private final ContactId contactId;
|
||||||
@Nullable
|
|
||||||
private final GroupId invitedGroupId;
|
private final GroupId invitedGroupId;
|
||||||
|
|
||||||
public InvitationMessage(MessageId id, SessionId sessionId, GroupId groupId,
|
public InvitationMessage(MessageId id, SessionId sessionId, GroupId groupId,
|
||||||
ContactId contactId, @Nullable GroupId invitedGroupId, long time,
|
ContactId contactId, GroupId invitedGroupId, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, groupId, time, local, read, sent, seen);
|
super(id, groupId, time, local, read, sent, seen);
|
||||||
|
|||||||
@@ -15,17 +15,19 @@ public abstract class InvitationRequest extends InvitationMessage {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String message;
|
private final String message;
|
||||||
private final boolean available;
|
private final boolean available, canBeOpened;
|
||||||
|
|
||||||
public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId,
|
public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId,
|
||||||
ContactId contactId, @Nullable String message,
|
ContactId contactId, @Nullable String message,
|
||||||
@Nullable GroupId invitedGroupId, boolean available, long time,
|
GroupId invitedGroupId, boolean available,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean canBeOpened, long time, boolean local, boolean sent,
|
||||||
|
boolean seen, boolean read) {
|
||||||
super(id, sessionId, groupId, contactId, invitedGroupId, time, local,
|
super(id, sessionId, groupId, contactId, invitedGroupId, time, local,
|
||||||
sent, seen, read);
|
sent, seen, read);
|
||||||
|
if (available && canBeOpened) throw new IllegalArgumentException();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.available = available;
|
this.available = available;
|
||||||
|
this.canBeOpened = canBeOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -37,4 +39,8 @@ public abstract class InvitationRequest extends InvitationMessage {
|
|||||||
return available;
|
return available;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canBeOpened() {
|
||||||
|
return canBeOpened;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ 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.SessionId;
|
import org.briarproject.briar.api.client.SessionId;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@@ -17,7 +16,7 @@ public abstract class InvitationResponse extends InvitationMessage {
|
|||||||
|
|
||||||
public InvitationResponse(MessageId id, SessionId sessionId,
|
public InvitationResponse(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId,
|
GroupId groupId, ContactId contactId,
|
||||||
@Nullable GroupId invitedGroupId, boolean accept, long time,
|
GroupId invitedGroupId, boolean accept, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, sessionId, groupId, contactId, invitedGroupId, time, local,
|
super(id, sessionId, groupId, contactId, invitedGroupId, time, local,
|
||||||
|
|||||||
@@ -405,11 +405,13 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
|||||||
SessionId sessionId = getSessionId(meta.getPrivateGroupId());
|
SessionId sessionId = getSessionId(meta.getPrivateGroupId());
|
||||||
// Look up the invite message to get the details of the private group
|
// Look up the invite message to get the details of the private group
|
||||||
InviteMessage invite = getInviteMessage(txn, m);
|
InviteMessage invite = getInviteMessage(txn, m);
|
||||||
|
boolean canBeOpened = db.containsGroup(txn, invite.getPrivateGroupId());
|
||||||
return new GroupInvitationRequest(m, sessionId, contactGroupId, c,
|
return new GroupInvitationRequest(m, sessionId, contactGroupId, c,
|
||||||
invite.getMessage(), invite.getPrivateGroupId(),
|
invite.getMessage(), invite.getPrivateGroupId(),
|
||||||
invite.getGroupName(), invite.getCreator(),
|
invite.getGroupName(), invite.getCreator(),
|
||||||
meta.isAvailableToAnswer(), meta.getTimestamp(), meta.isLocal(),
|
meta.isAvailableToAnswer(), canBeOpened, meta.getTimestamp(),
|
||||||
status.isSent(), status.isSeen(), meta.isRead());
|
meta.isLocal(), status.isSent(), status.isSeen(),
|
||||||
|
meta.isRead());
|
||||||
}
|
}
|
||||||
|
|
||||||
private InviteMessage getInviteMessage(Transaction txn, MessageId m)
|
private InviteMessage getInviteMessage(Transaction txn, MessageId m)
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ class InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> {
|
|||||||
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
||||||
return new GroupInvitationRequest(m.getId(), sessionId,
|
return new GroupInvitationRequest(m.getId(), sessionId,
|
||||||
m.getContactGroupId(), c, m.getMessage(), m.getPrivateGroupId(),
|
m.getContactGroupId(), c, m.getMessage(), m.getPrivateGroupId(),
|
||||||
m.getGroupName(), m.getCreator(), true, m.getTimestamp(), false,
|
m.getGroupName(), m.getCreator(), true, false, m.getTimestamp(),
|
||||||
false, true, false);
|
false, false, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,13 +135,13 @@ class BlogSharingManagerImpl extends
|
|||||||
@Override
|
@Override
|
||||||
protected InvitationMessage createInvitationRequest(MessageId id,
|
protected InvitationMessage createInvitationRequest(MessageId id,
|
||||||
BlogInvitation msg, ContactId contactId, GroupId blogId,
|
BlogInvitation msg, ContactId contactId, GroupId blogId,
|
||||||
boolean available, long time, boolean local, boolean sent,
|
boolean available, boolean canBeOpened, long time, boolean local,
|
||||||
boolean seen, boolean read) {
|
boolean sent, boolean seen, boolean read) {
|
||||||
|
|
||||||
return new BlogInvitationRequest(id, msg.getSessionId(),
|
return new BlogInvitationRequest(id, msg.getSessionId(),
|
||||||
msg.getGroupId(), contactId, msg.getBlogAuthorName(),
|
msg.getGroupId(), contactId, msg.getBlogAuthorName(),
|
||||||
msg.getMessage(), blogId, available, time, local, sent, seen,
|
msg.getMessage(), blogId, available, canBeOpened, time, local,
|
||||||
read);
|
sent, seen, read);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -345,8 +345,8 @@ class BlogSharingManagerImpl extends
|
|||||||
localState.getSessionId(),
|
localState.getSessionId(),
|
||||||
localState.getContactGroupId(), contactId,
|
localState.getContactGroupId(), contactId,
|
||||||
blog.getAuthor().getName(), msg,
|
blog.getAuthor().getName(), msg,
|
||||||
localState.getShareableId(), true, time, false,
|
localState.getShareableId(), true, false, time,
|
||||||
false, false, false);
|
false, false, false, false);
|
||||||
return new BlogInvitationRequestReceivedEvent(blog, contactId,
|
return new BlogInvitationRequestReceivedEvent(blog, contactId,
|
||||||
request);
|
request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,11 +83,12 @@ class ForumSharingManagerImpl extends
|
|||||||
@Override
|
@Override
|
||||||
protected InvitationMessage createInvitationRequest(MessageId id,
|
protected InvitationMessage createInvitationRequest(MessageId id,
|
||||||
ForumInvitation msg, ContactId contactId, GroupId forumId,
|
ForumInvitation msg, ContactId contactId, GroupId forumId,
|
||||||
boolean available, long time, boolean local, boolean sent,
|
boolean available, boolean canBeOpened, long time,
|
||||||
boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
return new ForumInvitationRequest(id, msg.getSessionId(),
|
return new ForumInvitationRequest(id, msg.getSessionId(),
|
||||||
msg.getGroupId(), contactId, forumId, msg.getForumName(),
|
msg.getGroupId(), contactId, forumId, msg.getForumName(),
|
||||||
msg.getMessage(), available, time, local, sent, seen, read);
|
msg.getMessage(), available, canBeOpened, time, local, sent,
|
||||||
|
seen, read);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -272,7 +273,7 @@ class ForumSharingManagerImpl extends
|
|||||||
localState.getInvitationId(), localState.getSessionId(),
|
localState.getInvitationId(), localState.getSessionId(),
|
||||||
localState.getContactGroupId(), contactId,
|
localState.getContactGroupId(), contactId,
|
||||||
localState.getShareableId(), forum.getName(), msg, true,
|
localState.getShareableId(), forum.getName(), msg, true,
|
||||||
time, false, false, false, false);
|
false, time, false, false, false, false);
|
||||||
return new ForumInvitationRequestReceivedEvent(forum, contactId,
|
return new ForumInvitationRequestReceivedEvent(forum, contactId,
|
||||||
request);
|
request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
|
|
||||||
protected abstract InvitationMessage createInvitationRequest(MessageId id,
|
protected abstract InvitationMessage createInvitationRequest(MessageId id,
|
||||||
I msg, ContactId contactId, GroupId shareableId, boolean available,
|
I msg, ContactId contactId, GroupId shareableId, boolean available,
|
||||||
long time, boolean local, boolean sent, boolean seen, boolean read);
|
boolean canBeOpened, long time, boolean local, boolean sent,
|
||||||
|
boolean seen, boolean read);
|
||||||
|
|
||||||
protected abstract InvitationMessage createInvitationResponse(MessageId id,
|
protected abstract InvitationMessage createInvitationResponse(MessageId id,
|
||||||
SessionId sessionId, GroupId groupId, ContactId contactId,
|
SessionId sessionId, GroupId groupId, ContactId contactId,
|
||||||
@@ -395,7 +396,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
long time = d.getLong(TIME);
|
long time = d.getLong(TIME);
|
||||||
boolean local = d.getBoolean(LOCAL);
|
boolean local = d.getBoolean(LOCAL);
|
||||||
boolean read = d.getBoolean(MSG_KEY_READ, false);
|
boolean read = d.getBoolean(MSG_KEY_READ, false);
|
||||||
boolean available = false;
|
boolean available = false, canBeOpened = false;
|
||||||
|
|
||||||
if (type == SHARE_MSG_TYPE_INVITATION) {
|
if (type == SHARE_MSG_TYPE_INVITATION) {
|
||||||
I msg = getIFactory().build(group.getId(), d);
|
I msg = getIFactory().build(group.getId(), d);
|
||||||
@@ -407,12 +408,16 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
continue;
|
continue;
|
||||||
available = ((InviteeSessionState) s).getState() ==
|
available = ((InviteeSessionState) s).getState() ==
|
||||||
AWAIT_LOCAL_RESPONSE;
|
AWAIT_LOCAL_RESPONSE;
|
||||||
|
if (!available) {
|
||||||
|
canBeOpened = db.containsGroup(txn,
|
||||||
|
s.getShareableId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InvitationMessage im =
|
InvitationMessage im =
|
||||||
createInvitationRequest(m.getKey(), msg,
|
createInvitationRequest(m.getKey(), msg,
|
||||||
contactId, s.getShareableId(),
|
contactId, s.getShareableId(),
|
||||||
available, time, local, status.isSent(),
|
available, canBeOpened, time, local,
|
||||||
status.isSeen(), read);
|
status.isSent(), status.isSeen(), read);
|
||||||
list.add(im);
|
list.add(im);
|
||||||
} else if (type == SHARE_MSG_TYPE_ACCEPT ||
|
} else if (type == SHARE_MSG_TYPE_ACCEPT ||
|
||||||
type == SHARE_MSG_TYPE_DECLINE) {
|
type == SHARE_MSG_TYPE_DECLINE) {
|
||||||
|
|||||||
@@ -640,13 +640,17 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
new HashMap<MessageId, BdfDictionary>();
|
new HashMap<MessageId, BdfDictionary>();
|
||||||
results.put(message.getId(), meta);
|
results.put(message.getId(), meta);
|
||||||
results.put(messageId2, meta2);
|
results.put(messageId2, meta2);
|
||||||
long time1 = 1L, time2 = 2L;
|
final long time1 = 1L, time2 = 2L;
|
||||||
final MessageMetadata messageMetadata1 =
|
final MessageMetadata messageMetadata1 =
|
||||||
new MessageMetadata(INVITE, privateGroup.getId(), time1, true,
|
new MessageMetadata(INVITE, privateGroup.getId(), time1, true,
|
||||||
true, true, true);
|
true, true, false);
|
||||||
final MessageMetadata messageMetadata2 =
|
final MessageMetadata messageMetadata2 =
|
||||||
new MessageMetadata(JOIN, privateGroup.getId(), time2, true,
|
new MessageMetadata(JOIN, privateGroup.getId(), time2, true,
|
||||||
true, true, true);
|
true, true, true);
|
||||||
|
final InviteMessage invite =
|
||||||
|
new InviteMessage(message.getId(), contactGroup.getId(),
|
||||||
|
privateGroup.getId(), time1, "name", author,
|
||||||
|
new byte[0], null, new byte[0]);
|
||||||
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
@@ -669,6 +673,9 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
oneOf(clientHelper).toList(message);
|
oneOf(clientHelper).toList(message);
|
||||||
will(returnValue(body));
|
will(returnValue(body));
|
||||||
oneOf(messageParser).parseInviteMessage(message, body);
|
oneOf(messageParser).parseInviteMessage(message, body);
|
||||||
|
will(returnValue(invite));
|
||||||
|
oneOf(db).containsGroup(txn, privateGroup.getId());
|
||||||
|
will(returnValue(true));
|
||||||
// second message
|
// second message
|
||||||
oneOf(messageParser).parseMetadata(meta2);
|
oneOf(messageParser).parseMetadata(meta2);
|
||||||
will(returnValue(messageMetadata2));
|
will(returnValue(messageMetadata2));
|
||||||
|
|||||||
Reference in New Issue
Block a user