|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
// Created by Frederic Jacobs on 16/11/14.
|
|
|
|
|
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "TSGroupThread.h"
|
|
|
|
|
#import "NSData+Base64.h"
|
|
|
|
@ -85,6 +86,34 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
return [NSData dataFromBase64String:[threadId substringWithRange:NSMakeRange(1, threadId.length - 1)]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Group and Contact threads share a collection, this is a convenient way to enumerate *just* the group threads
|
|
|
|
|
+ (void)enumerateGroupThreadsUsingBlock:(void (^)(TSGroupThread *groupThread, BOOL *stop))block
|
|
|
|
|
{
|
|
|
|
|
[self enumerateCollectionObjectsUsingBlock:^(id obj, BOOL *stop) {
|
|
|
|
|
if ([obj isKindOfClass:[TSGroupThread class]]) {
|
|
|
|
|
block((TSGroupThread *)obj, stop);
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @returns all threads to which the recipient is a member.
|
|
|
|
|
//
|
|
|
|
|
// @note If this becomes a hotspot we can extract into a YapDB View.
|
|
|
|
|
// As is, the number of groups should be small (dozens, *maybe* hundreds), and we only enumerate them upon SN changes.
|
|
|
|
|
+ (NSArray<TSGroupThread *> *)groupThreadsWithRecipientId:(NSString *)recipientId
|
|
|
|
|
{
|
|
|
|
|
NSMutableArray<TSGroupThread *> *groupThreads = [NSMutableArray new];
|
|
|
|
|
|
|
|
|
|
[self enumerateGroupThreadsUsingBlock:^(TSGroupThread *_Nonnull groupThread, BOOL *_Nonnull stop) {
|
|
|
|
|
if ([groupThread.groupModel.groupMemberIds containsObject:recipientId]) {
|
|
|
|
|
[groupThreads addObject:groupThread];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
return [groupThreads copy];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL)isGroupThread
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|