feat(voicemail): implement new voicemail notification callback and enhance call history retrieval with search and pagination support
This commit is contained in:
@@ -135,6 +135,9 @@ class ConfigManager:
|
||||
self.custom_ringtone_enabled = self.BoolConfig(self, "custom_ringtone_enabled", False)
|
||||
self.ringtone_filename = self.StringConfig(self, "ringtone_filename", None)
|
||||
|
||||
# telephony config
|
||||
self.do_not_disturb_enabled = self.BoolConfig(self, "do_not_disturb_enabled", False)
|
||||
|
||||
# map config
|
||||
self.map_offline_enabled = self.BoolConfig(self, "map_offline_enabled", False)
|
||||
self.map_offline_path = self.StringConfig(self, "map_offline_path", None)
|
||||
|
||||
@@ -2,7 +2,7 @@ from .provider import DatabaseProvider
|
||||
|
||||
|
||||
class DatabaseSchema:
|
||||
LATEST_VERSION = 18
|
||||
LATEST_VERSION = 19
|
||||
|
||||
def __init__(self, provider: DatabaseProvider):
|
||||
self.provider = provider
|
||||
@@ -551,6 +551,11 @@ class DatabaseSchema:
|
||||
"CREATE INDEX IF NOT EXISTS idx_contacts_remote_identity_hash ON contacts(remote_identity_hash)",
|
||||
)
|
||||
|
||||
if current_version < 19:
|
||||
self.provider.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_call_history_remote_name ON call_history(remote_identity_name)",
|
||||
)
|
||||
|
||||
# Update version in config
|
||||
self.provider.execute(
|
||||
"""
|
||||
|
||||
@@ -40,10 +40,19 @@ class TelephoneDAO:
|
||||
),
|
||||
)
|
||||
|
||||
def get_call_history(self, limit=10):
|
||||
def get_call_history(self, search=None, limit=10, offset=0):
|
||||
if search:
|
||||
return self.provider.fetchall(
|
||||
"""
|
||||
SELECT * FROM call_history
|
||||
WHERE remote_identity_name LIKE ? OR remote_identity_hash LIKE ?
|
||||
ORDER BY timestamp DESC LIMIT ? OFFSET ?
|
||||
""",
|
||||
(f"%{search}%", f"%{search}%", limit, offset),
|
||||
)
|
||||
return self.provider.fetchall(
|
||||
"SELECT * FROM call_history ORDER BY timestamp DESC LIMIT ?",
|
||||
(limit,),
|
||||
"SELECT * FROM call_history ORDER BY timestamp DESC LIMIT ? OFFSET ?",
|
||||
(limit, offset),
|
||||
)
|
||||
|
||||
def clear_call_history(self):
|
||||
|
||||
@@ -34,6 +34,8 @@ class VoicemailManager:
|
||||
self.recording_remote_identity = None
|
||||
self.recording_filename = None
|
||||
|
||||
self.on_new_voicemail_callback = None
|
||||
|
||||
# Paths to executables
|
||||
self.espeak_path = self._find_espeak()
|
||||
self.ffmpeg_path = self._find_ffmpeg()
|
||||
@@ -377,6 +379,13 @@ class VoicemailManager:
|
||||
f"Saved voicemail from {RNS.prettyhexrep(self.recording_remote_identity.hash)} ({duration}s)",
|
||||
RNS.LOG_DEBUG,
|
||||
)
|
||||
|
||||
if self.on_new_voicemail_callback:
|
||||
self.on_new_voicemail_callback(
|
||||
self.recording_remote_identity.hash.hex(),
|
||||
remote_name,
|
||||
duration,
|
||||
)
|
||||
else:
|
||||
# Delete short/empty recording
|
||||
filepath = os.path.join(self.recordings_dir, self.recording_filename)
|
||||
|
||||
Reference in New Issue
Block a user