Files
kyle b18b996468 refactor(nc_bot_webhooks): rename app display name and logger tags to nc_bot_webhooks and update docs
- appinfo/info.xml: Update app `<name>` to `nc_bot_web_hooks`.
- lib/NavigationProvider.php: Update navigation entry name to `nc_bot_web_hooks`.
- lib/Controller/WebhookController.php: Update all logger tags from `NCbotwebhooks:` to `nc_bot_web_hooks:`.
- lib/Cron/ImageCleanup.php: Update logger tag to `nc_bot_web_hooks:`.
- lib/Service/TalkService.php: Update all logger tags from `NCbotwebhooks:` to `nc_bot_web_hooks:`.
- agent.md: Update references to app name and logger tags.
- architecture.md: Update references to app name.
- INSTALL.md: Update references to app name and example strings.
- README.md: Restructure "Installation" section (split into Initial installation, Updating using git, Local update), add "Debugging" section with diagnostic grep examples, update app name references.
2026-06-14 15:06:15 -07:00

60 lines
1.6 KiB
PHP

<?php
namespace OCA\Ncbotwebhooks\Cron;
use OCA\Ncbotwebhooks\Service\TalkService;
use OCP\BackgroundJob\IJob;
use OCP\Files\IRootFolder;
use OCP\IConfig;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
class ImageCleanup implements IJob {
private TalkService $talkService;
private IRootFolder $rootFolder;
private IUserManager $userManager;
private LoggerInterface $logger;
public function __construct(
TalkService $talkService,
IRootFolder $rootFolder,
IUserManager $userManager,
LoggerInterface $logger,
) {
$this->talkService = $talkService;
$this->rootFolder = $rootFolder;
$this->userManager = $userManager;
$this->logger = $logger;
}
public function run($argument = null): void {
// Check if bot user exists
$bot = $this->userManager->get('talk-bot');
if (!$bot) {
return;
}
// Check if images directory exists
// LazyFolder in Nextcloud 33 doesn't delegate getFolder() properly
try {
$userFolder = $this->rootFolder->getUserFolder($bot->getUID());
try {
$userFolder->get('nc_bot_webhooks-images');
} catch (\OCP\Files\NotFoundException $e) {
return;
}
} catch (\Exception $e) {
return;
}
$count = $this->talkService->purgeOldImages();
if ($count > 0) {
$this->logger->info(
'nc_bot_webhooks: purged ' . $count . ' old image files',
['app' => 'nc_bot_webhooks'],
);
}
}
}