🐛 Fix the included post did not truncated
This commit is contained in:
parent
700c818df8
commit
bcd107ae2c
@ -25,11 +25,27 @@ public class PostService(
|
||||
const int maxLength = 256;
|
||||
foreach (var item in input)
|
||||
{
|
||||
if (!(item.Content?.Length > maxLength)) continue;
|
||||
if (item.Content?.Length > maxLength)
|
||||
{
|
||||
item.Content = item.Content[..maxLength];
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user