Manage bad m.file attachment format

https://github.com/vector-im/element-ios/issues/7406

By using value type checker methods.

With this fix, attachments with a wrong size format are still displayed in the timeline. Only the size is omitted
This commit is contained in:
manuroe
2023-03-15 15:18:38 +01:00
parent b1b7e853df
commit 7f00f71786
2 changed files with 10 additions and 2 deletions
@@ -1362,14 +1362,21 @@ static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*
{
body = body? body : [VectorL10n noticeFileAttachment];
NSDictionary *fileInfo = contentToUse[@"info"];
NSDictionary *fileInfo;
MXJSONModelSetDictionary(fileInfo, contentToUse[@"info"]);
if (fileInfo)
{
NSNumber *fileSize = fileInfo[@"size"];
NSNumber *fileSize;
MXJSONModelSetNumber(fileSize, fileInfo[@"size"])
if (fileSize)
{
body = [NSString stringWithFormat:@"%@ (%@)", body, [MXTools fileSizeToString: fileSize.longValue]];
}
else
{
MXLogDebug(@"[MXKEventFormatter] Warning: Unsupported m.file format: %@", event.description);
*error = MXKEventFormatterErrorUnsupported;
}
}
}
else