mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 08:35:18 +00:00
Automatically clean calls.
This commit is contained in:
@ -304,6 +304,47 @@ class CallsComponents {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all old call
|
||||
*
|
||||
* @return bool TRUE for a success / FALSE else
|
||||
*/
|
||||
public function cleanCalls() : bool {
|
||||
|
||||
//Compute timeout time
|
||||
$old_time = time() - cs()->config->get("calls_expiration");
|
||||
|
||||
//Get the list of old calls
|
||||
$calls = db()->select(
|
||||
self::CALLS_LIST_TABLE,
|
||||
"WHERE last_active < ?",
|
||||
array($old_time),
|
||||
array("id")
|
||||
);
|
||||
|
||||
//Process each result
|
||||
foreach($calls as $call){
|
||||
|
||||
//Delete all the members of the call
|
||||
db()->deleteEntry(
|
||||
self::CALLS_MEMBERS_TABLE,
|
||||
"call_id = ?",
|
||||
array($call["id"])
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
//Delete calls entries
|
||||
db()->deleteEntry(
|
||||
self::CALLS_LIST_TABLE,
|
||||
"last_active < ?",
|
||||
array($old_time)
|
||||
);
|
||||
|
||||
//Success
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a database entry into a CallInformation object
|
||||
*
|
||||
|
Reference in New Issue
Block a user