Fix friend request acceptance bug

This commit is contained in:
Niels Andriesse 2019-05-17 14:03:04 +10:00
parent 3c838c59b2
commit 2e8d62b3ee
3 changed files with 4 additions and 5 deletions

View File

@ -4301,6 +4301,9 @@ typedef enum : NSUInteger {
- (void)acceptFriendRequest:(TSIncomingMessage *)friendRequest
{
// Update the thread's friend request state
[self.thread setFriendRequestStatus:TSThreadFriendRequestStatusFriends withTransaction:nil];
// Send friend request accepted message
[ThreadUtil enqueueAcceptFriendRequestMessageInThread:self.thread];
}

View File

@ -1485,8 +1485,8 @@ NS_ASSUME_NONNULL_BEGIN
// friend request status is reset to TSThreadFriendRequestStatusNone. Bob now sends Alice a friend
// request. Alice's thread's friend request status is reset to
// TSThreadFriendRequestStatusRequestReceived.
message.isFriendRequest = YES; // It's important that this happens before the friend request status update below
[thread setFriendRequestStatus:TSThreadFriendRequestStatusRequestReceived withTransaction:transaction];
message.isFriendRequest = YES;
}
} else if (!thread.isContactFriend) {
// If the thread's friend request status is not TSThreadFriendRequestStatusFriends, but we're receiving a message,

View File

@ -1119,10 +1119,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
// ========
if (messageType == TSFriendRequestMessageType) {
[message.thread setFriendRequestStatus:TSThreadFriendRequestStatusRequestSent withTransaction:nil];
} else if (message.thread.hasCurrentUserReceivedFriendRequest) {
// If the thread's current friend request state is TSThreadFriendRequestStatusRequestReceived, and we're sending a message,
// that means we're accepting the request. Declining a friend request doesn't send a message.
[message.thread setFriendRequestStatus:TSThreadFriendRequestStatusFriends withTransaction:nil];
}
// ========
// Invoke the completion handler