mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/contactsAndProfilesVsDebugUI'
This commit is contained in:
commit
94f02c0d1d
|
@ -71,6 +71,9 @@ extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
|
|||
|
||||
#pragma mark - Other User's Profiles
|
||||
|
||||
// This method is for debugging.
|
||||
- (void)logUserProfiles;
|
||||
|
||||
- (nullable OWSAES256Key *)profileKeyForRecipientId:(NSString *)recipientId;
|
||||
|
||||
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId;
|
||||
|
|
|
@ -934,6 +934,32 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
|||
|
||||
#pragma mark - Other User's Profiles
|
||||
|
||||
- (void)logUserProfiles
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
@synchronized(self)
|
||||
{
|
||||
DDLogError(@"logUserProfiles: %zd", [self.dbConnection numberOfKeysInCollection:UserProfile.collection]);
|
||||
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
[transaction
|
||||
enumerateKeysAndObjectsInCollection:UserProfile.collection
|
||||
usingBlock:^(
|
||||
NSString *_Nonnull key, id _Nonnull object, BOOL *_Nonnull stop) {
|
||||
OWSAssert([object isKindOfClass:[UserProfile class]]);
|
||||
UserProfile *userProfile = object;
|
||||
DDLogError(@"\t [%@]: has profile key: %d, has avatar URL: %d, has "
|
||||
@"avatar file: %d, name: %@",
|
||||
userProfile.recipientId,
|
||||
userProfile.profileKey != nil,
|
||||
userProfile.avatarUrlPath != nil,
|
||||
userProfile.avatarFileName != nil,
|
||||
userProfile.profileName);
|
||||
}];
|
||||
}];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)setProfileKeyData:(NSData *)profileKeyData forRecipientId:(NSString *)recipientId;
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
|
|
|
@ -54,6 +54,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
actionBlock:^{
|
||||
[DebugUIContacts deleteRandomContacts];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Delete All Contacts"
|
||||
actionBlock:^{
|
||||
[DebugUIContacts deleteAllContacts];
|
||||
}],
|
||||
]];
|
||||
}
|
||||
|
||||
|
@ -1240,8 +1244,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}];
|
||||
}
|
||||
|
||||
+ (void)deleteRandomContacts
|
||||
+ (void)deleteContactsWithFilter:(BOOL (^_Nonnull)(CNContact *contact))filterBlock
|
||||
{
|
||||
OWSAssert(filterBlock);
|
||||
|
||||
CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
|
||||
if (status == CNAuthorizationStatusDenied || status == CNAuthorizationStatusRestricted) {
|
||||
[OWSAlerts showAlertWithTitle:@"Error" message:@"No contacts access."];
|
||||
|
@ -1270,7 +1276,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[store enumerateContactsWithFetchRequest:fetchRequest
|
||||
error:&fetchError
|
||||
usingBlock:^(CNContact *contact, BOOL *stop) {
|
||||
if ([contact.familyName hasPrefix:@"Rando-"]) {
|
||||
if (filterBlock(contact)) {
|
||||
[request deleteContact:[contact mutableCopy]];
|
||||
}
|
||||
}];
|
||||
|
@ -1286,6 +1292,20 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}];
|
||||
}
|
||||
|
||||
+ (void)deleteAllContacts
|
||||
{
|
||||
[self deleteContactsWithFilter:^(CNContact *contact) {
|
||||
return YES;
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)deleteRandomContacts
|
||||
{
|
||||
[self deleteContactsWithFilter:^(CNContact *contact) {
|
||||
return [contact.familyName hasPrefix:@"Rando-"];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -31,15 +31,18 @@ class DebugUIProfile: DebugUIPage {
|
|||
OWSTableItem(title: "Log Profile Whitelist") {
|
||||
self.profileManager.logProfileWhitelist()
|
||||
},
|
||||
OWSTableItem(title: "Log User Profiles") {
|
||||
self.profileManager.logUserProfiles()
|
||||
},
|
||||
OWSTableItem(title: "Regenerate Profile/ProfileKey") {
|
||||
self.profileManager.regenerateLocalProfile()
|
||||
},
|
||||
OWSTableItem(title: "Send profile key message.") {
|
||||
OWSTableItem(title: "Send Profile Key Message") {
|
||||
let message = OWSProfileKeyMessage(timestamp: NSDate.ows_millisecondTimeStamp(), in: aThread)
|
||||
self.messageSender.sendPromise(message: message).then {
|
||||
Logger.info("Successfully sent profile key message to thread: \(String(describing: aThread))")
|
||||
}.catch { _ in
|
||||
owsFail("Failed to send profile key message to thread: \(String(describing: aThread))")
|
||||
}.catch { _ in
|
||||
owsFail("Failed to send profile key message to thread: \(String(describing: aThread))")
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue