Fix restoration from seed part 1

pull/64/head
Niels Andriesse 6 years ago
parent 6e5169206d
commit 145a3beb0a

@ -1498,7 +1498,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
// Loki: Do this before the check below // Loki: Do this before the check below
[self handleFriendRequestMessageIfNeededWithEnvelope:envelope message:incomingMessage thread:thread transaction:transaction]; [self handleFriendRequestMessageIfNeededWithEnvelope:envelope data:dataMessage message:incomingMessage thread:thread transaction:transaction];
if (body.length == 0 && attachmentPointers.count < 1 && !contact) { if (body.length == 0 && attachmentPointers.count < 1 && !contact) {
OWSLogWarn(@"ignoring empty incoming message from: %@ with timestamp: %lu", OWSLogWarn(@"ignoring empty incoming message from: %@ with timestamp: %lu",
@ -1525,7 +1525,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
- (void)handleFriendRequestMessageIfNeededWithEnvelope:(SSKProtoEnvelope *)envelope message:(TSIncomingMessage *)message thread:(TSThread *)thread transaction:(YapDatabaseReadWriteTransaction *)transaction { - (void)handleFriendRequestMessageIfNeededWithEnvelope:(SSKProtoEnvelope *)envelope data:(SSKProtoDataMessage *)data message:(TSIncomingMessage *)message thread:(TSThread *)thread transaction:(YapDatabaseReadWriteTransaction *)transaction {
if (envelope.isGroupChatMessage || envelope.type != SSKProtoEnvelopeTypeFriendRequest) return; if (envelope.isGroupChatMessage || envelope.type != SSKProtoEnvelopeTypeFriendRequest) return;
if (thread.hasCurrentUserSentFriendRequest) { if (thread.hasCurrentUserSentFriendRequest) {
// This can happen if Alice sent Bob a friend request, Bob declined, but then Bob changed his // This can happen if Alice sent Bob a friend request, Bob declined, but then Bob changed his
@ -1546,14 +1546,18 @@ NS_ASSUME_NONNULL_BEGIN
// The two lines below are equivalent to calling [ThreadUtil enqueueFriendRequestAcceptanceMessageInThread:thread] // The two lines below are equivalent to calling [ThreadUtil enqueueFriendRequestAcceptanceMessageInThread:thread]
LKEphemeralMessage *backgroundMessage = [[LKEphemeralMessage alloc] initInThread:thread]; LKEphemeralMessage *backgroundMessage = [[LKEphemeralMessage alloc] initInThread:thread];
[self.messageSenderJobQueue addMessage:backgroundMessage transaction:transaction]; [self.messageSenderJobQueue addMessage:backgroundMessage transaction:transaction];
} else if (!thread.isContactFriend) { } else {
// Checking that the sender of the message isn't already a friend is necessary because otherwise if (!thread.isContactFriend) {
// the following situation can occur: Alice and Bob are friends. Bob loses his database and his // Checking that the sender of the message isn't already a friend is necessary because otherwise
// friend request status is reset to LKThreadFriendRequestStatusNone. Bob now sends Alice a friend // the following situation can occur: Alice and Bob are friends. Bob loses his database and his
// request. Alice's thread's friend request status is reset to // friend request status is reset to LKThreadFriendRequestStatusNone. Bob now sends Alice a friend
// LKThreadFriendRequestStatusRequestReceived. // request. Alice's thread's friend request status is reset to
[thread saveFriendRequestStatus:LKThreadFriendRequestStatusRequestReceived withTransaction:transaction]; // LKThreadFriendRequestStatusRequestReceived.
message.friendRequestStatus = LKMessageFriendRequestStatusPending; // Don't save yet. This is done in finalizeIncomingMessage:thread:envelope:transaction. [thread saveFriendRequestStatus:LKThreadFriendRequestStatusRequestReceived withTransaction:transaction];
message.friendRequestStatus = LKMessageFriendRequestStatusPending; // Don't save yet. This is done in finalizeIncomingMessage:thread:envelope:transaction.
} else {
[self handleEndSessionMessageWithEnvelope:envelope dataMessage:data transaction:transaction];
}
} }
} }

Loading…
Cancel
Save