feat(db_migrations, message_handler, repeater_manager): enhance purging log functionality

- Added a new migration to include a 'details' column in the 'purging_log' table for improved logging of actions.
- Refactored the `log_purging_action` method in `RepeaterManager` to handle both new and legacy schemas, ensuring compatibility with the updated database structure.
- Updated `MessageHandler` to utilize the new logging method, replacing direct database updates with a unified logging approach.
- Added tests to verify the presence of the new column and the correct functionality of the logging mechanism across different scenarios.
This commit is contained in:
agessaman
2026-04-21 17:04:51 -07:00
parent 8e71a11bd1
commit 23cdce03e8
6 changed files with 132 additions and 28 deletions
+6 -9
View File
@@ -3346,12 +3346,9 @@ class MessageHandler:
await self.bot.repeater_manager.check_and_auto_purge()
self.bot.repeater_manager.db_manager.execute_update(
'INSERT INTO purging_log (action, details) VALUES (?, ?)',
(
'new_contact_discovered',
f'New contact discovered: {contact_name} (key: {public_key[:16]}...)',
),
self.bot.repeater_manager.log_purging_action(
"new_contact_discovered",
f"New contact discovered: {contact_name} (key: {public_key[:16]}...)",
)
return
@@ -3408,9 +3405,9 @@ class MessageHandler:
# Log the new contact discovery
if hasattr(self.bot, 'repeater_manager'):
self.bot.repeater_manager.db_manager.execute_update(
'INSERT INTO purging_log (action, details) VALUES (?, ?)',
('new_contact_discovered', f'New contact discovered: {contact_name} (key: {public_key[:16]}...)')
self.bot.repeater_manager.log_purging_action(
"new_contact_discovered",
f"New contact discovered: {contact_name} (key: {public_key[:16]}...)",
)
except Exception as e: