2015-12-07 03:31:43 +01:00
|
|
|
//
|
2018-03-03 00:09:47 +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"
|
|
|
|
|
2017-10-11 16:23:24 +02:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2015-12-07 03:31:43 +01:00
|
|
|
@implementation TSAttributes
|
|
|
|
|
2018-03-03 00:09:47 +01:00
|
|
|
+ (NSDictionary *)attributesFromStorageWithManualMessageFetching:(BOOL)isEnabled pin:(nullable NSString *)pin
|
2017-10-11 16:23:24 +02:00
|
|
|
{
|
2017-11-02 14:58:33 +01:00
|
|
|
return [self attributesWithSignalingKey:TSAccountManager.signalingKey
|
|
|
|
serverAuthToken:TSAccountManager.serverAuthToken
|
2018-03-03 00:09:47 +01:00
|
|
|
manualMessageFetching:isEnabled
|
|
|
|
pin:pin];
|
2015-12-07 03:31:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSDictionary *)attributesWithSignalingKey:(NSString *)signalingKey
|
|
|
|
serverAuthToken:(NSString *)authToken
|
2017-10-11 16:23:24 +02:00
|
|
|
manualMessageFetching:(BOOL)isEnabled
|
2018-03-03 00:09:47 +01:00
|
|
|
pin:(nullable NSString *)pin
|
2015-12-07 03:31:43 +01:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(signalingKey.length > 0);
|
|
|
|
OWSAssertDebug(authToken.length > 0);
|
2017-12-05 19:42:50 +01:00
|
|
|
|
2018-03-03 00:09:47 +01:00
|
|
|
NSMutableDictionary *result = [@{
|
2015-12-07 03:31:43 +01:00
|
|
|
@"signalingKey" : signalingKey,
|
|
|
|
@"AuthKey" : authToken,
|
2017-02-21 17:00:49 +01:00
|
|
|
@"voice" : @(YES), // all Signal-iOS clients support voice
|
|
|
|
@"video" : @(YES), // all Signal-iOS clients support WebRTC-based voice and video calls.
|
2018-03-03 00:09:47 +01:00
|
|
|
@"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]]
|
2018-03-03 00:09:47 +01:00
|
|
|
} mutableCopy];
|
|
|
|
if (pin.length > 0) {
|
|
|
|
result[@"pin"] = pin;
|
|
|
|
}
|
|
|
|
return [result copy];
|
2015-12-07 03:31:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2017-10-11 16:23:24 +02:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|