Add "log user profiles" debug UI action.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-09-07 15:33:12 -04:00
parent d8d3f36070
commit 0c281cab95
3 changed files with 35 additions and 3 deletions

View File

@ -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;

View File

@ -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), ^{

View File

@ -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))")
}
}
]