Update our profile key if our primary device sends a message on the public chat.
This commit is contained in:
parent
1a9ad0062b
commit
b2a2cd8d20
|
@ -346,11 +346,13 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
|
|||
[self.localUserProfile updateWithProfileName:displayName transaction:transaction];
|
||||
}
|
||||
|
||||
- (void)updateUserPofileKeyData:(NSData *)profileKeyData avatarURL:(nullable NSString *)avatarURL transaction:(YapDatabaseReadWriteTransaction *)transaction {
|
||||
- (void)updateUserProfileKeyData:(NSData *)profileKeyData avatarURL:(nullable NSString *)avatarURL transaction:(YapDatabaseReadWriteTransaction *)transaction {
|
||||
OWSAES256Key *profileKey = [OWSAES256Key keyWithData:profileKeyData];
|
||||
if (profileKey != nil) {
|
||||
[self.localUserProfile updateWithProfileKey:profileKey transaction:transaction completion:^{
|
||||
[self.localUserProfile updateWithAvatarUrlPath:avatarURL transaction:transaction];
|
||||
[self.localUserProfile updateWithAvatarUrlPath:avatarURL transaction:transaction completion:^{
|
||||
[self downloadAvatarForUserProfile:self.localUserProfile];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
@ -469,6 +471,10 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
|
|||
successBlock();
|
||||
}
|
||||
|
||||
- (void)updateServiceWithProfileName:(nullable NSString *)localProfileName avatarUrl:(nullable NSString *)avatarURL {
|
||||
[self updateServiceWithProfileName:localProfileName avatarUrl:avatarURL success:^{} failure:^(NSError * _Nonnull error) {}];
|
||||
}
|
||||
|
||||
- (void)fetchLocalUsersProfile
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
|
|
@ -82,7 +82,7 @@ extern NSString *const kLocalProfileUniqueId;
|
|||
completion:(nullable OWSUserProfileCompletion)completion;
|
||||
|
||||
- (void)updateWithProfileName:(nullable NSString *)profileName transaction:(YapDatabaseReadWriteTransaction*)transaction;
|
||||
- (void)updateWithAvatarUrlPath:(NSString *)avatarUrlPath transaction:(YapDatabaseReadWriteTransaction*)transaction;
|
||||
- (void)updateWithAvatarUrlPath:(NSString *)avatarUrlPath transaction:(YapDatabaseReadWriteTransaction*)transaction completion:(nullable OWSUserProfileCompletion)completion;
|
||||
|
||||
#pragma mark - Profile Avatars Directory
|
||||
|
||||
|
|
|
@ -321,13 +321,13 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
|
|||
[self updateWithProfileName:profileName avatarUrlPath:self.avatarUrlPath avatarFileName:self.avatarFileName transaction:transaction completion:nil];
|
||||
}
|
||||
|
||||
- (void)updateWithAvatarUrlPath:(NSString *)avatarUrlPath transaction:(YapDatabaseReadWriteTransaction*)transaction {
|
||||
- (void)updateWithAvatarUrlPath:(NSString *)avatarUrlPath transaction:(YapDatabaseReadWriteTransaction*)transaction completion:(nullable OWSUserProfileCompletion)completion {
|
||||
[self applyChanges:^(OWSUserProfile *userProfile) {
|
||||
[userProfile setAvatarUrlPath:avatarUrlPath];
|
||||
}
|
||||
functionName:__PRETTY_FUNCTION__
|
||||
transaction:transaction
|
||||
completion:nil];
|
||||
completion:completion];
|
||||
}
|
||||
|
||||
- (void)updateWithAvatarUrlPath:(nullable NSString *)avatarUrlPath
|
||||
|
|
|
@ -163,6 +163,13 @@ public final class LokiPublicChatPoller : NSObject {
|
|||
transaction.setObject(senderDisplayName, forKey: senderHexEncodedPublicKey, inCollection: publicChat.id)
|
||||
let messageServerID = message.serverID
|
||||
SSKEnvironment.shared.messageManager.throws_processEnvelope(try! envelope.build(), plaintextData: try! content.build().serializedData(), wasReceivedByUD: false, transaction: transaction, serverID: messageServerID ?? 0)
|
||||
|
||||
// If we got a message from our primary device then we should use its avatar
|
||||
if let avatar = message.avatar, masterHexEncodedPublicKey == message.hexEncodedPublicKey {
|
||||
SSKEnvironment.shared.profileManager.updateUserProfile(withDisplayName: message.displayName, transaction: transaction)
|
||||
SSKEnvironment.shared.profileManager.updateUserProfileKeyData(avatar.profileKey, avatarURL: avatar.url, transaction: transaction)
|
||||
SSKEnvironment.shared.profileManager.updateService(withProfileName: message.displayName, avatarUrl: avatar.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -930,7 +930,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NSString *profilePictureURL = profile.profilePicture;
|
||||
[self.profileManager updateUserProfileWithDisplayName:displayName transaction:transaction];
|
||||
if ([dataMessage hasProfileKey]) {
|
||||
[self.profileManager updateUserPofileKeyData:dataMessage.profileKey avatarURL:profilePictureURL transaction:transaction];
|
||||
[self.profileManager updateUserProfileKeyData:dataMessage.profileKey avatarURL:profilePictureURL transaction:transaction];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,8 +33,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (void)fetchProfileForRecipientId:(NSString *)recipientId;
|
||||
|
||||
- (void)updateUserProfileWithDisplayName:(nullable NSString*)displayName transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)updateUserPofileKeyData:(NSData *)profileKeyData avatarURL:(nullable NSString *)avatarURL transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)updateUserProfileKeyData:(NSData *)profileKeyData avatarURL:(nullable NSString *)avatarURL transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)updateProfileForContactWithID:(NSString *)contactID displayName:(NSString *)displayName with:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)updateServiceWithProfileName:(nullable NSString *)localProfileName avatarUrl:(nullable NSString *)avatarURL;
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in New Issue