mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
A lot of Misc Fixes (#2656)
This commit is contained in:
parent
088af37960
commit
b1e9d8cbba
@ -395,7 +395,7 @@ public class AccountController : BaseApiController
|
||||
// Send a confirmation email
|
||||
try
|
||||
{
|
||||
var emailLink = await _accountService.GenerateEmailLink(Request, user.ConfirmationToken, "confirm-email-update", dto.Email);
|
||||
var emailLink = await _emailService.GenerateEmailLink(Request, user.ConfirmationToken, "confirm-email-update", dto.Email);
|
||||
_logger.LogCritical("[Update Email]: Email Link for {UserName}: {Link}", user.UserName, emailLink);
|
||||
|
||||
if (!_emailService.IsValidEmail(user.Email))
|
||||
@ -585,7 +585,7 @@ public class AccountController : BaseApiController
|
||||
if (string.IsNullOrEmpty(user.ConfirmationToken))
|
||||
return BadRequest(await _localizationService.Translate(User.GetUserId(), "manual-setup-fail"));
|
||||
|
||||
return await _accountService.GenerateEmailLink(Request, user.ConfirmationToken, "confirm-email", user.Email!, withBaseUrl);
|
||||
return await _emailService.GenerateEmailLink(Request, user.ConfirmationToken, "confirm-email", user.Email!, withBaseUrl);
|
||||
}
|
||||
|
||||
|
||||
@ -691,7 +691,7 @@ public class AccountController : BaseApiController
|
||||
|
||||
try
|
||||
{
|
||||
var emailLink = await _accountService.GenerateEmailLink(Request, user.ConfirmationToken, "confirm-email", dto.Email);
|
||||
var emailLink = await _emailService.GenerateEmailLink(Request, user.ConfirmationToken, "confirm-email", dto.Email);
|
||||
_logger.LogCritical("[Invite User]: Email Link for {UserName}: {Link}", user.UserName, emailLink);
|
||||
|
||||
var settings = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
||||
@ -911,7 +911,7 @@ public class AccountController : BaseApiController
|
||||
}
|
||||
|
||||
var token = await _userManager.GeneratePasswordResetTokenAsync(user);
|
||||
var emailLink = await _accountService.GenerateEmailLink(Request, token, "confirm-reset-password", user.Email);
|
||||
var emailLink = await _emailService.GenerateEmailLink(Request, token, "confirm-reset-password", user.Email);
|
||||
user.ConfirmationToken = token;
|
||||
_unitOfWork.UserRepository.Update(user);
|
||||
await _unitOfWork.CommitAsync();
|
||||
@ -989,7 +989,7 @@ public class AccountController : BaseApiController
|
||||
user.ConfirmationToken = token;
|
||||
_unitOfWork.UserRepository.Update(user);
|
||||
await _unitOfWork.CommitAsync();
|
||||
var emailLink = await _accountService.GenerateEmailLink(Request, token, "confirm-email-update", user.Email);
|
||||
var emailLink = await _emailService.GenerateEmailLink(Request, token, "confirm-email-update", user.Email);
|
||||
_logger.LogCritical("[Email Migration]: Email Link for {UserName}: {Link}", user.UserName, emailLink);
|
||||
|
||||
if (!_emailService.IsValidEmail(user.Email))
|
||||
|
@ -126,7 +126,7 @@ public class DeviceController : BaseApiController
|
||||
}
|
||||
finally
|
||||
{
|
||||
await _eventHub.SendMessageToAsync(MessageFactory.SendingToDevice,
|
||||
await _eventHub.SendMessageToAsync(MessageFactory.NotificationProgress,
|
||||
MessageFactory.SendingToDeviceEvent(await _localizationService.Translate(userId, "send-to-device-status"),
|
||||
"ended"), userId);
|
||||
}
|
||||
@ -167,7 +167,7 @@ public class DeviceController : BaseApiController
|
||||
}
|
||||
finally
|
||||
{
|
||||
await _eventHub.SendMessageToAsync(MessageFactory.SendingToDevice,
|
||||
await _eventHub.SendMessageToAsync(MessageFactory.NotificationProgress,
|
||||
MessageFactory.SendingToDeviceEvent(await _localizationService.Translate(User.GetUserId(), "send-to-device-status"),
|
||||
"ended"), userId);
|
||||
}
|
||||
@ -175,8 +175,6 @@ public class DeviceController : BaseApiController
|
||||
return BadRequest(await _localizationService.Translate(User.GetUserId(), "generic-send-to"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,6 +112,13 @@ public class LibraryController : BaseApiController
|
||||
if (!await _unitOfWork.CommitAsync()) return BadRequest(await _localizationService.Translate(User.GetUserId(), "generic-library"));
|
||||
_logger.LogInformation("Created a new library: {LibraryName}", library.Name);
|
||||
|
||||
// Restart Folder watching if on
|
||||
var settings = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
||||
if (settings.EnableFolderWatching)
|
||||
{
|
||||
await _libraryWatcher.RestartWatching();
|
||||
}
|
||||
|
||||
// Assign all the necessary users with this library side nav
|
||||
var userIds = admins.Select(u => u.Id).Append(User.GetUserId()).ToList();
|
||||
var userNeedingNewLibrary = (await _unitOfWork.UserRepository.GetAllUsersAsync(AppUserIncludes.SideNavStreams))
|
||||
|
@ -209,18 +209,6 @@ public class ServerController : BaseApiController
|
||||
return Ok(await _versionUpdaterService.GetAllReleases());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is this server accessible to the outside net
|
||||
/// </summary>
|
||||
/// <remarks>If the instance has the HostName set, this will return true whether or not it is accessible externally</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("accessible")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<bool>> IsServerAccessible()
|
||||
{
|
||||
return Ok(await _accountService.CheckIfAccessible(Request));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of reoccurring jobs. Scheduled ad-hoc jobs will not be returned.
|
||||
/// </summary>
|
||||
|
@ -500,4 +500,16 @@ public class SettingsController : BaseApiController
|
||||
// NOTE: This must match Hangfire's underlying cron system. Hangfire is unique
|
||||
return Ok(CronHelper.IsValidCron(cronExpression));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a test email to see if email settings are hooked up correctly
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize(Policy = "RequireAdminRole")]
|
||||
[HttpPost("test-email-url")]
|
||||
public async Task<ActionResult<EmailTestResultDto>> TestEmailServiceUrl()
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(User.GetUserId());
|
||||
return Ok(await _emailService.SendTestEmail(user!.Email));
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,6 @@ public interface IAccountService
|
||||
Task<bool> HasBookmarkPermission(AppUser? user);
|
||||
Task<bool> HasDownloadPermission(AppUser? user);
|
||||
Task<bool> HasChangeRestrictionRole(AppUser? user);
|
||||
Task<bool> CheckIfAccessible(HttpRequest request);
|
||||
Task<string> GenerateEmailLink(HttpRequest request, string token, string routePart, string email, bool withHost = true);
|
||||
|
||||
}
|
||||
|
||||
public class AccountService : IAccountService
|
||||
@ -37,50 +34,13 @@ public class AccountService : IAccountService
|
||||
private readonly UserManager<AppUser> _userManager;
|
||||
private readonly ILogger<AccountService> _logger;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IHostEnvironment _environment;
|
||||
private readonly IEmailService _emailService;
|
||||
public const string DefaultPassword = "[k.2@RZ!mxCQkJzE";
|
||||
private const string LocalHost = "localhost:4200";
|
||||
|
||||
public AccountService(UserManager<AppUser> userManager, ILogger<AccountService> logger, IUnitOfWork unitOfWork,
|
||||
IHostEnvironment environment, IEmailService emailService)
|
||||
public AccountService(UserManager<AppUser> userManager, ILogger<AccountService> logger, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_logger = logger;
|
||||
_unitOfWork = unitOfWork;
|
||||
_environment = environment;
|
||||
_emailService = emailService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the instance is accessible. If the host name is filled out, then it will assume it is accessible as email generation will use host name.
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> CheckIfAccessible(HttpRequest request)
|
||||
{
|
||||
var host = _environment.IsDevelopment() ? LocalHost : request.Host.ToString();
|
||||
return !string.IsNullOrEmpty((await _unitOfWork.SettingsRepository.GetSettingsDtoAsync()).HostName) || await _emailService.CheckIfAccessible(host);
|
||||
}
|
||||
|
||||
public async Task<string> GenerateEmailLink(HttpRequest request, string token, string routePart, string email, bool withHost = true)
|
||||
{
|
||||
var serverSettings = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
||||
var host = _environment.IsDevelopment() ? LocalHost : request.Host.ToString();
|
||||
var basePart = $"{request.Scheme}://{host}{request.PathBase}/";
|
||||
if (!string.IsNullOrEmpty(serverSettings.HostName))
|
||||
{
|
||||
basePart = serverSettings.HostName;
|
||||
if (!serverSettings.BaseUrl.Equals(Configuration.DefaultBaseUrl))
|
||||
{
|
||||
var removeCount = serverSettings.BaseUrl.EndsWith('/') ? 1 : 0;
|
||||
basePart += serverSettings.BaseUrl.Substring(0, serverSettings.BaseUrl.Length - removeCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (withHost) return $"{basePart}/registration/{routePart}?token={HttpUtility.UrlEncode(token)}&email={HttpUtility.UrlEncode(email)}";
|
||||
return $"registration/{routePart}?token={HttpUtility.UrlEncode(token)}&email={HttpUtility.UrlEncode(email)}"
|
||||
.Replace("//", "/");
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ApiException>> ChangeUserPassword(AppUser user, string newPassword)
|
||||
|
@ -5,10 +5,13 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using API.Data;
|
||||
using API.DTOs.Email;
|
||||
using Kavita.Common;
|
||||
using MailKit.Security;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MimeKit;
|
||||
|
||||
@ -36,6 +39,9 @@ public interface IEmailService
|
||||
Task<EmailTestResultDto> SendTestEmail(string adminEmail);
|
||||
Task SendEmailChangeEmail(ConfirmationEmailDto data);
|
||||
bool IsValidEmail(string email);
|
||||
|
||||
Task<string> GenerateEmailLink(HttpRequest request, string token, string routePart, string email,
|
||||
bool withHost = true);
|
||||
}
|
||||
|
||||
public class EmailService : IEmailService
|
||||
@ -43,19 +49,17 @@ public class EmailService : IEmailService
|
||||
private readonly ILogger<EmailService> _logger;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IDirectoryService _directoryService;
|
||||
private readonly IHostEnvironment _environment;
|
||||
|
||||
private const string TemplatePath = @"{0}.html";
|
||||
/// <summary>
|
||||
/// This is used to initially set or reset the ServerSettingKey. Do not access from the code, access via UnitOfWork
|
||||
/// </summary>
|
||||
public const string DefaultApiUrl = "https://email.kavitareader.com";
|
||||
private const string LocalHost = "localhost:4200";
|
||||
|
||||
|
||||
public EmailService(ILogger<EmailService> logger, IUnitOfWork unitOfWork, IDirectoryService directoryService)
|
||||
public EmailService(ILogger<EmailService> logger, IUnitOfWork unitOfWork, IDirectoryService directoryService, IHostEnvironment environment)
|
||||
{
|
||||
_logger = logger;
|
||||
_unitOfWork = unitOfWork;
|
||||
_directoryService = directoryService;
|
||||
_environment = environment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -142,6 +146,26 @@ public class EmailService : IEmailService
|
||||
return new EmailAddressAttribute().IsValid(email);
|
||||
}
|
||||
|
||||
public async Task<string> GenerateEmailLink(HttpRequest request, string token, string routePart, string email, bool withHost = true)
|
||||
{
|
||||
var serverSettings = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
||||
var host = _environment.IsDevelopment() ? LocalHost : request.Host.ToString();
|
||||
var basePart = $"{request.Scheme}://{host}{request.PathBase}";
|
||||
if (!string.IsNullOrEmpty(serverSettings.HostName))
|
||||
{
|
||||
basePart = serverSettings.HostName;
|
||||
if (!serverSettings.BaseUrl.Equals(Configuration.DefaultBaseUrl))
|
||||
{
|
||||
var removeCount = serverSettings.BaseUrl.EndsWith('/') ? 1 : 0;
|
||||
basePart += serverSettings.BaseUrl[..^removeCount];
|
||||
}
|
||||
}
|
||||
|
||||
if (withHost) return $"{basePart}/registration/{routePart}?token={HttpUtility.UrlEncode(token)}&email={HttpUtility.UrlEncode(email)}";
|
||||
return $"registration/{routePart}?token={HttpUtility.UrlEncode(token)}&email={HttpUtility.UrlEncode(email)}"
|
||||
.Replace("//", "/");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invite email to a user to setup their account
|
||||
/// </summary>
|
||||
|
@ -10,7 +10,9 @@ public static class OsInfo
|
||||
public static bool IsLinux => Os is Os.Linux or Os.LinuxMusl or Os.Bsd;
|
||||
public static bool IsOsx => Os == Os.Osx;
|
||||
public static bool IsWindows => Os == Os.Windows;
|
||||
public static bool IsDocker => Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true";
|
||||
public static bool IsDocker =>
|
||||
Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true" ||
|
||||
Environment.GetEnvironmentVariable("LSIO_FIRST_PARTY") == "true";
|
||||
|
||||
static OsInfo()
|
||||
{
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import {DestroyRef, Injectable} from '@angular/core';
|
||||
import { of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import {filter, map, tap} from 'rxjs/operators';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { JumpKey } from '../_models/jumpbar/jump-key';
|
||||
import { Library, LibraryType } from '../_models/library/library';
|
||||
import { DirectoryDto } from '../_models/system/directory-dto';
|
||||
import {EVENTS, MessageHubService} from "./message-hub.service";
|
||||
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
||||
|
||||
|
||||
@Injectable({
|
||||
@ -18,7 +20,12 @@ export class LibraryService {
|
||||
private libraryNames: {[key:number]: string} | undefined = undefined;
|
||||
private libraryTypes: {[key: number]: LibraryType} | undefined = undefined;
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
constructor(private httpClient: HttpClient, private readonly messageHub: MessageHubService, private readonly destroyRef: DestroyRef) {
|
||||
this.messageHub.messages$.pipe(takeUntilDestroyed(this.destroyRef), filter(e => e.event === EVENTS.LibraryModified),
|
||||
tap((e) => {
|
||||
this.libraryNames = undefined;
|
||||
})).subscribe();
|
||||
}
|
||||
|
||||
getLibraryNames() {
|
||||
if (this.libraryNames != undefined) {
|
||||
|
@ -50,10 +50,6 @@ export class ServerService {
|
||||
return this.http.get<UpdateVersionEvent[]>(this.baseUrl + 'server/changelog', {});
|
||||
}
|
||||
|
||||
isServerAccessible() {
|
||||
return this.http.get<boolean>(this.baseUrl + 'server/accessible');
|
||||
}
|
||||
|
||||
getRecurringJobs() {
|
||||
return this.http.get<Job[]>(this.baseUrl + 'server/jobs');
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<ng-container *transloco="let t; read: 'manage-email-settings'">
|
||||
<div class="container-fluid">
|
||||
<form [formGroup]="settingsForm" *ngIf="serverSettings !== undefined">
|
||||
<h4>{{t('title')}}</h4>
|
||||
<h4 id="email-header">{{t('title')}}</h4>
|
||||
|
||||
<p>You must fill out both Host Name and SMTP settings to use email-based functionality within Kavita.</p>
|
||||
|
||||
@ -11,8 +11,13 @@
|
||||
<span class="visually-hidden" id="settings-hostname-help">
|
||||
<ng-container [ngTemplateOutlet]="hostNameTooltip"></ng-container>
|
||||
</span>
|
||||
<input id="settings-hostname" aria-describedby="settings-hostname-help" class="form-control" formControlName="hostName" type="text"
|
||||
[class.is-invalid]="settingsForm.get('hostName')?.invalid && settingsForm.get('hostName')?.touched">
|
||||
<div class="input-group">
|
||||
<input id="settings-hostname" aria-describedby="settings-hostname-help" class="form-control" formControlName="hostName" type="text"
|
||||
[class.is-invalid]="settingsForm.get('hostName')?.invalid && settingsForm.get('hostName')?.touched">
|
||||
<button class="btn btn-outline-secondary" (click)="autofillGmail()">{{t('gmail-label')}}</button>
|
||||
<button class="btn btn-outline-secondary" (click)="autofillOutlook()">{{t('outlook-label')}}</button>
|
||||
</div>
|
||||
|
||||
<div id="hostname-validations" class="invalid-feedback" *ngIf="settingsForm.dirty || settingsForm.touched">
|
||||
<div *ngIf="settingsForm.get('hostName')?.errors?.pattern">
|
||||
{{t('host-name-validation')}}
|
||||
@ -27,15 +32,17 @@
|
||||
<i class="fa fa-info-circle ms-1" aria-hidden="true" placement="right" [ngbTooltip]="senderAddressTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #senderAddressTooltip>{{t('sender-address-tooltip')}}</ng-template>
|
||||
<span class="visually-hidden" id="settings-sender-address-help"><ng-container [ngTemplateOutlet]="senderAddressTooltip"></ng-container></span>
|
||||
<input type="text" class="form-control" aria-describedby="manga-header" formControlName="senderAddress" id="settings-sender-address" />
|
||||
<input type="text" class="form-control" aria-describedby="email-header" formControlName="senderAddress" id="settings-sender-address" />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-md-6 col-sm-12 pe-2 ps-2 mb-2">
|
||||
<label for="settings-sender-displayname" class="form-label">{{t('sender-displayname-label')}}</label>
|
||||
<i class="fa fa-info-circle ms-1" aria-hidden="true" placement="right" [ngbTooltip]="senderDisplayNameTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #senderDisplayNameTooltip>{{t('sender-displayname-tooltip')}}</ng-template>
|
||||
<span class="visually-hidden" id="settings-sender-displayname-help"><ng-container [ngTemplateOutlet]="senderDisplayNameTooltip"></ng-container></span>
|
||||
<input type="text" class="form-control" aria-describedby="manga-header" formControlName="senderDisplayName" id="settings-sender-displayname" />
|
||||
<input type="text" class="form-control" aria-describedby="email-header" formControlName="senderDisplayName" id="settings-sender-displayname" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -45,12 +52,12 @@
|
||||
<i class="fa fa-info-circle ms-1" aria-hidden="true" placement="right" [ngbTooltip]="hostTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #hostTooltip>{{t('host-tooltip')}}</ng-template>
|
||||
<span class="visually-hidden" id="settings-host-help"><ng-container [ngTemplateOutlet]="hostTooltip"></ng-container></span>
|
||||
<input type="text" class="form-control" aria-describedby="manga-header" formControlName="host" id="settings-host" />
|
||||
<input type="text" class="form-control" aria-describedby="email-header" formControlName="host" id="settings-host" />
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-sm-12 pe-2 ps-2 mb-2">
|
||||
<label for="settings-port" class="form-label">{{t('port-label')}}</label>
|
||||
<input type="number" min="1" class="form-control" aria-describedby="manga-header" formControlName="port" id="settings-port" />
|
||||
<input type="number" min="1" class="form-control" aria-describedby="email-header" formControlName="port" id="settings-port" />
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-sm-12 pe-2 ps-2 mb-2">
|
||||
@ -68,12 +75,12 @@
|
||||
<i class="fa fa-info-circle ms-1" aria-hidden="true" placement="right" [ngbTooltip]="usernameTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #usernameTooltip>{{t('username-tooltip')}}</ng-template>
|
||||
<span class="visually-hidden" id="settings-username-help"><ng-container [ngTemplateOutlet]="usernameTooltip"></ng-container></span>
|
||||
<input type="text" class="form-control" aria-describedby="manga-header" formControlName="userName" id="settings-username" />
|
||||
<input type="text" class="form-control" aria-describedby="email-header" formControlName="userName" id="settings-username" />
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 col-sm-12 pe-2 ps-2 mb-2">
|
||||
<label for="settings-password" class="form-label">{{t('password-label')}}</label>
|
||||
<input type="password" class="form-control" aria-describedby="manga-header" formControlName="password" id="settings-password" />
|
||||
<input type="password" class="form-control" aria-describedby="email-header" formControlName="password" id="settings-password" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -83,7 +90,7 @@
|
||||
<i class="fa fa-info-circle ms-1" aria-hidden="true" placement="right" [ngbTooltip]="sizeLimitTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #sizeLimitTooltip>{{t('size-limit-tooltip')}}</ng-template>
|
||||
<span class="visually-hidden" id="settings-size-limit-help"><ng-container [ngTemplateOutlet]="sizeLimitTooltip"></ng-container></span>
|
||||
<input type="text" class="form-control" aria-describedby="manga-header" formControlName="sizeLimit" id="settings-size-limit" />
|
||||
<input type="text" class="form-control" aria-describedby="email-header" formControlName="sizeLimit" id="settings-size-limit" />
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 col-sm-12 pe-2 ps-2 mb-2">
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, OnInit} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||
import {ToastrService} from 'ngx-toastr';
|
||||
import {take} from 'rxjs';
|
||||
@ -15,6 +15,8 @@ import {NgForOf, NgIf, NgTemplateOutlet, TitleCasePipe} from '@angular/common';
|
||||
import {translate, TranslocoModule} from "@ngneat/transloco";
|
||||
import {SafeHtmlPipe} from "../../_pipes/safe-html.pipe";
|
||||
import {ManageAlertsComponent} from "../manage-alerts/manage-alerts.component";
|
||||
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
||||
import {filter} from "rxjs/operators";
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-email-settings',
|
||||
@ -22,7 +24,9 @@ import {ManageAlertsComponent} from "../manage-alerts/manage-alerts.component";
|
||||
styleUrls: ['./manage-email-settings.component.scss'],
|
||||
standalone: true,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [NgIf, ReactiveFormsModule, NgbTooltip, NgTemplateOutlet, TranslocoModule, SafeHtmlPipe, ManageAlertsComponent, NgbAccordionBody, NgbAccordionButton, NgbAccordionCollapse, NgbAccordionDirective, NgbAccordionHeader, NgbAccordionItem, NgForOf, TitleCasePipe]
|
||||
imports: [NgIf, ReactiveFormsModule, NgbTooltip, NgTemplateOutlet, TranslocoModule, SafeHtmlPipe,
|
||||
ManageAlertsComponent, NgbAccordionBody, NgbAccordionButton, NgbAccordionCollapse, NgbAccordionDirective,
|
||||
NgbAccordionHeader, NgbAccordionItem, NgForOf, TitleCasePipe]
|
||||
})
|
||||
export class ManageEmailSettingsComponent implements OnInit {
|
||||
|
||||
@ -47,6 +51,7 @@ export class ManageEmailSettingsComponent implements OnInit {
|
||||
this.settingsForm.addControl('senderDisplayName', new FormControl(this.serverSettings.smtpConfig.senderDisplayName, []));
|
||||
this.settingsForm.addControl('sizeLimit', new FormControl(this.serverSettings.smtpConfig.sizeLimit, [Validators.min(1)]));
|
||||
this.settingsForm.addControl('customizedTemplates', new FormControl(this.serverSettings.smtpConfig.customizedTemplates, [Validators.min(1)]));
|
||||
|
||||
this.cdRef.markForCheck();
|
||||
});
|
||||
}
|
||||
@ -67,6 +72,22 @@ export class ManageEmailSettingsComponent implements OnInit {
|
||||
this.cdRef.markForCheck();
|
||||
}
|
||||
|
||||
autofillGmail() {
|
||||
this.settingsForm.get('host')?.setValue('smtp.gmail.com');
|
||||
this.settingsForm.get('port')?.setValue(587);
|
||||
this.settingsForm.get('sizeLimit')?.setValue(26214400);
|
||||
this.settingsForm.get('enableSsl')?.setValue(true);
|
||||
this.cdRef.markForCheck();
|
||||
}
|
||||
|
||||
autofillOutlook() {
|
||||
this.settingsForm.get('host')?.setValue('smtp-mail.outlook.com');
|
||||
this.settingsForm.get('port')?.setValue(587 );
|
||||
this.settingsForm.get('sizeLimit')?.setValue(1048576);
|
||||
this.settingsForm.get('enableSsl')?.setValue(true);
|
||||
this.cdRef.markForCheck();
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
const modelSettings = Object.assign({}, this.serverSettings);
|
||||
modelSettings.emailServiceUrl = this.settingsForm.get('emailServiceUrl')?.value;
|
||||
|
@ -206,9 +206,9 @@ export class InfiniteScrollerComponent implements OnInit, OnChanges, OnDestroy {
|
||||
.pipe(debounceTime(20), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((event) => this.handleScrollEvent(event));
|
||||
|
||||
// fromEvent(this.isFullscreenMode ? this.readerElemRef.nativeElement : this.document.body, 'scrollend')
|
||||
// .pipe(debounceTime(20), takeUntilDestroyed(this.destroyRef))
|
||||
// .subscribe((event) => this.handleScrollEndEvent(event));
|
||||
fromEvent(this.isFullscreenMode ? this.readerElemRef.nativeElement : this.document.body, 'scrollend')
|
||||
.pipe(debounceTime(20), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((event) => this.handleScrollEndEvent(event));
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
@ -1094,6 +1094,8 @@
|
||||
"size-limit-tooltip": "How many bytes can the Email Server handle for attachments",
|
||||
"customized-templates-label": "Customized Templates",
|
||||
"customized-templates-tooltip": "Should Kavita use config/templates directory for templates rather than default? You are responsible to keep up to date with template changes.",
|
||||
"gmail-label": "Gmail",
|
||||
"outlook-label": "Outlook",
|
||||
|
||||
"reset-to-default": "{{common.reset-to-default}}",
|
||||
"save": "{{common.save}}"
|
||||
|
@ -7,7 +7,7 @@
|
||||
"name": "GPL-3.0",
|
||||
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
||||
},
|
||||
"version": "0.7.13.2"
|
||||
"version": "0.7.13.5"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user