chore: apply ESLint auto-fix across entire backend
Build and Push Multi-Platform Images / build-and-push (push) Successful in 41s

Reformats code style (line breaks, indentation, type annotations)
without changing logic. Also includes minor feature additions bundled
in the same lint run (stats service, user-settings groups, agrarmonitor
polling improvements).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 09:02:02 +02:00
parent 4c75a1ded2
commit dad0136365
74 changed files with 4022 additions and 1052 deletions
@@ -47,7 +47,10 @@ export class UserSettingsService {
if (!this.encKey) return plaintext;
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv(ALGORITHM, this.encKey, iv);
const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);
const encrypted = Buffer.concat([
cipher.update(plaintext, 'utf8'),
cipher.final(),
]);
const authTag = cipher.getAuthTag();
return `enc:${iv.toString('hex')}:${authTag.toString('hex')}:${encrypted.toString('hex')}`;
}
@@ -62,10 +65,18 @@ export class UserSettingsService {
const encrypted = Buffer.from(encryptedHex, 'hex');
const decipher = crypto.createDecipheriv(ALGORITHM, this.encKey, iv);
decipher.setAuthTag(authTag);
return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString('utf8');
return Buffer.concat([
decipher.update(encrypted),
decipher.final(),
]).toString('utf8');
}
async getSettings(userId: string, email?: string, preferredUsername?: string, groups?: string[]): Promise<UserSettingsDto> {
async getSettings(
userId: string,
email?: string,
preferredUsername?: string,
groups?: string[],
): Promise<UserSettingsDto> {
let entity = await this.repo.findOne({ where: { UserId: userId } });
if (email || preferredUsername || groups) {
if (!entity) {
@@ -107,15 +118,24 @@ export class UserSettingsService {
if (data.smtpPort !== undefined) entity.SmtpPort = data.smtpPort;
if (data.smtpSecure !== undefined) entity.SmtpSecure = data.smtpSecure;
if (data.smtpUser !== undefined) entity.SmtpUser = data.smtpUser;
if (data.smtpPass !== undefined && data.smtpPass !== null && data.smtpPass !== '') {
if (
data.smtpPass !== undefined &&
data.smtpPass !== null &&
data.smtpPass !== ''
) {
entity.SmtpPass = this.encrypt(data.smtpPass);
}
if (data.smtpFrom !== undefined) entity.SmtpFrom = data.smtpFrom;
if (data.smtpFromName !== undefined) entity.SmtpFromName = data.smtpFromName;
if (data.mailSignatureHtml !== undefined) entity.MailSignatureHtml = data.mailSignatureHtml;
if (data.defaultLabelTemplateId !== undefined) entity.DefaultLabelTemplateId = data.defaultLabelTemplateId;
if (data.emailRecipientHistory !== undefined) entity.EmailRecipientHistory = data.emailRecipientHistory;
if (data.dailyDigestEnabled !== undefined) entity.DailyDigestEnabled = data.dailyDigestEnabled;
if (data.smtpFromName !== undefined)
entity.SmtpFromName = data.smtpFromName;
if (data.mailSignatureHtml !== undefined)
entity.MailSignatureHtml = data.mailSignatureHtml;
if (data.defaultLabelTemplateId !== undefined)
entity.DefaultLabelTemplateId = data.defaultLabelTemplateId;
if (data.emailRecipientHistory !== undefined)
entity.EmailRecipientHistory = data.emailRecipientHistory;
if (data.dailyDigestEnabled !== undefined)
entity.DailyDigestEnabled = data.dailyDigestEnabled;
if (email) entity.UserEmail = email;
if (preferredUsername) entity.UserPreferredUsername = preferredUsername;
if (groups) entity.UserGroups = groups;
@@ -146,12 +166,19 @@ export class UserSettingsService {
}
async getSmtpConfig(userId: string): Promise<{
host: string; port: number; secure: boolean; user: string; pass: string; from: string;
host: string;
port: number;
secure: boolean;
user: string;
pass: string;
from: string;
} | null> {
const entity = await this.repo.findOne({ where: { UserId: userId } });
if (!entity?.SmtpHost || !entity?.SmtpPass) return null;
const fromEmail = entity.SmtpFrom ?? entity.SmtpUser ?? '';
const from = entity.SmtpFromName ? `"${entity.SmtpFromName}" <${fromEmail}>` : fromEmail;
const from = entity.SmtpFromName
? `"${entity.SmtpFromName}" <${fromEmail}>`
: fromEmail;
return {
host: entity.SmtpHost,
port: entity.SmtpPort ?? 587,
@@ -163,21 +190,34 @@ export class UserSettingsService {
}
async findAllDigestSubscribers(): Promise<UserSettings[]> {
return this.repo.find({
where: { DailyDigestEnabled: true },
}).then(rows => rows.filter(r => !!r.UserEmail));
return this.repo
.find({
where: { DailyDigestEnabled: true },
})
.then((rows) => rows.filter((r) => !!r.UserEmail));
}
async getAvailableSenders(userId: string): Promise<{ id: string; label: string }[]> {
const defaultEmail = this.configService.get<string>('SMTP_FROM', 'paperless@localhost');
async getAvailableSenders(
userId: string,
): Promise<{ id: string; label: string }[]> {
const defaultEmail = this.configService.get<string>(
'SMTP_FROM',
'paperless@localhost',
);
const defaultName = this.configService.get<string>('SMTP_FROM_NAME', '');
const defaultLabel = defaultName ? `${defaultName} <${defaultEmail}>` : defaultEmail;
const senders: { id: string; label: string }[] = [{ id: 'default', label: defaultLabel }];
const defaultLabel = defaultName
? `${defaultName} <${defaultEmail}>`
: defaultEmail;
const senders: { id: string; label: string }[] = [
{ id: 'default', label: defaultLabel },
];
const entity = await this.repo.findOne({ where: { UserId: userId } });
if (entity?.SmtpHost && entity?.SmtpPass) {
const userEmail = entity.SmtpFrom ?? entity.SmtpUser ?? '';
const userLabel = entity.SmtpFromName ? `${entity.SmtpFromName} <${userEmail}>` : userEmail;
const userLabel = entity.SmtpFromName
? `${entity.SmtpFromName} <${userEmail}>`
: userEmail;
senders.push({ id: 'user', label: userLabel });
}
@@ -190,7 +230,7 @@ export class UserSettingsService {
smtpPort: entity?.SmtpPort ?? null,
smtpSecure: entity?.SmtpSecure ?? false,
smtpUser: entity?.SmtpUser ?? null,
smtpPassSet: !!(entity?.SmtpPass),
smtpPassSet: !!entity?.SmtpPass,
smtpFrom: entity?.SmtpFrom ?? null,
smtpFromName: entity?.SmtpFromName ?? null,
mailSignatureHtml: entity?.MailSignatureHtml ?? null,