update voicemail with the latest changes to the maintenance application (#7035)
* update voicemail with the latest changes to the maintenance application Update the public static function filesystem_maintenance in voicemail class to use the newest changes in the maintenance class. The maintenance class now has a constant defined for the subcategory used within the project. * update app_config file with necessary default setting changes --------- Authored-by: Tim Fry <tim@fusionpbx.com>
This commit is contained in:
parent
adbb9f9fd8
commit
50f1601a4d
|
|
@ -386,7 +386,22 @@
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_value'] = "true";
|
$apps[$x]['default_settings'][$y]['default_setting_value'] = "true";
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
|
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Transcription enabled default false.";
|
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Transcription enabled default false.";
|
||||||
|
$y++;
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "275cf580-7b72-45e4-9af5-b8eed9a45ec0";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_category'] = "voicemail";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "database_retention_days";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_value'] = "90";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of days maintenance application will retain logs in the database.";
|
||||||
|
$y++;
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "9237cc82-7dea-4b5f-8225-eeed97938338";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_category'] = "voicemail";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "filesystem_retention_days";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_value'] = "90";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of days maintenance application will retain files.";
|
||||||
//schema details
|
//schema details
|
||||||
$y=0;
|
$y=0;
|
||||||
$apps[$x]['db'][$y]['table']['name'] = "v_voicemails";
|
$apps[$x]['db'][$y]['table']['name'] = "v_voicemails";
|
||||||
|
|
|
||||||
|
|
@ -1050,7 +1050,7 @@
|
||||||
$domain_settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
|
$domain_settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
|
||||||
|
|
||||||
//ensure we have a retention day
|
//ensure we have a retention day
|
||||||
$retention_days = $domain_settings->get('maintenance', 'voicemail_database_retention_days', '');
|
$retention_days = $domain_settings->get('voicemail', maintenance::DATABASE_SUBCATEGORY, '');
|
||||||
if (!empty($retention_days) && is_numeric($retention_days)) {
|
if (!empty($retention_days) && is_numeric($retention_days)) {
|
||||||
//clear out old records
|
//clear out old records
|
||||||
$sql = "delete from v_{$table} WHERE to_timestamp(created_epoch) < NOW() - INTERVAL '{$retention_days} days'"
|
$sql = "delete from v_{$table} WHERE to_timestamp(created_epoch) < NOW() - INTERVAL '{$retention_days} days'"
|
||||||
|
|
@ -1064,45 +1064,61 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//clear out any null domain_uuid entries
|
|
||||||
$sql = "delete from v_{$table} WHERE to_timestamp(created_epoch) < NOW() - INTERVAL '{$retention_days} days'"
|
|
||||||
. " and domain_uuid is null";
|
|
||||||
$database->execute($sql);
|
|
||||||
if ($database->message['code'] === 200) {
|
|
||||||
maintenance_service::log_write(self::class, "Successfully removed voicemail entries from $domain_name", $domain_uuid);
|
|
||||||
} else {
|
|
||||||
maintenance_service::log_write(self::class, "Unable to remove records for domain $domain_name", $domain_uuid, maintenance_service::LOG_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
//ensure logs are saved
|
//ensure logs are saved
|
||||||
maintenance_service::log_flush();
|
maintenance_service::log_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the maintenance system to remove old files
|
||||||
|
* @param settings $settings Settings object
|
||||||
|
*/
|
||||||
public static function filesystem_maintenance(settings $settings): void {
|
public static function filesystem_maintenance(settings $settings): void {
|
||||||
//get a list of domains
|
//get a list of domains
|
||||||
$domains = maintenance::get_domains($settings->database());
|
$domains = maintenance::get_domains($settings->database());
|
||||||
|
|
||||||
|
//loop through domains to handle domains with different defaults
|
||||||
foreach ($domains as $domain_uuid => $domain_name) {
|
foreach ($domains as $domain_uuid => $domain_name) {
|
||||||
|
|
||||||
|
//get settings for this domain
|
||||||
$domain_settings = new settings(['database' => $settings->database(), 'domain_uuid' => $domain_uuid]);
|
$domain_settings = new settings(['database' => $settings->database(), 'domain_uuid' => $domain_uuid]);
|
||||||
|
|
||||||
|
//get the switch voicemail location
|
||||||
$voicemail_location = $domain_settings->get('switch', 'voicemail', '/var/lib/freeswitch/storage/voicemail') . '/default';
|
$voicemail_location = $domain_settings->get('switch', 'voicemail', '/var/lib/freeswitch/storage/voicemail') . '/default';
|
||||||
$retention_days = $domain_settings->get('maintenance', 'voicemail_filesystem_retention_days', '');
|
|
||||||
|
//get the filesystem retention days
|
||||||
|
$retention_days = $domain_settings->get('voicemail', maintenance::FILESYSTEM_SUBCATEGORY, '');
|
||||||
if (!empty($retention_days)) {
|
if (!empty($retention_days)) {
|
||||||
|
|
||||||
|
//get all wav and mp3 voicemail files
|
||||||
$mp3_files = glob("$voicemail_location/$domain_name/*/msg_*.mp3");
|
$mp3_files = glob("$voicemail_location/$domain_name/*/msg_*.mp3");
|
||||||
$wav_files = glob("$voicemail_location/$domain_name/*/msg_*.wav");
|
$wav_files = glob("$voicemail_location/$domain_name/*/msg_*.wav");
|
||||||
$domain_voicemail_files = array_merge($mp3_files, $wav_files);
|
$domain_voicemail_files = array_merge($mp3_files, $wav_files);
|
||||||
|
|
||||||
|
//delete individually
|
||||||
foreach ($domain_voicemail_files as $file) {
|
foreach ($domain_voicemail_files as $file) {
|
||||||
|
|
||||||
|
//check modified date on file
|
||||||
if (maintenance_service::days_since_modified($file) > $retention_days) {
|
if (maintenance_service::days_since_modified($file) > $retention_days) {
|
||||||
|
|
||||||
|
//date is older so remove
|
||||||
if (unlink($file)) {
|
if (unlink($file)) {
|
||||||
|
//successfully deleted
|
||||||
maintenance_service::log_write(self::class, "Removed $file from voicemails", $domain_uuid);
|
maintenance_service::log_write(self::class, "Removed $file from voicemails", $domain_uuid);
|
||||||
} else {
|
} else {
|
||||||
|
//failed to delete file
|
||||||
maintenance_service::log_write(self::class, "Unable to remove $file", $domain_uuid, maintenance_service::LOG_ERROR);
|
maintenance_service::log_write(self::class, "Unable to remove $file", $domain_uuid, maintenance_service::LOG_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
//log retention days not valid
|
||||||
maintenance_service::log_write(self::class, "Retention days not set or not a valid number", $domain_uuid, maintenance_service::LOG_ERROR);
|
maintenance_service::log_write(self::class, "Retention days not set or not a valid number", $domain_uuid, maintenance_service::LOG_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ensure logs are saved
|
||||||
|
maintenance_service::log_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue