[backend/federation] Make publish/update date checks stricter (ISH-687)
This commit is contained in:
parent
cd76e82a1e
commit
1bb199bf59
1 changed files with 8 additions and 2 deletions
|
@ -964,9 +964,12 @@ public class NoteService(
|
|||
return null;
|
||||
}
|
||||
|
||||
if (note.PublishedAt is null or { Year: < 2007 } || note.PublishedAt > DateTime.Now + TimeSpan.FromDays(3))
|
||||
if (note.PublishedAt is null or { Year: < 2007 } || note.PublishedAt > DateTime.Now + TimeSpan.FromMinutes(5))
|
||||
throw GracefulException.UnprocessableEntity("Note.PublishedAt is nonsensical");
|
||||
|
||||
if (note.PublishedAt > DateTime.Now)
|
||||
note.PublishedAt = DateTime.Now;
|
||||
|
||||
if (replyUri != null)
|
||||
{
|
||||
if (reply == null && note.Name != null)
|
||||
|
@ -1084,11 +1087,14 @@ public class NoteService(
|
|||
throw GracefulException.Forbidden("User is suspended");
|
||||
if (dbNote.UpdatedAt != null && dbNote.UpdatedAt > updatedAt)
|
||||
throw GracefulException.UnprocessableEntity("Note update is older than last known version");
|
||||
if (updatedAt.Year < 2007 || updatedAt > DateTime.Now + TimeSpan.FromDays(3))
|
||||
if (updatedAt.Year < 2007 || updatedAt > DateTime.Now + TimeSpan.FromMinutes(5))
|
||||
throw GracefulException.UnprocessableEntity("updatedAt is nonsensical");
|
||||
if (actor.Host == null)
|
||||
throw GracefulException.UnprocessableEntity("User.Host is null");
|
||||
|
||||
if (note.UpdatedAt > DateTime.Now)
|
||||
note.UpdatedAt = DateTime.Now;
|
||||
|
||||
var mentionData = await ResolveNoteMentionsAsync(note);
|
||||
|
||||
var text = note.MkContent;
|
||||
|
|
Loading…
Add table
Reference in a new issue