Merge branch 'mkirk/profile-request'

pull/1/head
Michael Kirk 8 years ago
commit 0201fa34ce

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

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

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

@ -6,6 +6,7 @@
#import "NSData+Base64.h"
#import "SignalRecipient.h"
#import "TSAttachmentStream.h"
#import <SignalServiceKit/TSAccountManager.h>
#import <YapDatabase/YapDatabaseConnection.h>
#import <YapDatabase/YapDatabaseTransaction.h>
@ -86,6 +87,18 @@ NS_ASSUME_NONNULL_BEGIN
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
+ (void)enumerateGroupThreadsUsingBlock:(void (^)(TSGroupThread *groupThread, BOOL *stop))block
{

@ -46,11 +46,11 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)attachmentsFolder;
+ (NSUInteger)numberOfItemsInAttachmentsFolder;
- (CGSize)cachedImageSizeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (CGSize)cachedImageSizeWithoutTransaction;
- (CGSize)imageSizeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (CGSize)imageSizeWithoutTransaction;
- (CGFloat)cachedAudioDurationSecondsWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (CGFloat)cachedAudioDurationSecondsWithoutTransaction;
- (CGFloat)audioDurationSecondsWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (CGFloat)audioDurationSecondsWithoutTransaction;
@end

@ -374,19 +374,15 @@ NS_ASSUME_NONNULL_BEGIN
return imageSize;
}
- (CGSize)cachedImageSizeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
- (CGSize)imageSizeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert([NSThread isMainThread]);
OWSAssert(transaction);
if (self.cachedImageWidth && self.cachedImageHeight) {
return CGSizeMake(self.cachedImageWidth.floatValue, self.cachedImageHeight.floatValue);
}
return [self ensureCachedImageSizeWithTransaction:transaction];
}
- (CGSize)cachedImageSizeWithoutTransaction
- (CGSize)imageSizeWithoutTransaction
{
OWSAssert([NSThread isMainThread]);
@ -449,19 +445,15 @@ NS_ASSUME_NONNULL_BEGIN
return audioDurationSeconds;
}
- (CGFloat)cachedAudioDurationSecondsWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
- (CGFloat)audioDurationSecondsWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert([NSThread isMainThread]);
OWSAssert(transaction);
if (self.cachedAudioDurationSeconds) {
return self.cachedAudioDurationSeconds.floatValue;
}
return [self ensureCachedAudioDurationSecondsWithTransaction:transaction];
}
- (CGFloat)cachedAudioDurationSecondsWithoutTransaction
- (CGFloat)audioDurationSecondsWithoutTransaction
{
OWSAssert([NSThread isMainThread]);

@ -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,30 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSGetProfileRequest.h"
#import "TSConstants.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSGetProfileRequest
- (instancetype)initWithRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
NSString *path = [NSString stringWithFormat:textSecureProfileAPIFormat, 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
// TextSecureKit
//
// Created by Frederic Jacobs on 06/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSStorageManager+keyingMaterial.h"
@ -17,6 +13,7 @@
- (NSString *)localNumber
{
// TODO cache this? It only changes once, ever, and otherwise causes "surprising" transactions to occur.
return [self stringForKey:TSStorageRegisteredNumberKey inCollection:TSStorageUserAccountCollection];
}

@ -1,5 +1,6 @@
// Created by Frederic Jacobs on 28/10/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
@class TSNumberVerifier;
@ -39,6 +40,7 @@ typedef enum { kSMSVerification, kPhoneNumberVerification } VerificationTranspor
#define textSecureDeviceProvisioningCodeAPI @"v1/devices/provisioning/code"
#define textSecureDeviceProvisioningAPIFormat @"v1/provisioning/%@"
#define textSecureDevicesAPIFormat @"v1/devices/%@"
#define textSecureProfileAPIFormat @"v1/profile/%@"
#pragma mark Push RegistrationSpecific Constants
typedef NS_ENUM(NSInteger, TSPushRegistrationError) {

Loading…
Cancel
Save