Added ability to send me information about K+ instance for support.
This commit is contained in:
parent
cc4de12df8
commit
d943c66bcf
5 changed files with 76 additions and 32 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using API.Constants;
|
||||
using API.Data;
|
||||
using API.Data.ManualMigrations;
|
||||
using API.DTOs;
|
||||
|
|
@ -16,12 +17,10 @@ namespace API.Controllers;
|
|||
public class AdminController : BaseApiController
|
||||
{
|
||||
private readonly UserManager<AppUser> _userManager;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public AdminController(UserManager<AppUser> userManager, IUnitOfWork unitOfWork)
|
||||
public AdminController(UserManager<AppUser> userManager)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -32,18 +31,7 @@ public class AdminController : BaseApiController
|
|||
[HttpGet("exists")]
|
||||
public async Task<ActionResult<bool>> AdminExists()
|
||||
{
|
||||
var users = await _userManager.GetUsersInRoleAsync("Admin");
|
||||
var users = await _userManager.GetUsersInRoleAsync(PolicyConstants.AdminRole);
|
||||
return users.Count > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the progress information for a particular user
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize("RequireAdminRole")]
|
||||
[HttpPost("update-chapter-progress")]
|
||||
public async Task<ActionResult<bool>> UpdateChapterProgress(UpdateUserProgressDto dto)
|
||||
{
|
||||
return Ok(await Task.FromResult(false));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace API.DTOs.Progress;
|
||||
#nullable enable
|
||||
|
||||
public class UpdateUserProgressDto
|
||||
{
|
||||
public int PageNum { get; set; }
|
||||
public DateTime LastModifiedUtc { get; set; }
|
||||
public DateTime CreatedUtc { get; set; }
|
||||
}
|
||||
20
API/EmailTemplates/KavitaPlusDebug.html
Normal file
20
API/EmailTemplates/KavitaPlusDebug.html
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<tr>
|
||||
<td valign="top" style="text-align: center; padding: 20px 0 10px 20px;">
|
||||
<h1 style="margin: 0; font-family: 'Montserrat', sans-serif; font-size: 30px; line-height: 36px; font-weight: bold;">A User needs manual registration</h1> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="center" style="text-align: center; padding: 15px 0px 20px 0px;">
|
||||
<center>
|
||||
<table role="presentation" align="center" cellspacing="0" cellpadding="0" border="0" class="center-on-narrow">
|
||||
<tr>
|
||||
<td class="button-td">
|
||||
InstallId: {{InstallId}}
|
||||
</td>
|
||||
<td class="button-td">
|
||||
Build: {{Build}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using API.Data;
|
||||
|
|
@ -11,6 +12,7 @@ using API.DTOs.Email;
|
|||
using API.Entities;
|
||||
using API.Services.Plus;
|
||||
using Kavita.Common;
|
||||
using Kavita.Common.EnvironmentInfo;
|
||||
using Kavita.Common.Extensions;
|
||||
using MailKit.Security;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
|
@ -52,6 +54,7 @@ public interface IEmailService
|
|||
|
||||
Task<bool> SendTokenExpiredEmail(int userId, ScrobbleProvider provider);
|
||||
Task<bool> SendTokenExpiringSoonEmail(int userId, ScrobbleProvider provider);
|
||||
Task<bool> SendKavitaPlusDebug();
|
||||
}
|
||||
|
||||
public class EmailService : IEmailService
|
||||
|
|
@ -72,6 +75,7 @@ public class EmailService : IEmailService
|
|||
public const string TokenExpiringSoonTemplate = "TokenExpiringSoon";
|
||||
public const string EmailConfirmTemplate = "EmailConfirm";
|
||||
public const string EmailPasswordResetTemplate = "EmailPasswordReset";
|
||||
public const string KavitaPlusDebugTemplate = "KavitaPlusDebug";
|
||||
|
||||
public EmailService(ILogger<EmailService> logger, IUnitOfWork unitOfWork, IDirectoryService directoryService,
|
||||
IHostEnvironment environment, ILocalizationService localizationService)
|
||||
|
|
@ -259,6 +263,40 @@ public class EmailService : IEmailService
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends information about Kavita install for Kavita+ registration
|
||||
/// </summary>
|
||||
/// <example>Users in China can have issues subscribing, this flow will allow me to register their instance on their behalf</example>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> SendKavitaPlusDebug()
|
||||
{
|
||||
var settings = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
||||
if (!settings.IsEmailSetup()) return false;
|
||||
|
||||
var placeholders = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new ("{{InstallId}}", HashUtil.ServerToken()),
|
||||
new ("{{Build}}", BuildInfo.Version.ToString()),
|
||||
};
|
||||
|
||||
var emailOptions = new EmailOptionsDto()
|
||||
{
|
||||
Subject = UpdatePlaceHolders("Kavita+: A User needs manual registration", placeholders),
|
||||
Template = KavitaPlusDebugTemplate,
|
||||
Body = UpdatePlaceHolders(await GetEmailBody(KavitaPlusDebugTemplate), placeholders),
|
||||
Preheader = UpdatePlaceHolders("Kavita+: A User needs manual registration", placeholders),
|
||||
ToEmails =
|
||||
[
|
||||
// My kavita email
|
||||
Encoding.UTF8.GetString(Convert.FromBase64String("a2F2aXRhcmVhZGVyQGdtYWlsLmNvbQ=="))
|
||||
]
|
||||
};
|
||||
|
||||
await SendEmail(emailOptions);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invite email to a user to setup their account
|
||||
/// </summary>
|
||||
|
|
@ -304,10 +342,10 @@ public class EmailService : IEmailService
|
|||
Template = EmailPasswordResetTemplate,
|
||||
Body = UpdatePlaceHolders(await GetEmailBody(EmailPasswordResetTemplate), placeholders),
|
||||
Preheader = "Email confirmation is required for continued access. Click the button to confirm your email.",
|
||||
ToEmails = new List<string>()
|
||||
{
|
||||
ToEmails =
|
||||
[
|
||||
dto.EmailAddress
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
await SendEmail(emailOptions);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue