a digital person for bluesky

Fix notification processing race condition

Move notification marking to after queueing to prevent skipping unread notifications. Previously, notifications were marked as seen before being queued, causing them to be filtered out as already read.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Changed files
+10 -10
+10 -10
bsky.py
··· 1305 1305 # Now process all fetched notifications 1306 1306 new_count = 0 1307 1307 if all_notifications: 1308 - # Mark as seen first 1309 - try: 1310 - atproto_client.app.bsky.notification.update_seen( 1311 - data={'seenAt': last_seen_at} 1312 - ) 1313 - logger.debug(f"Marked {len(all_notifications)} notifications as seen at {last_seen_at}") 1314 - except Exception as e: 1315 - logger.error(f"Error marking notifications as seen: {e}") 1316 - 1317 - # Queue all new notifications (except likes and already read) 1308 + # Queue all new notifications (except likes and already read) BEFORE marking as seen 1318 1309 for notif in all_notifications: 1319 1310 # Skip if already read or if it's a like 1320 1311 if (hasattr(notif, 'is_read') and notif.is_read) or (hasattr(notif, 'reason') and notif.reason == 'like'): ··· 1344 1335 1345 1336 if save_notification_to_queue(notif_dict, is_priority=is_priority): 1346 1337 new_count += 1 1338 + 1339 + # Mark as seen AFTER queueing 1340 + try: 1341 + atproto_client.app.bsky.notification.update_seen( 1342 + data={'seenAt': last_seen_at} 1343 + ) 1344 + logger.debug(f"Marked {len(all_notifications)} notifications as seen at {last_seen_at}") 1345 + except Exception as e: 1346 + logger.error(f"Error marking notifications as seen: {e}") 1347 1347 1348 1348 if new_count > 0: 1349 1349 logger.info(f"Queued {new_count} new notifications and marked as seen")