a digital person for bluesky

Fix notification database errors and duplication issues

- Fixed 'NoneType' object has no attribute 'get' errors in notification_db.py
- Added proper null checking for record fields and reply information
- Fixed logic in save_notification_to_queue to prevent queueing when DB add fails
- This resolves notification duplication where failed DB adds led to reprocessing

The bot was reprocessing the same notifications because:
1. Notification gets fetched and queued
2. Database add fails due to None field access
3. Notification gets processed but never marked as processed in DB
4. Next fetch cycle finds it again and re-queues it

Changed files
+16 -8
+4 -2
bsky.py
··· 971 if NOTIFICATION_DB.is_processed(notification_uri): 972 logger.debug(f"Notification already processed (DB): {notification_uri}") 973 return False 974 - # Add to database 975 - NOTIFICATION_DB.add_notification(notif_dict) 976 else: 977 # Fall back to old JSON method 978 processed_uris = load_processed_notifications()
··· 971 if NOTIFICATION_DB.is_processed(notification_uri): 972 logger.debug(f"Notification already processed (DB): {notification_uri}") 973 return False 974 + # Add to database - if this fails, don't queue the notification 975 + if not NOTIFICATION_DB.add_notification(notif_dict): 976 + logger.warning(f"Failed to add notification to database, skipping: {notification_uri}") 977 + return False 978 else: 979 # Fall back to old JSON method 980 processed_uris = load_processed_notifications()
+12 -6
notification_db.py
··· 92 author_handle = author.get('handle', '') if author else '' 93 author_did = author.get('did', '') if author else '' 94 95 - # Extract text from record if available 96 - record = notif_dict.get('record', {}) 97 - text = record.get('text', '')[:500] # Limit text length 98 99 # Extract thread info 100 parent_uri = None 101 root_uri = None 102 - if 'reply' in record: 103 - parent_uri = record['reply'].get('parent', {}).get('uri') 104 - root_uri = record['reply'].get('root', {}).get('uri') 105 106 # Store additional metadata as JSON 107 metadata = {
··· 92 author_handle = author.get('handle', '') if author else '' 93 author_did = author.get('did', '') if author else '' 94 95 + # Extract text from record if available (handle None records) 96 + record = notif_dict.get('record') or {} 97 + text = record.get('text', '')[:500] if record else '' 98 99 # Extract thread info 100 parent_uri = None 101 root_uri = None 102 + if record and 'reply' in record and record['reply']: 103 + reply_info = record['reply'] 104 + if reply_info and isinstance(reply_info, dict): 105 + parent_info = reply_info.get('parent', {}) 106 + root_info = reply_info.get('root', {}) 107 + if parent_info: 108 + parent_uri = parent_info.get('uri') 109 + if root_info: 110 + root_uri = root_info.get('uri') 111 112 # Store additional metadata as JSON 113 metadata = {