check if the linked device is a member of the closed group

pull/104/head
Ryan ZHAO 5 years ago
parent c3c080eb59
commit 7bafd94643

@ -38,6 +38,7 @@ extern NSString *const TSGroupThread_NotificationKey_UniqueId;
- (BOOL)isLocalUserInGroup;
- (BOOL)isLocalUserInGroupWithTransaction:(YapDatabaseReadTransaction *)transaction;
- (BOOL)isUserInGroup:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction;
// all group threads containing recipient as a member
+ (NSArray<TSGroupThread *> *)groupThreadsWithRecipientId:(NSString *)recipientId

@ -204,6 +204,13 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
return [linkedDeviceHexEncodedPublicKeys intersectsSet:[NSSet setWithArray:self.groupModel.groupMemberIds]];
}
- (BOOL)isUserInGroup:(NSString *)hexEncodedPublicKey transaction:(YapDatabaseReadWriteTransaction *)transaction
{
if (hexEncodedPublicKey == nil) { return NO; }
NSSet<NSString *> *linkedDeviceHexEncodedPublicKeys = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:hexEncodedPublicKey in:transaction];
return [linkedDeviceHexEncodedPublicKeys intersectsSet:[NSSet setWithArray:self.groupModel.groupMemberIds]];
}
- (NSString *)name
{
// TODO sometimes groupName is set to the empty string. I'm hesitent to change

@ -1360,7 +1360,7 @@ NS_ASSUME_NONNULL_BEGIN
}
// Ensure sender is in the group.
if (![gThread.groupModel.groupMemberIds containsObject:envelope.source]) {
if (![gThread isUserInGroup:envelope.source transaction:transaction]) {
OWSLogWarn(@"Ignoring 'Request Group Info' message for non-member of group. %@ not in %@",
envelope.source,
gThread.groupModel.groupMemberIds);

Loading…
Cancel
Save