session-ios/SignalServiceKit/src/Account/TSAttributes.m

37 lines
1.2 KiB
Objective-C

//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSAttributes.h"
#import "TSAccountManager.h"
#import "TSStorageManager+keyingMaterial.h"
NS_ASSUME_NONNULL_BEGIN
@implementation TSAttributes
+ (NSDictionary *)attributesFromStorageWithManualMessageFetching:(BOOL)isEnabled
{
return [self attributesWithSignalingKey:[TSStorageManager signalingKey]
serverAuthToken:[TSStorageManager serverAuthToken]
manualMessageFetching:isEnabled];
}
+ (NSDictionary *)attributesWithSignalingKey:(NSString *)signalingKey
serverAuthToken:(NSString *)authToken
manualMessageFetching:(BOOL)isEnabled
{
return @{
@"signalingKey" : signalingKey,
@"AuthKey" : authToken,
@"voice" : @(YES), // all Signal-iOS clients support voice
@"video" : @(YES), // all Signal-iOS clients support WebRTC-based voice and video calls.
@"fetchesMessages" : @(isEnabled), // devices that don't support push must tell the server they fetch messages manually
@"registrationId" : [NSString stringWithFormat:@"%i", [TSAccountManager getOrGenerateRegistrationId]]
};
}
@end
NS_ASSUME_NONNULL_END