From 437f265ef0a8b5552b137b04d51f2c43dd5d4ae7 Mon Sep 17 00:00:00 2001 From: Cameron Pfiffer Date: Wed, 24 Dec 2025 20:15:42 -0800 Subject: [PATCH] Add 1-month age filter to skip old notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Import timedelta for date calculations - Skip notifications older than 30 days from current time - Prevents processing very old backlog items - Still respects last_processed_time for recent items 🐾 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta --- bsky.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bsky.py b/bsky.py index c0ed127..4382051 100644 --- a/bsky.py +++ b/bsky.py @@ -8,7 +8,7 @@ import json import hashlib import subprocess from pathlib import Path -from datetime import datetime +from datetime import datetime, timedelta from collections import defaultdict import time import argparse @@ -1419,8 +1419,18 @@ def fetch_and_queue_new_notifications(atproto_client): processed_uris = load_processed_notifications() # Queue all new notifications (except likes) + # Calculate cutoff time: 1 month ago from now + one_month_ago = (datetime.now() - timedelta(days=30)).isoformat() + for notif in all_notifications: - # Skip if older than last processed (when we have timestamp filtering) + # Skip if older than 1 month + if hasattr(notif, 'indexed_at'): + if notif.indexed_at < one_month_ago: + skipped_old_timestamp += 1 + logger.debug(f"Skipping old notification (older than 1 month): {notif.indexed_at}") + continue + + # Also skip if older than last processed (when we have timestamp filtering) if last_processed_time and hasattr(notif, 'indexed_at'): if notif.indexed_at <= last_processed_time: skipped_old_timestamp += 1 -- 2.51.2