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

46 lines
1.5 KiB
Mathematica
Raw Normal View History

2015-12-07 03:31:43 +01:00
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
2015-12-07 03:31:43 +01:00
//
#import "TSAttributes.h"
#import "TSAccountManager.h"
NS_ASSUME_NONNULL_BEGIN
2015-12-07 03:31:43 +01:00
@implementation TSAttributes
+ (NSDictionary *)attributesFromStorageWithManualMessageFetching:(BOOL)isEnabled pin:(nullable NSString *)pin
{
2017-11-02 14:58:33 +01:00
return [self attributesWithSignalingKey:TSAccountManager.signalingKey
serverAuthToken:TSAccountManager.serverAuthToken
manualMessageFetching:isEnabled
pin:pin];
2015-12-07 03:31:43 +01:00
}
+ (NSDictionary *)attributesWithSignalingKey:(NSString *)signalingKey
serverAuthToken:(NSString *)authToken
manualMessageFetching:(BOOL)isEnabled
pin:(nullable NSString *)pin
2015-12-07 03:31:43 +01:00
{
OWSAssertDebug(signalingKey.length > 0);
OWSAssertDebug(authToken.length > 0);
2017-12-05 19:42:50 +01:00
NSMutableDictionary *result = [@{
2015-12-07 03:31:43 +01:00
@"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
2015-12-07 03:31:43 +01:00
@"registrationId" : [NSString stringWithFormat:@"%i", [TSAccountManager getOrGenerateRegistrationId]]
} mutableCopy];
if (pin.length > 0) {
result[@"pin"] = pin;
}
return [result copy];
2015-12-07 03:31:43 +01:00
}
@end
NS_ASSUME_NONNULL_END