mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Clean
This commit is contained in:
parent
b0dfae7974
commit
2b8e74348a
|
@ -81,9 +81,6 @@ extern NSString *const kLocalProfileUniqueId;
|
||||||
dbConnection:(YapDatabaseConnection *)dbConnection
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
||||||
completion:(nullable OWSUserProfileCompletion)completion;
|
completion:(nullable OWSUserProfileCompletion)completion;
|
||||||
|
|
||||||
- (void)updateWithProfileName:(nullable NSString *)profileName transaction:(YapDatabaseReadWriteTransaction*)transaction;
|
|
||||||
- (void)updateWithAvatarUrlPath:(NSString *)avatarUrlPath transaction:(YapDatabaseReadWriteTransaction*)transaction completion:(nullable OWSUserProfileCompletion)completion;
|
|
||||||
|
|
||||||
#pragma mark - Profile Avatars Directory
|
#pragma mark - Profile Avatars Directory
|
||||||
|
|
||||||
+ (NSString *)profileAvatarFilepathWithFilename:(NSString *)filename;
|
+ (NSString *)profileAvatarFilepathWithFilename:(NSString *)filename;
|
||||||
|
|
|
@ -317,25 +317,6 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
|
||||||
completion:completion];
|
completion:completion];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateWithProfileName:(nullable NSString *)profileName transaction:(YapDatabaseReadWriteTransaction*)transaction
|
|
||||||
{
|
|
||||||
[self applyChanges:^(OWSUserProfile *userProfile) {
|
|
||||||
[userProfile setProfileName:profileName];
|
|
||||||
}
|
|
||||||
functionName:__PRETTY_FUNCTION__
|
|
||||||
transaction:transaction
|
|
||||||
completion:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)updateWithAvatarUrlPath:(NSString *)avatarUrlPath transaction:(YapDatabaseReadWriteTransaction*)transaction completion:(nullable OWSUserProfileCompletion)completion {
|
|
||||||
[self applyChanges:^(OWSUserProfile *userProfile) {
|
|
||||||
[userProfile setAvatarUrlPath:avatarUrlPath];
|
|
||||||
}
|
|
||||||
functionName:__PRETTY_FUNCTION__
|
|
||||||
transaction:transaction
|
|
||||||
completion:completion];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)updateWithAvatarUrlPath:(nullable NSString *)avatarUrlPath
|
- (void)updateWithAvatarUrlPath:(nullable NSString *)avatarUrlPath
|
||||||
avatarFileName:(nullable NSString *)avatarFileName
|
avatarFileName:(nullable NSString *)avatarFileName
|
||||||
dbConnection:(YapDatabaseConnection *)dbConnection
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
||||||
|
|
|
@ -468,8 +468,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
// Set any profile information
|
// Set any profile information
|
||||||
if (contentProto.dataMessage) {
|
if (contentProto.dataMessage) {
|
||||||
[self handleProfileNameUpdateIfNeeded:contentProto.dataMessage recipientId:masterHexEncodedPublicKey transaction:transaction];
|
SSKProtoDataMessage *dataMessage = contentProto.dataMessage;
|
||||||
[self handleProfileKeyUpdateIfNeeded:contentProto.dataMessage recipientId:masterHexEncodedPublicKey];
|
[self handleProfileNameUpdateIfNeeded:dataMessage recipientId:masterHexEncodedPublicKey transaction:transaction];
|
||||||
|
[self handleProfileKeyUpdateIfNeeded:dataMessage recipientId:masterHexEncodedPublicKey];
|
||||||
}
|
}
|
||||||
} else if (slaveSignature != nil) { // Request
|
} else if (slaveSignature != nil) { // Request
|
||||||
OWSLogInfo(@"[Loki] Received a device linking request from: %@", envelope.source); // Not slaveHexEncodedPublicKey
|
OWSLogInfo(@"[Loki] Received a device linking request from: %@", envelope.source); // Not slaveHexEncodedPublicKey
|
||||||
|
@ -924,12 +925,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
BOOL wasSentByMasterDevice = [masterHexEncodedPublicKey isEqual:envelope.source];
|
BOOL wasSentByMasterDevice = [masterHexEncodedPublicKey isEqual:envelope.source];
|
||||||
if (syncMessage.sent) {
|
if (syncMessage.sent) {
|
||||||
|
|
||||||
// Loki: Try to update using the provided profile
|
|
||||||
if (wasSentByMasterDevice) {
|
|
||||||
[self handleProfileNameUpdateIfNeeded:syncMessage.sent.message recipientId:masterHexEncodedPublicKey transaction:transaction];
|
|
||||||
[self handleProfileKeyUpdateIfNeeded:syncMessage.sent.message recipientId:masterHexEncodedPublicKey];
|
|
||||||
}
|
|
||||||
|
|
||||||
OWSIncomingSentMessageTranscript *transcript =
|
OWSIncomingSentMessageTranscript *transcript =
|
||||||
[[OWSIncomingSentMessageTranscript alloc] initWithProto:syncMessage.sent transaction:transaction];
|
[[OWSIncomingSentMessageTranscript alloc] initWithProto:syncMessage.sent transaction:transaction];
|
||||||
|
|
||||||
|
@ -938,6 +933,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
OWSFailDebug(@"Missing dataMessage.");
|
OWSFailDebug(@"Missing dataMessage.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loki: Try to update using the provided profile
|
||||||
|
if (wasSentByMasterDevice) {
|
||||||
|
[self handleProfileNameUpdateIfNeeded:dataMessage recipientId:masterHexEncodedPublicKey transaction:transaction];
|
||||||
|
[self handleProfileKeyUpdateIfNeeded:dataMessage recipientId:masterHexEncodedPublicKey];
|
||||||
|
}
|
||||||
|
|
||||||
NSString *destination = syncMessage.sent.destination;
|
NSString *destination = syncMessage.sent.destination;
|
||||||
if (dataMessage && destination.length > 0 && dataMessage.hasProfileKey) {
|
if (dataMessage && destination.length > 0 && dataMessage.hasProfileKey) {
|
||||||
// If we observe a linked device sending our profile key to another
|
// If we observe a linked device sending our profile key to another
|
||||||
|
@ -1029,7 +1031,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
OWSLogInfo(@"Received verification state for %@", syncMessage.verified.destination);
|
OWSLogInfo(@"Received verification state for %@", syncMessage.verified.destination);
|
||||||
[self.identityManager throws_processIncomingSyncMessage:syncMessage.verified transaction:transaction];
|
[self.identityManager throws_processIncomingSyncMessage:syncMessage.verified transaction:transaction];
|
||||||
} else if (syncMessage.contacts != nil) {
|
} else if (syncMessage.contacts != nil) {
|
||||||
if (false && wasSentByMasterDevice && syncMessage.contacts.data.length > 0) {
|
if (wasSentByMasterDevice && syncMessage.contacts.data.length > 0) {
|
||||||
NSLog(@"[Loki] Received contact sync message.");
|
NSLog(@"[Loki] Received contact sync message.");
|
||||||
NSData *data = syncMessage.contacts.data;
|
NSData *data = syncMessage.contacts.data;
|
||||||
ContactParser *parser = [[ContactParser alloc] initWithData:data];
|
ContactParser *parser = [[ContactParser alloc] initWithData:data];
|
||||||
|
@ -1623,13 +1625,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handleProfileNameUpdateIfNeeded:(SSKProtoDataMessage *)dataMessage recipientId:(NSString *)recipientId transaction:(YapDatabaseReadWriteTransaction *)transaction {
|
- (void)handleProfileNameUpdateIfNeeded:(SSKProtoDataMessage *)dataMessage recipientId:(NSString *)recipientId transaction:(YapDatabaseReadWriteTransaction *)transaction {
|
||||||
if (dataMessage.profile != nil) {
|
if (dataMessage != nil && dataMessage.profile != nil) {
|
||||||
[self.profileManager updateProfileForContactWithID:recipientId displayName:dataMessage.profile.displayName with:transaction];
|
[self.profileManager updateProfileForContactWithID:recipientId displayName:dataMessage.profile.displayName with:transaction];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handleProfileKeyUpdateIfNeeded:(SSKProtoDataMessage *)dataMessage recipientId:(NSString *)recipientId {
|
- (void)handleProfileKeyUpdateIfNeeded:(SSKProtoDataMessage *)dataMessage recipientId:(NSString *)recipientId {
|
||||||
if ([dataMessage hasProfileKey]) {
|
if (dataMessage != nil && [dataMessage hasProfileKey]) {
|
||||||
NSData *profileKey = [dataMessage profileKey];
|
NSData *profileKey = [dataMessage profileKey];
|
||||||
NSString *url = dataMessage.profile != nil ? dataMessage.profile.profilePicture : nil;
|
NSString *url = dataMessage.profile != nil ? dataMessage.profile.profilePicture : nil;
|
||||||
if (profileKey.length == kAES256_KeyByteLength) {
|
if (profileKey.length == kAES256_KeyByteLength) {
|
||||||
|
|
Loading…
Reference in a new issue