Discard if 3 days in the future

This commit is contained in:
Kio-td 2023-02-11 06:26:05 -05:00
parent e35f3eef56
commit f9fc1d7137
1 changed files with 7 additions and 0 deletions

View File

@ -116,12 +116,19 @@ export async function createNote(
logger.info(`Creating the Note: ${note.id}`);
// Skip if note is made before 2007 (1yr before Fedi was created)
// OR skip if note is made 3 days in advance
if (note.published) {
const DateChecker = new Date(note.published)
const FutureCheck = new Date()
FutureCheck.setDate(FutureCheck.getDate() + 3) // Allow some wiggle room for misconfigured hosts
if (DateChecker.getFullYear() < 2007) {
logger.warn('Note somehow made before Activitypub was created; discarding');
return null;
}
if (DateChecker < FutureCheck) {
logger.warn('Note somehow made after today; discarding')
return null;
}
}