mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Remember when invitation was auto-declined due to deletion
And render differently
This commit is contained in:
committed by
Torsten Grote
parent
a7590956fd
commit
5c41d09c52
@@ -102,6 +102,10 @@ class ConversationVisitor implements
|
||||
text = ctx.getString(
|
||||
R.string.blogs_sharing_response_accepted_sent,
|
||||
contactName.getValue());
|
||||
} else if (r.isAutoDecline()) {
|
||||
text = ctx.getString(
|
||||
R.string.blogs_sharing_response_declined_auto,
|
||||
contactName.getValue());
|
||||
} else {
|
||||
text = ctx.getString(
|
||||
R.string.blogs_sharing_response_declined_sent,
|
||||
@@ -155,6 +159,10 @@ class ConversationVisitor implements
|
||||
text = ctx.getString(
|
||||
R.string.forum_invitation_response_accepted_sent,
|
||||
contactName.getValue());
|
||||
} else if (r.isAutoDecline()) {
|
||||
text = ctx.getString(
|
||||
R.string.forum_invitation_response_declined_auto,
|
||||
contactName.getValue());
|
||||
} else {
|
||||
text = ctx.getString(
|
||||
R.string.forum_invitation_response_declined_sent,
|
||||
|
||||
@@ -419,6 +419,7 @@
|
||||
<string name="forum_invitation_already_sharing">Already sharing</string>
|
||||
<string name="forum_invitation_response_accepted_sent">You accepted the forum invitation from %s.</string>
|
||||
<string name="forum_invitation_response_declined_sent">You declined the forum invitation from %s.</string>
|
||||
<string name="forum_invitation_response_declined_auto">The forum invitation from %s was automatically declined.</string>
|
||||
<string name="forum_invitation_response_accepted_received">%s accepted the forum invitation.</string>
|
||||
<string name="forum_invitation_response_declined_received">%s declined the forum invitation.</string>
|
||||
|
||||
@@ -456,6 +457,7 @@
|
||||
<string name="blogs_sharing_snackbar">Blog shared with chosen contacts</string>
|
||||
<string name="blogs_sharing_response_accepted_sent">You accepted the blog invitation from %s.</string>
|
||||
<string name="blogs_sharing_response_declined_sent">You declined the blog invitation from %s.</string>
|
||||
<string name="blogs_sharing_response_declined_auto">The blog invitation from %s was automatically declined.</string>
|
||||
<string name="blogs_sharing_response_accepted_received">%s accepted the blog invitation.</string>
|
||||
<string name="blogs_sharing_response_declined_received">%s declined the blog invitation.</string>
|
||||
<string name="blogs_sharing_invitation_received">%1$s has shared the blog \"%2$s\" with you.</string>
|
||||
|
||||
@@ -13,9 +13,9 @@ public class BlogInvitationResponse extends InvitationResponse {
|
||||
public BlogInvitationResponse(MessageId id, GroupId groupId, long time,
|
||||
boolean local, boolean read, boolean sent, boolean seen,
|
||||
SessionId sessionId, boolean accept, GroupId shareableId,
|
||||
long autoDeleteTimer) {
|
||||
long autoDeleteTimer, boolean isAutoDecline) {
|
||||
super(id, groupId, time, local, read, sent, seen, sessionId,
|
||||
accept, shareableId, autoDeleteTimer, false);
|
||||
accept, shareableId, autoDeleteTimer, isAutoDecline);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,9 +16,9 @@ public class ForumInvitationResponse extends InvitationResponse {
|
||||
public ForumInvitationResponse(MessageId id, GroupId groupId, long time,
|
||||
boolean local, boolean read, boolean sent, boolean seen,
|
||||
SessionId sessionId, boolean accept, GroupId shareableId,
|
||||
long autoDeleteTimer) {
|
||||
long autoDeleteTimer, boolean isAutoDecline) {
|
||||
super(id, groupId, time, local, read, sent, seen, sessionId,
|
||||
accept, shareableId, autoDeleteTimer, false);
|
||||
accept, shareableId, autoDeleteTimer, isAutoDecline);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,11 +33,11 @@ public class BlogInvitationFactoryImpl
|
||||
public BlogInvitationResponse createInvitationResponse(MessageId id,
|
||||
GroupId contactGroupId, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, boolean accept, GroupId shareableId,
|
||||
long autoDeleteTimer) {
|
||||
long autoDeleteTimer, boolean isAutoDecline) {
|
||||
SessionId sessionId = new SessionId(shareableId.getBytes());
|
||||
return new BlogInvitationResponse(id, contactGroupId, time, local, read,
|
||||
sent, seen, sessionId, accept, shareableId,
|
||||
autoDeleteTimer);
|
||||
autoDeleteTimer, isAutoDecline);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||
@@ -71,7 +72,8 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
|
||||
BlogInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, false, false,
|
||||
true, m.getShareableId(), m.getAutoDeleteTimer());
|
||||
true, m.getShareableId(), m.getAutoDeleteTimer(),
|
||||
false);
|
||||
return new BlogInvitationResponseReceivedEvent(response, contactId);
|
||||
}
|
||||
|
||||
@@ -81,7 +83,18 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
|
||||
BlogInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, false, false,
|
||||
false, m.getShareableId(), m.getAutoDeleteTimer());
|
||||
false, m.getShareableId(), m.getAutoDeleteTimer(),
|
||||
false);
|
||||
return new BlogInvitationResponseReceivedEvent(response, contactId);
|
||||
}
|
||||
|
||||
@Override
|
||||
Event getAutoDeclineInvitationResponseReceivedEvent(Session s, Message m,
|
||||
ContactId contactId, long timer) {
|
||||
BlogInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), s.getContactGroupId(),
|
||||
m.getTimestamp(), true, false, false, true,
|
||||
false, s.getShareableId(), timer, true);
|
||||
return new BlogInvitationResponseReceivedEvent(response, contactId);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,11 @@ public class ForumInvitationFactoryImpl
|
||||
public ForumInvitationResponse createInvitationResponse(MessageId id,
|
||||
GroupId contactGroupId, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, boolean accept, GroupId shareableId,
|
||||
long autoDeleteTimer) {
|
||||
long autoDeleteTimer, boolean isAutoDecline) {
|
||||
SessionId sessionId = new SessionId(shareableId.getBytes());
|
||||
return new ForumInvitationResponse(id, contactGroupId, time, local,
|
||||
read, sent, seen, sessionId, accept, shareableId,
|
||||
autoDeleteTimer);
|
||||
autoDeleteTimer, isAutoDecline);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.versioning.ClientVersioningManager;
|
||||
@@ -71,7 +72,8 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
|
||||
ForumInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, true, false,
|
||||
true, m.getShareableId(), m.getAutoDeleteTimer());
|
||||
true, m.getShareableId(), m.getAutoDeleteTimer(),
|
||||
false);
|
||||
return new ForumInvitationResponseReceivedEvent(response, contactId);
|
||||
}
|
||||
|
||||
@@ -81,7 +83,18 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
|
||||
ForumInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, true, false,
|
||||
false, m.getShareableId(), m.getAutoDeleteTimer());
|
||||
false, m.getShareableId(), m.getAutoDeleteTimer(),
|
||||
false);
|
||||
return new ForumInvitationResponseReceivedEvent(response, contactId);
|
||||
}
|
||||
|
||||
@Override
|
||||
Event getAutoDeclineInvitationResponseReceivedEvent(Session s, Message m,
|
||||
ContactId contactId, long timer) {
|
||||
ForumInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), s.getContactGroupId(),
|
||||
m.getTimestamp(), true, false, false, true,
|
||||
false, s.getShareableId(), timer, true);
|
||||
return new ForumInvitationResponseReceivedEvent(response, contactId);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ public interface InvitationFactory<S extends Shareable, R extends InvitationResp
|
||||
|
||||
R createInvitationResponse(MessageId id, GroupId contactGroupId, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read,
|
||||
boolean accept, GroupId shareableId, long autoDeleteTimer);
|
||||
boolean accept, GroupId shareableId, long autoDeleteTimer,
|
||||
boolean isAutoDecline);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ interface MessageEncoder {
|
||||
|
||||
BdfDictionary encodeMetadata(MessageType type, GroupId shareableId,
|
||||
long timestamp, boolean local, boolean read, boolean visible,
|
||||
boolean available, boolean accepted, long autoDeleteTimer);
|
||||
boolean available, boolean accepted, long autoDeleteTimer,
|
||||
boolean isAutoDecline);
|
||||
|
||||
void setVisibleInUi(BdfDictionary meta, boolean visible);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.briarproject.briar.sharing.MessageType.LEAVE;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_AUTO_DELETE_TIMER;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_AVAILABLE_TO_ANSWER;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_INVITATION_ACCEPTED;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_IS_AUTO_DECLINE;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_LOCAL;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_MESSAGE_TYPE;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_READ;
|
||||
@@ -48,7 +49,7 @@ class MessageEncoderImpl implements MessageEncoder {
|
||||
public BdfDictionary encodeMetadata(MessageType type,
|
||||
GroupId shareableId, long timestamp, boolean local, boolean read,
|
||||
boolean visible, boolean available, boolean accepted,
|
||||
long autoDeleteTimer) {
|
||||
long autoDeleteTimer, boolean isAutoDecline) {
|
||||
BdfDictionary meta = new BdfDictionary();
|
||||
meta.put(MSG_KEY_MESSAGE_TYPE, type.getValue());
|
||||
meta.put(MSG_KEY_SHAREABLE_ID, shareableId);
|
||||
@@ -61,6 +62,9 @@ class MessageEncoderImpl implements MessageEncoder {
|
||||
if (autoDeleteTimer != NO_AUTO_DELETE_TIMER) {
|
||||
meta.put(MSG_KEY_AUTO_DELETE_TIMER, autoDeleteTimer);
|
||||
}
|
||||
if (isAutoDecline) {
|
||||
meta.put(MSG_KEY_IS_AUTO_DECLINE, isAutoDecline);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,11 @@ class MessageMetadata {
|
||||
private final GroupId shareableId;
|
||||
private final long timestamp, autoDeleteTimer;
|
||||
private final boolean local, read, visible, available, accepted;
|
||||
private final boolean isAutoDecline;
|
||||
|
||||
MessageMetadata(MessageType type, GroupId shareableId, long timestamp,
|
||||
boolean local, boolean read, boolean visible, boolean available,
|
||||
boolean accepted, long autoDeleteTimer) {
|
||||
boolean accepted, long autoDeleteTimer, boolean isAutoDecline) {
|
||||
this.shareableId = shareableId;
|
||||
this.type = type;
|
||||
this.timestamp = timestamp;
|
||||
@@ -26,6 +27,7 @@ class MessageMetadata {
|
||||
this.available = available;
|
||||
this.accepted = accepted;
|
||||
this.autoDeleteTimer = autoDeleteTimer;
|
||||
this.isAutoDecline = isAutoDecline;
|
||||
}
|
||||
|
||||
MessageType getMessageType() {
|
||||
@@ -58,7 +60,7 @@ class MessageMetadata {
|
||||
|
||||
/**
|
||||
* Returns true if the invitation was accepted.
|
||||
*
|
||||
* <p>
|
||||
* Only applies to messages of type INVITE.
|
||||
*/
|
||||
public boolean wasAccepted() {
|
||||
@@ -68,4 +70,8 @@ class MessageMetadata {
|
||||
public long getAutoDeleteTimer() {
|
||||
return autoDeleteTimer;
|
||||
}
|
||||
|
||||
public boolean isAutoDecline() {
|
||||
return isAutoDecline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.briarproject.briar.sharing.MessageType.INVITE;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_AUTO_DELETE_TIMER;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_AVAILABLE_TO_ANSWER;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_INVITATION_ACCEPTED;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_IS_AUTO_DECLINE;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_LOCAL;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_MESSAGE_TYPE;
|
||||
import static org.briarproject.briar.sharing.SharingConstants.MSG_KEY_READ;
|
||||
@@ -74,8 +75,9 @@ abstract class MessageParserImpl<S extends Shareable>
|
||||
boolean accepted = meta.getBoolean(MSG_KEY_INVITATION_ACCEPTED, false);
|
||||
long timer = meta.getLong(MSG_KEY_AUTO_DELETE_TIMER,
|
||||
NO_AUTO_DELETE_TIMER);
|
||||
boolean isAutoDecline = meta.getBoolean(MSG_KEY_IS_AUTO_DECLINE, false);
|
||||
return new MessageMetadata(type, shareableId, timestamp, local, read,
|
||||
visible, available, accepted, timer);
|
||||
visible, available, accepted, timer, isAutoDecline);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,8 +16,8 @@ interface ProtocolEngine<S extends Shareable> {
|
||||
|
||||
Session onAcceptAction(Transaction txn, Session session) throws DbException;
|
||||
|
||||
Session onDeclineAction(Transaction txn, Session session)
|
||||
throws DbException;
|
||||
Session onDeclineAction(Transaction txn, Session session,
|
||||
boolean isAutoDecline) throws DbException;
|
||||
|
||||
Session onLeaveAction(Transaction txn, Session session) throws DbException;
|
||||
|
||||
|
||||
@@ -235,11 +235,11 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session onDeclineAction(Transaction txn, Session s)
|
||||
throws DbException {
|
||||
public Session onDeclineAction(Transaction txn, Session s,
|
||||
boolean isAutoDecline) throws DbException {
|
||||
switch (s.getState()) {
|
||||
case LOCAL_INVITED:
|
||||
return onLocalDecline(txn, s);
|
||||
return onLocalDecline(txn, s, isAutoDecline);
|
||||
case START:
|
||||
case REMOTE_INVITED:
|
||||
case SHARING:
|
||||
@@ -251,14 +251,14 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
}
|
||||
}
|
||||
|
||||
private Session onLocalDecline(Transaction txn, Session s)
|
||||
throws DbException {
|
||||
private Session onLocalDecline(Transaction txn, Session s,
|
||||
boolean isAutoDecline) throws DbException {
|
||||
// Mark the invite message unavailable to answer
|
||||
MessageId inviteId = s.getLastRemoteMessageId();
|
||||
if (inviteId == null) throw new IllegalStateException();
|
||||
markMessageAvailableToAnswer(txn, inviteId, false);
|
||||
// Send a DECLINE message
|
||||
Message sent = sendDeclineMessage(txn, s);
|
||||
Message sent = sendDeclineMessage(txn, s, isAutoDecline);
|
||||
// Track the message
|
||||
messageTracker.trackOutgoingMessage(txn, sent);
|
||||
// Move to the START state
|
||||
@@ -267,8 +267,8 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
s.getInviteTimestamp());
|
||||
}
|
||||
|
||||
private Message sendDeclineMessage(Transaction txn, Session s)
|
||||
throws DbException {
|
||||
private Message sendDeclineMessage(Transaction txn, Session s,
|
||||
boolean isAutoDecline) throws DbException {
|
||||
Message m;
|
||||
long localTimestamp = getTimestampForVisibleMessage(txn, s);
|
||||
ContactId c = getContactId(txn, s.getContactGroupId());
|
||||
@@ -278,11 +278,18 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
m = messageEncoder.encodeDeclineMessage(s.getContactGroupId(),
|
||||
s.getShareableId(), localTimestamp,
|
||||
s.getLastLocalMessageId(), timer);
|
||||
sendMessage(txn, m, DECLINE, s.getShareableId(), true, timer);
|
||||
sendMessage(txn, m, DECLINE, s.getShareableId(), true, timer,
|
||||
isAutoDecline);
|
||||
// Set the auto-delete timer duration on the local message
|
||||
if (timer != NO_AUTO_DELETE_TIMER) {
|
||||
db.setCleanupTimerDuration(txn, m.getId(), timer);
|
||||
}
|
||||
if (isAutoDecline) {
|
||||
// Broadcast an event, so the auto-decline becomes visible
|
||||
Event e = getAutoDeclineInvitationResponseReceivedEvent(
|
||||
s, m, c, timer);
|
||||
txn.attach(e);
|
||||
}
|
||||
} else {
|
||||
m = messageEncoder.encodeDeclineMessage(s.getContactGroupId(),
|
||||
s.getShareableId(), localTimestamp,
|
||||
@@ -293,6 +300,9 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
return m;
|
||||
}
|
||||
|
||||
abstract Event getAutoDeclineInvitationResponseReceivedEvent(Session s,
|
||||
Message m, ContactId contactId, long timer);
|
||||
|
||||
@Override
|
||||
public Session onLeaveAction(Transaction txn, Session s)
|
||||
throws DbException {
|
||||
@@ -406,8 +416,8 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
// Broadcast an event
|
||||
ContactId contactId =
|
||||
clientHelper.getContactId(txn, s.getContactGroupId());
|
||||
txn.attach(
|
||||
getInvitationRequestReceivedEvent(m, contactId, false, true));
|
||||
txn.attach(getInvitationRequestReceivedEvent(m, contactId, false,
|
||||
true));
|
||||
// Move to the next state
|
||||
return new Session(SHARING, s.getContactGroupId(), s.getShareableId(),
|
||||
s.getLastLocalMessageId(), m.getId(), s.getLocalTimestamp(),
|
||||
@@ -648,9 +658,16 @@ abstract class ProtocolEngineImpl<S extends Shareable>
|
||||
private void sendMessage(Transaction txn, Message m, MessageType type,
|
||||
GroupId shareableId, boolean visibleInConversation,
|
||||
long autoDeleteTimer) throws DbException {
|
||||
sendMessage(txn, m, type, shareableId, visibleInConversation,
|
||||
autoDeleteTimer, false);
|
||||
}
|
||||
|
||||
private void sendMessage(Transaction txn, Message m, MessageType type,
|
||||
GroupId shareableId, boolean visibleInConversation,
|
||||
long autoDeleteTimer, boolean isAutoDecline) throws DbException {
|
||||
BdfDictionary meta = messageEncoder.encodeMetadata(type, shareableId,
|
||||
m.getTimestamp(), true, true, visibleInConversation, false,
|
||||
false, autoDeleteTimer);
|
||||
false, autoDeleteTimer, isAutoDecline);
|
||||
try {
|
||||
clientHelper.addLocalMessage(txn, m, meta, true, false);
|
||||
} catch (FormatException e) {
|
||||
|
||||
@@ -14,6 +14,7 @@ interface SharingConstants {
|
||||
String MSG_KEY_AVAILABLE_TO_ANSWER = "availableToAnswer";
|
||||
String MSG_KEY_INVITATION_ACCEPTED = "invitationAccepted";
|
||||
String MSG_KEY_AUTO_DELETE_TIMER = "autoDeleteTimer";
|
||||
String MSG_KEY_IS_AUTO_DECLINE = "isAutoDecline";
|
||||
|
||||
// Session keys
|
||||
String SESSION_KEY_IS_SESSION = "isSession";
|
||||
|
||||
@@ -302,11 +302,13 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
@Override
|
||||
public void respondToInvitation(ContactId c, SessionId id, boolean accept)
|
||||
throws DbException {
|
||||
db.transaction(false, txn -> respondToInvitation(txn, c, id, accept));
|
||||
db.transaction(false,
|
||||
txn -> respondToInvitation(txn, c, id, accept, false));
|
||||
}
|
||||
|
||||
private void respondToInvitation(Transaction txn, ContactId c,
|
||||
SessionId id, boolean accept) throws DbException {
|
||||
SessionId id, boolean accept, boolean isAutoDecline)
|
||||
throws DbException {
|
||||
try {
|
||||
// Look up the session
|
||||
Contact contact = db.getContact(txn, c);
|
||||
@@ -318,7 +320,7 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
sessionParser.parseSession(contactGroupId, ss.bdfSession);
|
||||
// Handle the accept or decline action
|
||||
if (accept) session = engine.onAcceptAction(txn, session);
|
||||
else session = engine.onDeclineAction(txn, session);
|
||||
else session = engine.onDeclineAction(txn, session, isAutoDecline);
|
||||
// Store the updated session
|
||||
storeSession(txn, ss.storageId, session);
|
||||
} catch (FormatException e) {
|
||||
@@ -381,7 +383,7 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
return invitationFactory.createInvitationResponse(m, contactGroupId,
|
||||
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
||||
status.isSeen(), meta.isRead(), accept, meta.getShareableId(),
|
||||
meta.getAutoDeleteTimer());
|
||||
meta.getAutoDeleteTimer(), meta.isAutoDecline());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -583,7 +585,6 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
}, messageId -> false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DeletionResult deleteMessages(Transaction txn, ContactId c,
|
||||
Set<MessageId> messageIds) throws DbException {
|
||||
@@ -731,9 +732,10 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
// delete given visible messages in sessions
|
||||
for (Entry<SessionId, DeletableSession> entry : sessions.entrySet()) {
|
||||
DeletableSession session = entry.getValue();
|
||||
// first decline pending shareable we're invited to
|
||||
// first decline pending invitation to shareable
|
||||
if (session.state == LOCAL_INVITED) {
|
||||
respondToInvitation(txn, c, entry.getKey(), false);
|
||||
// marked as autoDecline
|
||||
respondToInvitation(txn, c, entry.getKey(), false, true);
|
||||
}
|
||||
for (MessageId m : session.messages) {
|
||||
db.deleteMessage(txn, m);
|
||||
|
||||
@@ -74,7 +74,8 @@ abstract class SharingValidator extends BdfMessageValidator {
|
||||
}
|
||||
|
||||
BdfDictionary meta = messageEncoder.encodeMetadata(INVITE, shareableId,
|
||||
m.getTimestamp(), false, false, false, false, false, timer);
|
||||
m.getTimestamp(), false, false, false, false, false, timer,
|
||||
false);
|
||||
if (previousMessageId == null) {
|
||||
return new BdfMessageContext(meta);
|
||||
} else {
|
||||
@@ -96,7 +97,7 @@ abstract class SharingValidator extends BdfMessageValidator {
|
||||
|
||||
BdfDictionary meta = messageEncoder.encodeMetadata(type,
|
||||
new GroupId(shareableId), m.getTimestamp(), false, false,
|
||||
false, false, false, NO_AUTO_DELETE_TIMER);
|
||||
false, false, false, NO_AUTO_DELETE_TIMER, false);
|
||||
if (previousMessageId == null) {
|
||||
return new BdfMessageContext(meta);
|
||||
} else {
|
||||
@@ -123,7 +124,7 @@ abstract class SharingValidator extends BdfMessageValidator {
|
||||
|
||||
BdfDictionary meta = messageEncoder.encodeMetadata(type,
|
||||
new GroupId(shareableId), m.getTimestamp(), false, false,
|
||||
false, false, false, timer);
|
||||
false, false, false, timer, false);
|
||||
if (previousMessageId == null) {
|
||||
return new BdfMessageContext(meta);
|
||||
} else {
|
||||
|
||||
@@ -16,19 +16,17 @@ import static org.junit.Assert.assertTrue;
|
||||
public abstract class AbstractAutoDeleteIntegrationTest
|
||||
extends AbstractAutoDeleteTest {
|
||||
|
||||
protected SharingManager<?> sharingManager0;
|
||||
protected SharingManager<? extends Shareable> sharingManager0;
|
||||
protected Shareable shareable;
|
||||
|
||||
protected void testAutoDeclinedSharing(SharingManager<?> sharingManager0,
|
||||
protected void testAutoDeclinedSharing(
|
||||
SharingManager<? extends Shareable> sharingManager0,
|
||||
Shareable shareable) throws Exception {
|
||||
setAutoDeleteTimer(c0, contactId1From0, MIN_AUTO_DELETE_TIMER_MS);
|
||||
|
||||
assertGroupCount(c0, contactId1From0, 1, 0);
|
||||
|
||||
// Send invitation
|
||||
sharingManager0
|
||||
.sendInvitation(shareable.getId(), contactId1From0,
|
||||
"This shareable!");
|
||||
sharingManager0.sendInvitation(
|
||||
shareable.getId(), contactId1From0, "This shareable!");
|
||||
|
||||
// The message should have been added to 0's view of the conversation
|
||||
assertGroupCount(c0, contactId1From0, 1, 0);
|
||||
@@ -99,7 +97,7 @@ public abstract class AbstractAutoDeleteIntegrationTest
|
||||
assertNotEquals(messageId0, h.getId());
|
||||
assertTrue(h instanceof InvitationResponse);
|
||||
assertFalse(((InvitationResponse) h).wasAccepted());
|
||||
//TODO assertTrue(((InvitationResponse) h).isAutoDecline());
|
||||
assertTrue(((InvitationResponse) h).isAutoDecline());
|
||||
// The auto-decline message should have the expected timer
|
||||
assertEquals(MIN_AUTO_DELETE_TIMER_MS,
|
||||
h.getAutoDeleteTimer());
|
||||
@@ -152,8 +150,7 @@ public abstract class AbstractAutoDeleteIntegrationTest
|
||||
assertTrue(sharingManager0
|
||||
.canBeShared(shareable.getId(), contact1From0));
|
||||
// Send invitation
|
||||
sharingManager0
|
||||
.sendInvitation(shareable.getId(), contactId1From0,
|
||||
sharingManager0.sendInvitation(shareable.getId(), contactId1From0,
|
||||
"This shareable, please be quick!");
|
||||
sync0To1(1, true);
|
||||
assertGroupCount(c1, contactId0From1, 1, 1);
|
||||
|
||||
@@ -210,7 +210,7 @@ public abstract class SharingValidatorTest extends ValidatorTestCase {
|
||||
void expectEncodeMetadata(MessageType type, long autoDeleteTimer) {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(messageEncoder).encodeMetadata(type, groupId, timestamp,
|
||||
false, false, false, false, false, autoDeleteTimer);
|
||||
false, false, false, false, false, autoDeleteTimer, false);
|
||||
will(returnValue(meta));
|
||||
}});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user