Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add notification for quota depletion #8610

Merged
merged 1 commit into from
Jul 28, 2023

Conversation

miaulalala
Copy link
Contributor

@miaulalala miaulalala commented Jul 6, 2023

Fixes #8513

How to test

If your hoster doesn't support the QUOTA extension, you can replace the code in the background job with the following:

		$previous = 80;
		$quota = new Quota(91, 100);

//		$quota = $this->mailManager->getQuota($account);
//		if($quota === null) {
//			$this->logger->debug('Could not get quota information for account <' . $account->getEmail() . '>', ['app' => 'mail']);
//			return;
//		}
//		$previous = $account->getMailAccount()->getQuotaPercentage();

Current text:
image

To Do

  • Test notifications ( I couldn't trigger them yet)
  • Background jobs for existing accounts
  • Tests

@miaulalala miaulalala added this to the v3.3.0 milestone Jul 6, 2023
@miaulalala miaulalala self-assigned this Jul 6, 2023
@miaulalala miaulalala added enhancement nextcloud-gmbh Tickets with importance for Nextcloud Gmbh labels Jul 6, 2023
@miaulalala miaulalala marked this pull request as draft July 6, 2023 15:50
@ChristophWurst ChristophWurst removed this from the v3.3.0 milestone Jul 6, 2023
@miaulalala miaulalala marked this pull request as ready for review July 20, 2023 15:26
@miaulalala miaulalala changed the title enh: add notification for quota depletion feat: add notification for quota depletion Jul 20, 2023
lib/BackgroundJob/QuotaJob.php Outdated Show resolved Hide resolved
lib/Migration/Version3300Date20230706140531.php Outdated Show resolved Hide resolved
lib/Account.php Outdated Show resolved Hide resolved
lib/Notification/Notifier.php Outdated Show resolved Hide resolved
Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it using your proposed hack and it seems to work.

The notification entries are created in the notifications table but they don't show up in the web ui for some reason. I also attached a debugger to the cron to make sure that the notification is triggered.

lib/BackgroundJob/QuotaJob.php Show resolved Hide resolved
lib/BackgroundJob/QuotaJob.php Outdated Show resolved Hide resolved
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good

lib/BackgroundJob/QuotaJob.php Outdated Show resolved Hide resolved
$this->jobList = $jobList;
$this->mailManager = $mailManager;

$this->setInterval(24 * 60 * 60);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO doing this less often would be fine too. The quota won't grow so rapidly. If it does, we won't catch it in time anyway.

@ChristophWurst ChristophWurst merged commit a15ccbe into main Jul 28, 2023
29 checks passed
@ChristophWurst ChristophWurst deleted the enh/quota-depletion-warning branch July 28, 2023 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review enhancement nextcloud-gmbh Tickets with importance for Nextcloud Gmbh
Projects
Development

Successfully merging this pull request may close these issues.

Warn the user about quota depletion
4 participants