Support for profile fetching so we can display SN changes upon entering

a thread

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent b89d16ea90
commit fe075d2f77

@ -36,6 +36,11 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (nullable NSString *)contactIdentifier; - (nullable NSString *)contactIdentifier;
/**
* @returns recipientId for each recipient in the thread
*/
@property (nonatomic, readonly) NSArray<NSString *> *recipientIdentifiers;
#if TARGET_OS_IOS #if TARGET_OS_IOS
/** /**

@ -84,6 +84,12 @@ NS_ASSUME_NONNULL_BEGIN
return nil; return nil;
} }
- (NSArray<NSString *> *)recipientIdentifiers
{
NSAssert(FALSE, @"Should be implemented in subclasses");
return @[];
}
- (nullable UIImage *)image - (nullable UIImage *)image
{ {
return nil; return nil;

@ -80,6 +80,11 @@ NS_ASSUME_NONNULL_BEGIN
return [[self class] contactIdFromThreadId:self.uniqueId]; return [[self class] contactIdFromThreadId:self.uniqueId];
} }
- (NSArray<NSString *> *)recipientIdentifiers
{
return @[self.contactIdentifier];
}
- (BOOL)isGroupThread { - (BOOL)isGroupThread {
return false; return false;
} }

@ -6,6 +6,7 @@
#import "NSData+Base64.h" #import "NSData+Base64.h"
#import "SignalRecipient.h" #import "SignalRecipient.h"
#import "TSAttachmentStream.h" #import "TSAttachmentStream.h"
#import <SignalServiceKit/TSAccountManager.h>
#import <YapDatabase/YapDatabaseConnection.h> #import <YapDatabase/YapDatabaseConnection.h>
#import <YapDatabase/YapDatabaseTransaction.h> #import <YapDatabase/YapDatabaseTransaction.h>
@ -86,6 +87,18 @@ NS_ASSUME_NONNULL_BEGIN
return [NSData dataFromBase64String:[threadId substringWithRange:NSMakeRange(1, threadId.length - 1)]]; return [NSData dataFromBase64String:[threadId substringWithRange:NSMakeRange(1, threadId.length - 1)]];
} }
- (NSArray<NSString *> *)recipientIdentifiers
{
NSMutableArray<NSString *> *groupMemberIds = [self.groupModel.groupMemberIds mutableCopy];
if (groupMemberIds == nil) {
return @[];
}
[groupMemberIds removeObject:[TSAccountManager localNumber]];
return [groupMemberIds copy];
}
// Group and Contact threads share a collection, this is a convenient way to enumerate *just* the group threads // 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 + (void)enumerateGroupThreadsUsingBlock:(void (^)(TSGroupThread *groupThread, BOOL *stop))block
{ {

@ -0,0 +1,15 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSRequest.h"
NS_ASSUME_NONNULL_BEGIN
@interface OWSGetProfileRequest : TSRequest
- (instancetype)initWithRecipientId:(NSString *)recipientId;
@end
NS_ASSUME_NONNULL_END

@ -0,0 +1,31 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSGetProfileRequest.h"
NS_ASSUME_NONNULL_BEGIN
NSString *const OWSProfileRequestPathFormat = @"v1/profile/%@";
@implementation OWSGetProfileRequest
- (instancetype)initWithRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
NSString *path =[NSString stringWithFormat:OWSProfileRequestPathFormat, recipientId];
self = [super initWithURL:[NSURL URLWithString:path]];
if (!self) {
return self;
}
self.HTTPMethod = @"GET";
self.parameters = nil;
return self;
}
@end
NS_ASSUME_NONNULL_END

@ -1,9 +1,5 @@
// //
// TSStorageManager+keyingMaterial.m // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// TextSecureKit
//
// Created by Frederic Jacobs on 06/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
// //
#import "TSStorageManager+keyingMaterial.h" #import "TSStorageManager+keyingMaterial.h"
@ -17,6 +13,7 @@
- (NSString *)localNumber - (NSString *)localNumber
{ {
// TODO cache this? It only changes once, ever, and otherwise causes "surprising" transactions to occur.
return [self stringForKey:TSStorageRegisteredNumberKey inCollection:TSStorageUserAccountCollection]; return [self stringForKey:TSStorageRegisteredNumberKey inCollection:TSStorageUserAccountCollection];
} }

Loading…
Cancel
Save