Browse Source

- Updated mail storage to be by bytes.

- Added upload limits to multiple spots
feature/billing
Teknikode 6 months ago
parent
commit
7f1efd40d5
  1. 2
      BillingService/Program.cs
  2. 8
      MailService/HMailService.cs
  3. 4
      MailService/IMailService.cs
  4. 2
      Teknik/Areas/Billing/BillingHelper.cs
  5. 2
      Teknik/Areas/Billing/Controllers/BillingController.cs
  6. 4
      Teknik/Areas/User/Controllers/UserController.cs
  7. 2
      Teknik/Areas/User/Utility/UserHelper.cs
  8. 3
      Teknik/Areas/User/ViewModels/UploadSettingsViewModel.cs
  9. 16
      Teknik/Areas/User/Views/User/Settings/UploadSettings.cshtml

2
BillingService/Program.cs

@ -94,7 +94,7 @@ namespace Teknik.BillingService @@ -94,7 +94,7 @@ namespace Teknik.BillingService
if (emailPrice != null)
{
UserHelper.EnableUserEmail(config, email);
UserHelper.EditUserEmailMaxSize(config, email, (int)emailPrice.Storage);
UserHelper.EditUserEmailMaxSize(config, email, emailPrice.Storage);
}
}
else

8
MailService/HMailService.cs

@ -35,14 +35,14 @@ namespace Teknik.MailService @@ -35,14 +35,14 @@ namespace Teknik.MailService
_App = InitApp();
}
public void CreateAccount(string username, string password, int size)
public void CreateAccount(string username, string password, long size)
{
var domain = _App.Domains.ItemByName[_Domain];
var newAccount = domain.Accounts.Add();
newAccount.Address = username;
newAccount.Password = password;
newAccount.Active = true;
newAccount.MaxSize = size;
newAccount.MaxSize = (int)(size / 1000000);
newAccount.Save();
}
@ -94,10 +94,10 @@ namespace Teknik.MailService @@ -94,10 +94,10 @@ namespace Teknik.MailService
mySQL.Execute(sql, new object[] { maxPerDay, username });
}
public void EditMaxSize(string username, int size)
public void EditMaxSize(string username, long size)
{
var account = GetAccount(username);
account.MaxSize = size;
account.MaxSize = (int)(size / 1000000);
account.Save();
}

4
MailService/IMailService.cs

@ -10,11 +10,11 @@ namespace Teknik.MailService @@ -10,11 +10,11 @@ namespace Teknik.MailService
bool Enabled(string username);
void CreateAccount(string username, string password, int size);
void CreateAccount(string username, string password, long size);
void EditPassword(string username, string password);
void EditMaxSize(string username, int size);
void EditMaxSize(string username, long size);
void EditMaxEmailsPerDay(string username, int maxPerDay);

2
Teknik/Areas/Billing/BillingHelper.cs

@ -44,7 +44,7 @@ namespace Teknik.Areas.Billing @@ -44,7 +44,7 @@ namespace Teknik.Areas.Billing
if (active)
{
UserHelper.EnableUserEmail(config, email);
UserHelper.EditUserEmailMaxSize(config, email, (int)price.Storage);
UserHelper.EditUserEmailMaxSize(config, email, price.Storage);
}
else
{

2
Teknik/Areas/Billing/Controllers/BillingController.cs

@ -34,6 +34,8 @@ namespace Teknik.Areas.Billing.Controllers @@ -34,6 +34,8 @@ namespace Teknik.Areas.Billing.Controllers
[AllowAnonymous]
public IActionResult ViewSubscriptions()
{
ViewBag.Title = "Subscriptions";
var subVM = new SubscriptionsViewModel();
// Get Biling Service

4
Teknik/Areas/User/Controllers/UserController.cs

@ -580,6 +580,10 @@ namespace Teknik.Areas.Users.Controllers @@ -580,6 +580,10 @@ namespace Teknik.Areas.Users.Controllers
model.Page = "Upload";
model.UserID = user.UserId;
model.Username = user.Username;
model.MaxStorage = user.UploadSettings.MaxUploadStorage ?? _config.UploadConfig.MaxStorage;
model.MaxFileSize = user.UploadSettings.MaxUploadFileSize ?? _config.UploadConfig.MaxUploadFileSize;
model.Encrypt = user.UploadSettings.Encrypt;
model.ExpirationLength = user.UploadSettings.ExpirationLength;
model.ExpirationUnit = user.UploadSettings.ExpirationUnit;

2
Teknik/Areas/User/Utility/UserHelper.cs

@ -751,7 +751,7 @@ If you recieved this email and you did not reset your password, you can ignore t @@ -751,7 +751,7 @@ If you recieved this email and you did not reset your password, you can ignore t
}
}
public static void EditUserEmailMaxSize(Config config, string email, int size)
public static void EditUserEmailMaxSize(Config config, string email, long size)
{
try
{

3
Teknik/Areas/User/ViewModels/UploadSettingsViewModel.cs

@ -10,6 +10,9 @@ namespace Teknik.Areas.Users.ViewModels @@ -10,6 +10,9 @@ namespace Teknik.Areas.Users.ViewModels
{
public class UploadSettingsViewModel : SettingsViewModel
{
public long MaxStorage { get; set; }
public long MaxFileSize { get; set; }
public bool Encrypt { get; set; }
public int ExpirationLength { get; set; }
public ExpirationUnit ExpirationUnit { get; set; }

16
Teknik/Areas/User/Views/User/Settings/UploadSettings.cshtml

@ -12,6 +12,22 @@ @@ -12,6 +12,22 @@
<bundle src="css/user.settings.upload.min.css" append-version="true"></bundle>
<div class="row">
<div class="col-md-12">
<h3 class="text-center">Upload Limits</h3>
<div class="row">
<div class="col-md-2 col-sm-offset-1"><strong>Storage</strong></div>
<div class="col-md-9"><strong>@StringHelper.GetBytesReadable(Model.MaxStorage)</strong></div>
</div>
<div class="row">
<div class="col-md-2 col-sm-offset-1"><strong>File Size</strong></div>
<div class="col-md-9"><strong>@StringHelper.GetBytesReadable(Model.MaxFileSize)</strong></div>
</div>
</div>
</div>
<br />
<hr />
<!form class="form" action="##" method="post" id="updateForm">
<div class="row form-horizontal">

Loading…
Cancel
Save