Skip to content

Commit

Permalink
Merge pull request #85 from Lombiq/issue/NEST-423
Browse files Browse the repository at this point in the history
NEST-423: Small modifications regarding email quota module
  • Loading branch information
DemeSzabolcs authored Sep 25, 2023
2 parents 7f9b63c + ea2539a commit 32c35dd
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 60 deletions.
6 changes: 0 additions & 6 deletions Lombiq.Hosting.Tenants.Admin.Login/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ public void ConfigureServices(IServiceCollection services) =>
```

**NOTE:** This way the feature will also be enabled on the Default tenant. Therefore, for greater security, the controller does not perform anything on the Default tenant.

## Dependencies

This module has the following dependencies:

- [Lombiq Helpful Libraries for Orchard Core](https://github.com/Lombiq/Helpful-Libraries)
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ await contentZone.AddAsync(
await _shapeFactory.CreateAsync("EmailSettingsQuota", new
{
CurrentEmailCount = quota.CurrentEmailQuotaCount,
_emailQuotaOptions.EmailQuota,
EmailQuota = _emailQuotaOptions.EmailQuotaPerMonth,
}),
"0");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace Lombiq.Hosting.Tenants.EmailQuotaManagement.Models;

public class EmailQuotaOptions
{
public int EmailQuota { get; set; }
public int EmailQuotaPerMonth { get; set; }
}
22 changes: 5 additions & 17 deletions Lombiq.Hosting.Tenants.EmailQuotaManagement/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## About

With the help of this module, you can set restrictions regarding maximum email sent per tenant per month, if they are using the same SMTP server host as the predefined one from the environment variables or from the `appsettings.json` file.
With the help of this module, you can set restrictions regarding maximum email sent per tenant per month, if they are using the same SMTP server host as the predefined one from the environment variables or from the _appsettings.json_ file.

Do you want to quickly try out this project and see it in action? Check it out in our [Open-Source Orchard Core Extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions) full Orchard Core solution and also see our other useful Orchard Core-related open-source projects!

Expand All @@ -16,17 +16,17 @@ This module currently contains one feature:

### `Lombiq.Hosting.Tenants.EmailQuotaManagement`

With this module, you can specify how much space would you like to limit each tenant's maximum email quota. The default is 1000 per month. You can change this value in the `appsettings.json` file or with an environment variable. When the quota is reached the email won't be sent and also the following will happen:
With this module, you can specify how much space would you like to limit each tenant's maximum email quota. The default is 1000 per month. You can change this value in the _appsettings.json_ file or with an environment variable. When the quota is reached the email won't be sent and also the following will happen:

- An email will be sent to the tenant's users who has Site Owner permission.
- A warning message will be shown that the limit has been reached on the admin dashboard.

Also a warning message is always shown with the current email quota status on the email settings page when the same host is used as the predefined one from the environment variables or from the `appsettings.json` file.
Also a warning message is always shown with the current email quota status on the email settings page when the same host is used as the predefined one from the environment variables or from the _appsettings.json_ file.

```json
"OrchardCore": {
"Lombiq_Hosting_Tenants_EmailQuotaManagement": {
"EmailQuota": 42069
"EmailQuotaPerMonth": 42069
}
}
```
Expand All @@ -37,20 +37,8 @@ Tenant based configuration can be defined as the following, for more details rea
"OrchardCore": {
"TenantName": {
"Lombiq_Hosting_Tenants_EmailQuotaManagement": {
"EmailQuota": 42069
"EmailQuotaPerMonth": 42069
}
}
}
```

## Dependencies

This module has the following dependencies:

- [Lombiq Helpful Libraries for Orchard Core](https://github.com/Lombiq/Helpful-Libraries)

## Contributing and support

Bug reports, feature requests, comments, questions, code contributions and love letters are warmly welcome. You can send them to us via GitHub issues and pull requests. Please adhere to our [open-source guidelines](https://lombiq.com/open-source-guidelines) while doing so.

This project is developed by [Lombiq Technologies](https://lombiq.com/). Commercial-grade support is available through Lombiq.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private Task SendAlertEmailIfNecessaryAsync(EmailQuota emailQuota)
ShellScope.AddDeferredTask(async _ =>
{
var emailParameters = await _emailQuotaEmailService.CreateEmailForExceedingQuotaAsync();
emailParameters.Body = await _emailTemplateService.RenderEmailTemplateAsync("EmailQuote", new
emailParameters.Body = await _emailTemplateService.RenderEmailTemplateAsync("EmailQuota", new
{
HostName = _shellSettings.Name,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task<QuotaResult> IsQuotaOverTheLimitAsync()
var currentQuota = await GetCurrentQuotaAsync();
return new QuotaResult
{
IsOverQuota = _emailQuotaOptions.EmailQuota <= currentQuota.CurrentEmailQuotaCount,
IsOverQuota = _emailQuotaOptions.EmailQuotaPerMonth <= currentQuota.CurrentEmailQuotaCount,
EmailQuota = currentQuota,
};
}
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Hosting.Tenants.EmailQuotaManagement/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddDataMigration<EmailQuotaMigrations>();
services.AddSingleton<IIndexProvider, EmailQuotaIndexProvider>();
services.Configure<EmailQuotaOptions>(options =>
options.EmailQuota = _shellConfiguration.GetValue<int?>("Lombiq_Hosting_Tenants_EmailQuotaManagement:EmailQuota")
options.EmailQuotaPerMonth = _shellConfiguration.GetValue<int?>("Lombiq_Hosting_Tenants_EmailQuotaManagement:EmailQuota")
?? DefaultEmailQuota);

services.AddScoped<IQuotaService, QuotaService>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@{
ViewLayout = "Layout__EmailTemplate";
}
@T["<p>Hi</p><p> It seems that your {0} site sent out more e-mails than the available quota for this month. E-mail sending has been stopped until next month (any feature sending out e-mails will fail).</p><p> Thank you,<br/> Your Admin Crew</p> ", Model.HostName]

This file was deleted.

6 changes: 0 additions & 6 deletions Lombiq.Hosting.Tenants.Management/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,3 @@ public void ConfigureServices(IServiceCollection services) =>
```

**NOTE:** This extension method not only sets the tags you want to hide but also registers the feature as a setup feature. If you just want to use the default `HideFromSetupScreen` tag then just call the extension method without any parameter.

## Dependencies

This module has the following dependencies:

- [Lombiq Helpful Libraries for Orchard Core](https://github.com/Lombiq/Helpful-Libraries)
14 changes: 1 addition & 13 deletions Lombiq.Hosting.Tenants.MediaStorageManagement/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This module currently contains one feature:

### `Lombiq.Hosting.Tenants.MediaStorageManagement`

With this module, you can specify how much space would you like to limit each tenant's storage space. The default is 1GB. If you want to set it to 2GB e.g. you can do it in bytes as an environment variable or in `appsettings.json` as follows:
With this module, you can specify how much space would you like to limit each tenant's storage space. The default is 1GB. If you want to set it to 2GB e.g. you can do it in bytes as an environment variable or in _appsettings.json_ as follows:

```json
"OrchardCore": {
Expand All @@ -37,15 +37,3 @@ Tenant based configuration can be defined as the following, for more details rea
}
}
```

## Dependencies

This module has the following dependencies:

- [Lombiq Helpful Libraries for Orchard Core](https://github.com/Lombiq/Helpful-Libraries)

## Contributing and support

Bug reports, feature requests, comments, questions, code contributions and love letters are warmly welcome. You can send them to us via GitHub issues and pull requests. Please adhere to our [open-source guidelines](https://lombiq.com/open-source-guidelines) while doing so.

This project is developed by [Lombiq Technologies](https://lombiq.com/). Commercial-grade support is available through Lombiq.

0 comments on commit 32c35dd

Please sign in to comment.