[backend/federation] Fix future publishedAt/updatedAt DateTime handling
This commit is contained in:
parent
57645f017d
commit
77936b710d
1 changed files with 6 additions and 6 deletions
|
@ -964,11 +964,11 @@ public class NoteService(
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.PublishedAt is null or { Year: < 2007 } || note.PublishedAt > DateTime.Now + TimeSpan.FromMinutes(5))
|
if (note.PublishedAt is null or { Year: < 2007 } || note.PublishedAt > DateTime.UtcNow + TimeSpan.FromDays(3))
|
||||||
throw GracefulException.UnprocessableEntity("Note.PublishedAt is nonsensical");
|
throw GracefulException.UnprocessableEntity("Note.PublishedAt is nonsensical");
|
||||||
|
|
||||||
if (note.PublishedAt > DateTime.Now)
|
if (note.PublishedAt > DateTime.UtcNow)
|
||||||
note.PublishedAt = DateTime.Now;
|
note.PublishedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
if (replyUri != null)
|
if (replyUri != null)
|
||||||
{
|
{
|
||||||
|
@ -1087,13 +1087,13 @@ public class NoteService(
|
||||||
throw GracefulException.Forbidden("User is suspended");
|
throw GracefulException.Forbidden("User is suspended");
|
||||||
if (dbNote.UpdatedAt != null && dbNote.UpdatedAt > updatedAt)
|
if (dbNote.UpdatedAt != null && dbNote.UpdatedAt > updatedAt)
|
||||||
throw GracefulException.UnprocessableEntity("Note update is older than last known version");
|
throw GracefulException.UnprocessableEntity("Note update is older than last known version");
|
||||||
if (updatedAt.Year < 2007 || updatedAt > DateTime.Now + TimeSpan.FromMinutes(5))
|
if (updatedAt.Year < 2007 || updatedAt > DateTime.UtcNow + TimeSpan.FromDays(3))
|
||||||
throw GracefulException.UnprocessableEntity("updatedAt is nonsensical");
|
throw GracefulException.UnprocessableEntity("updatedAt is nonsensical");
|
||||||
if (actor.Host == null)
|
if (actor.Host == null)
|
||||||
throw GracefulException.UnprocessableEntity("User.Host is null");
|
throw GracefulException.UnprocessableEntity("User.Host is null");
|
||||||
|
|
||||||
if (note.UpdatedAt > DateTime.Now)
|
if (note.UpdatedAt > DateTime.UtcNow)
|
||||||
note.UpdatedAt = DateTime.Now;
|
note.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
var mentionData = await ResolveNoteMentionsAsync(note);
|
var mentionData = await ResolveNoteMentionsAsync(note);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue