🐛 Fix the included post did not truncated

This commit is contained in:
LittleSheep 2025-06-21 11:05:12 +08:00
parent 700c818df8
commit bcd107ae2c

View File

@ -25,11 +25,27 @@ public class PostService(
const int maxLength = 256; const int maxLength = 256;
foreach (var item in input) foreach (var item in input)
{ {
if (!(item.Content?.Length > maxLength)) continue; if (item.Content?.Length > maxLength)
{
item.Content = item.Content[..maxLength]; item.Content = item.Content[..maxLength];
item.IsTruncated = true; item.IsTruncated = true;
} }
// Truncate replied post content
if (item.RepliedPost?.Content?.Length > maxLength)
{
item.RepliedPost.Content = item.RepliedPost.Content[..maxLength];
item.RepliedPost.IsTruncated = true;
}
// Truncate forwarded post content
if (item.ForwardedPost?.Content?.Length > maxLength)
{
item.ForwardedPost.Content = item.ForwardedPost.Content[..maxLength];
item.ForwardedPost.IsTruncated = true;
}
}
return input; return input;
} }