Remove contact share avatars upon message deletion

// FREEBIE
This commit is contained in:
Michael Kirk 2018-05-10 10:14:39 -04:00
parent efa3c81f68
commit ed2945126a
3 changed files with 13 additions and 0 deletions

View File

@ -117,6 +117,8 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value);
@property (nonatomic, readonly, nullable) NSString *avatarAttachmentId;
- (nullable TSAttachment *)avatarAttachmentWithTransaction:(YapDatabaseReadTransaction *)transaction;
- (void)removeAvatarAttachmentWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)saveAvatarImage:(UIImage *)image transaction:(YapDatabaseReadWriteTransaction *)transaction;
// "Profile" avatars should _not_ be saved to device contacts.
@property (nonatomic, readonly) BOOL isProfileAvatar;

View File

@ -499,6 +499,13 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
self.avatarAttachmentId = attachmentStream.uniqueId;
}
- (void)removeAvatarAttachmentWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
TSAttachmentStream *_Nullable attachment =
[TSAttachmentStream fetchObjectWithUniqueID:self.avatarAttachmentId transaction:transaction];
[attachment removeWithTransaction:transaction];
}
#pragma mark - Phone Numbers and Recipient IDs
- (NSArray<NSString *> *)systemContactsWithSignalAccountPhoneNumbers:(id<ContactsManagerProtocol>)contactsManager

View File

@ -289,6 +289,10 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
[attachment removeWithTransaction:transaction];
};
if (self.contactShare.avatarAttachmentId) {
[self.contactShare removeAvatarAttachmentWithTransaction:transaction];
}
// Updates inbox thread preview
[self touchThreadWithTransaction:transaction];
}