feat: add command to clear avatar cache

pull/186/head
sualko 2022-01-05 10:05:26 +01:00
parent dd87506f22
commit 862cda79c3
3 changed files with 43 additions and 0 deletions

View File

@ -111,6 +111,10 @@ and `avatar.url = https://avatar-cache.your-nextcloud.com/`:
For additional security, we recommend to disable directory listing, symlinks and
any language interpreter such as php for the cache directory.
Cached avatars are usually deleted as soon as the meeting ends. In cases the BBB
server shuts down unexpected, we provide the `bbb:clear-avatar-cache` occ
command (example use: `./occ bbb:clear-avatar-cache`).
## :bowtie: User guide

View File

@ -45,6 +45,9 @@ Developer wanted! If you have time it would be awesome if you could help to enha
<lib>SimpleXML</lib>
<nextcloud min-version="20" max-version="23"/>
</dependencies>
<commands>
<command>OCA\BigBlueButton\Command\ClearAvatarCache</command>
</commands>
<settings>
<admin>OCA\BigBlueButton\Settings\Admin</admin>
<personal-section>OCA\BigBlueButton\Settings\Section</personal-section>

View File

@ -0,0 +1,36 @@
<?php
namespace OCA\BigBlueButton\Command;
use OCA\BigBlueButton\AvatarRepository;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ClearAvatarCache extends Command {
/**
* @var AvatarRepository
*/
private $avatarRepository;
public function __construct(
AvatarRepository $avatarRepository
) {
parent::__construct();
$this->avatarRepository = $avatarRepository;
}
protected function configure() {
$this->setName('bbb:clear-avatar-cache');
$this->setDescription('Clear all avatars in cache');
}
protected function execute(InputInterface $input, OutputInterface $output) {
$stats = $this->avatarRepository->clearAllRooms();
$output->writeln("Removed " . $stats["files"] . " avatars in " . $stats["rooms"] . " rooms");
return 0;
}
}