mirror of
https://github.com/nextcloud/server.git
synced 2026-05-22 01:55:56 -04:00
fix: don't trigger on-setup share update from inside the share listener
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
1aa347dc76
commit
cb8fb349d2
3 changed files with 16 additions and 0 deletions
|
|
@ -54,11 +54,15 @@ class SharesUpdatedListener implements IEventListener {
|
|||
private readonly ClockInterface $clock,
|
||||
private readonly LoggerInterface $logger,
|
||||
IAppConfig $appConfig,
|
||||
private readonly UserHomeSetupListener $homeSetupListener,
|
||||
) {
|
||||
$this->cutOffMarkTime = $appConfig->getValueFloat(Application::APP_ID, ConfigLexicon::UPDATE_CUTOFF_TIME, 3.0);
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
// don't trigger the on-setup checks if this handler triggers an fs setup
|
||||
$this->homeSetupListener->setDisabled(true);
|
||||
|
||||
if ($event instanceof UserShareAccessUpdatedEvent) {
|
||||
foreach ($event->getUsers() as $user) {
|
||||
$this->updateOrMarkUser($user);
|
||||
|
|
@ -107,6 +111,8 @@ class SharesUpdatedListener implements IEventListener {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
$this->homeSetupListener->setDisabled(false);
|
||||
}
|
||||
|
||||
private function markOrRun(IUser $user, callable $callback): void {
|
||||
|
|
|
|||
|
|
@ -23,16 +23,23 @@ use OCP\Files\Events\UserHomeSetupEvent;
|
|||
* @template-implements IEventListener<UserHomeSetupEvent>
|
||||
*/
|
||||
class UserHomeSetupListener implements IEventListener {
|
||||
private bool $disabled = false;
|
||||
public function __construct(
|
||||
private readonly ShareRecipientUpdater $updater,
|
||||
private readonly IUserConfig $userConfig,
|
||||
) {
|
||||
}
|
||||
|
||||
public function setDisabled(bool $disabled): void {
|
||||
$this->disabled = $disabled;
|
||||
}
|
||||
public function handle(Event $event): void {
|
||||
if (!$event instanceof UserHomeSetupEvent) {
|
||||
return;
|
||||
}
|
||||
if ($this->disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $event->getUser();
|
||||
if ($this->userConfig->getValueBool($user->getUID(), Application::APP_ID, ConfigLexicon::USER_NEEDS_SHARE_REFRESH, true)) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace OCA\Files_Sharing\Tests;
|
|||
use OCA\Files_Sharing\Config\ConfigLexicon;
|
||||
use OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent;
|
||||
use OCA\Files_Sharing\Listener\SharesUpdatedListener;
|
||||
use OCA\Files_Sharing\Listener\UserHomeSetupListener;
|
||||
use OCA\Files_Sharing\ShareRecipientUpdater;
|
||||
use OCP\Config\IUserConfig;
|
||||
use OCP\IAppConfig;
|
||||
|
|
@ -57,6 +58,7 @@ class SharesUpdatedListenerTest extends \Test\TestCase {
|
|||
return ($this->clockFn)();
|
||||
});
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$homeSetupListener = new UserHomeSetupListener($this->shareRecipientUpdater, $this->userConfig);
|
||||
|
||||
$this->sharesUpdatedListener = new SharesUpdatedListener(
|
||||
$this->manager,
|
||||
|
|
@ -65,6 +67,7 @@ class SharesUpdatedListenerTest extends \Test\TestCase {
|
|||
$this->clock,
|
||||
$this->logger,
|
||||
$this->appConfig,
|
||||
$homeSetupListener,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue