A focal point is two finite numbers
float.TryParse takes "NaN" and "Infinity", and Math.Clamp keeps a NaN, so `focus=NaN,NaN` on an upload or a media PUT was stored as given. Once the media was posted, every status and timeline response holding the post, and the Note and its delivery, failed to serialise, for every viewer. FocalPoint.Parse takes finite numbers only (anything else is ignored, as an unreadable focus was); the mapper and the renderer leave out a focus that isn't sound, and migration _016 removes the ones stored before, from the uploads and from the copy each post keeps. What PrivaPub sends is unchanged for any focus that could be sent before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
402f9e0d75
commit
52d201eee9
9 files changed
+100
-17
No files matched your search
@@ -75,7 +75,7 @@ namespace PrivaPub.Domain.Media
|
||||
{
|
||||
OwnerAvatarId = owner.Id,
|
||||
Description = Clean(description, 1500),
|
||||
Focus = Focus(focus)
|
||||
Focus = FocalPoint.Parse(focus)
|
||||
};
|
||||
if (ImageTypes.Contains(contentType))
|
||||
{
|
||||
@@ -252,15 +252,5 @@ namespace PrivaPub.Domain.Media
|
||||
|
||||
static string Clean(string value, int max) =>
|
||||
string.IsNullOrWhiteSpace(value) ? default : value.Trim().Length <= max ? value.Trim() : value.Trim()[..max];
|
||||
|
||||
static float[] Focus(string focus)
|
||||
{
|
||||
var parts = focus?.Split(',');
|
||||
if (parts is not { Length: 2 }
|
||||
|| !float.TryParse(parts[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var x)
|
||||
|| !float.TryParse(parts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var y))
|
||||
return default;
|
||||
return new[] { Math.Clamp(x, -1, 1), Math.Clamp(y, -1, 1) };
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user