mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-07-06 01:42:41 +02:00
feat(companion): enhance contact capacity management and bridge settings
- Introduced `CompanionContactCapacityError` to handle cases where persisted contacts exceed configured limits. - Added utility functions for parsing companion bridge settings and validating contact capacity. - Updated `RepeaterDaemon` to check contact capacity during companion loading and initialization. - Enhanced API endpoints to validate companion settings and manage contact limits effectively. - Implemented logging for bridge limits and errors related to contact capacity.
This commit is contained in:
@@ -2229,6 +2229,20 @@ class SQLiteHandler:
|
||||
return 0
|
||||
|
||||
# Companion persistence methods
|
||||
def companion_count_contacts(self, companion_hash: str) -> int:
|
||||
"""Return the number of persisted contacts for a companion."""
|
||||
try:
|
||||
with self._connect() as conn:
|
||||
cursor = conn.execute(
|
||||
"SELECT COUNT(*) FROM companion_contacts WHERE companion_hash = ?",
|
||||
(companion_hash,),
|
||||
)
|
||||
row = cursor.fetchone()
|
||||
return int(row[0]) if row else 0
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to count companion contacts: {e}")
|
||||
return 0
|
||||
|
||||
def companion_load_contacts(self, companion_hash: str) -> List[Dict]:
|
||||
"""Load contacts for a companion from storage."""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user