1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Add option to list multiple recipients #683

This commit is contained in:
Patrik J. Braun 2023-08-01 15:30:11 +02:00
parent 7317b354ee
commit e9f9a3aa88
8 changed files with 35 additions and 29 deletions

View File

@ -44,16 +44,10 @@ export class TopPickSendJob extends Job<{
defaultValue: 5, defaultValue: 5,
}, { }, {
id: 'emailTo', id: 'emailTo',
type: 'email', type: 'string-array',
name: backendTexts.emailTo.name, name: backendTexts.emailTo.name,
description: backendTexts.emailTo.description, description: backendTexts.emailTo.description,
defaultValue: '', defaultValue: [],
}, {
id: 'emailFrom',
type: 'email',
name: backendTexts.emailFrom.name,
description: backendTexts.emailFrom.description,
defaultValue: 'norelpy@pigallery2.com',
}, { }, {
id: 'emailSubject', id: 'emailSubject',
type: 'string', type: 'string',
@ -105,7 +99,6 @@ export class TopPickSendJob extends Job<{
this.Progress.log('Sending emails'); this.Progress.log('Sending emails');
const messenger = new EmailMediaMessenger(); const messenger = new EmailMediaMessenger();
await messenger.sendMedia({ await messenger.sendMedia({
from: this.config.emailFrom,
to: this.config.emailTo, to: this.config.emailTo,
subject: this.config.emailSubject, subject: this.config.emailSubject,
text: this.config.emailText text: this.config.emailText

View File

@ -42,7 +42,6 @@ export class EmailMediaMessenger {
} }
public async sendMedia(mailSettings: { public async sendMedia(mailSettings: {
from: string,
to: string, to: string,
subject: string, subject: string,
text: string text: string
@ -84,7 +83,7 @@ export class EmailMediaMessenger {
} }
return await this.transporter.sendMail({ return await this.transporter.sendMail({
from: mailSettings.from, from: Config.Messaging.Email.emailFrom,
to: mailSettings.to, to: mailSettings.to,
subject: mailSettings.subject, subject: mailSettings.subject,
html: htmlStart + htmlMiddle + htmlEnd, html: htmlStart + htmlMiddle + htmlEnd,

View File

@ -7,7 +7,6 @@ export const backendTexts = {
sortBy: {name: 50, description: 52}, sortBy: {name: 50, description: 52},
pickAmount: {name: 60, description: 62}, pickAmount: {name: 60, description: 62},
emailTo: {name: 70, description: 72}, emailTo: {name: 70, description: 72},
emailFrom: {name: 80, description: 82},
emailSubject: {name: 90, description: 92}, emailSubject: {name: 90, description: 92},
emailText: {name: 100, description: 102} emailText: {name: 100, description: 102}

View File

@ -3,6 +3,7 @@ import {SubConfigClass} from '../../../../node_modules/typeconfig/src/decorators
import {ConfigPriority, TAGS} from '../public/ClientConfig'; import {ConfigPriority, TAGS} from '../public/ClientConfig';
import {ConfigProperty} from '../../../../node_modules/typeconfig/src/decorators/property/ConfigPropoerty'; import {ConfigProperty} from '../../../../node_modules/typeconfig/src/decorators/property/ConfigPropoerty';
import {ServerConfig} from './PrivateConfig'; import {ServerConfig} from './PrivateConfig';
declare let $localize: (s: TemplateStringsArray) => string; declare let $localize: (s: TemplateStringsArray) => string;
if (typeof $localize === 'undefined') { if (typeof $localize === 'undefined') {
@ -10,6 +11,7 @@ if (typeof $localize === 'undefined') {
// @ts-ignore // @ts-ignore
global.$localize = (s) => s; global.$localize = (s) => s;
} }
export enum EmailMessagingType { export enum EmailMessagingType {
sendmail = 1, sendmail = 1,
SMTP = 2, SMTP = 2,
@ -91,6 +93,16 @@ export class EmailMessagingConfig {
}) })
type: EmailMessagingType = EmailMessagingType.sendmail; type: EmailMessagingType = EmailMessagingType.sendmail;
@ConfigProperty<EmailMessagingType, EmailMessagingConfig>({
tags:
{
name: $localize`Sender email`,
priority: ConfigPriority.advanced,
} as TAGS,
description: $localize`Some services do not allow sending from random e-mail addresses. Set this accordingly.`
})
emailFrom: string = 'noreply@pigallery2.com';
@ConfigProperty({ @ConfigProperty({
tags: tags:
{ {

View File

@ -1,6 +1,6 @@
import {backendText} from '../../BackendTexts'; import {backendText} from '../../BackendTexts';
export type fieldType = 'string' | 'email' | 'number' | 'boolean' | 'number-array' | 'SearchQuery' | 'sort-array'; export type fieldType = 'string' | 'string-array' | 'number' | 'boolean' | 'number-array' | 'SearchQuery' | 'sort-array';
export enum DefaultsJobs { export enum DefaultsJobs {
Indexing = 1, Indexing = 1,

View File

@ -35,10 +35,6 @@ export class BackendtextService {
return $localize`E-mail to`; return $localize`E-mail to`;
case backendTexts.emailTo.description: case backendTexts.emailTo.description:
return $localize`E-mail address of the recipient.`; return $localize`E-mail address of the recipient.`;
case backendTexts.emailFrom.name:
return $localize`E-mail From`;
case backendTexts.emailFrom.description:
return $localize`E-mail sender address.`;
case backendTexts.emailSubject.name: case backendTexts.emailSubject.name:
return $localize`Subject`; return $localize`Subject`;
case backendTexts.emailSubject.description: case backendTexts.emailSubject.description:

View File

@ -176,12 +176,12 @@
[(ngModel)]="schedule.config[configEntry.id]" required> [(ngModel)]="schedule.config[configEntry.id]" required>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'email'"> <ng-container *ngSwitchCase="'string-array'">
<input type="email" class="form-control" [name]="configEntry.id+'_'+i" <input type="text" class="form-control"
[name]="configEntry.id+'_'+i"
[id]="configEntry.id+'_'+i" [id]="configEntry.id+'_'+i"
placeholder="adress@domain.com" (ngModelChange)="setEmailArray(schedule.config,configEntry.id,$event); onChange($event);"
(ngModelChange)="onChange($event)" [ngModel]="getArray($any(schedule.config),configEntry.id)" required>
[(ngModel)]="schedule.config[configEntry.id]" required>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'number'"> <ng-container *ngSwitchCase="'number'">
@ -196,7 +196,7 @@
[name]="configEntry.id+'_'+i" [name]="configEntry.id+'_'+i"
[id]="configEntry.id+'_'+i" [id]="configEntry.id+'_'+i"
(ngModelChange)="setNumberArray(schedule.config,configEntry.id,$event); onChange($event);" (ngModelChange)="setNumberArray(schedule.config,configEntry.id,$event); onChange($event);"
[ngModel]="getNumberArray($any(schedule.config),configEntry.id)" required> [ngModel]="getArray($any(schedule.config),configEntry.id)" required>
</ng-container> </ng-container>
<app-gallery-search-field <app-gallery-search-field

View File

@ -159,6 +159,17 @@ export class WorkflowComponent implements ControlValueAccessor, Validator, OnIni
} }
} }
setEmailArray(configElement: any, id: string, value: string): void {
value = value.replace(new RegExp(',', 'g'), ';');
value = value.replace(new RegExp(' ', 'g'), ';');
configElement[id] = value
.split(';').filter((i: string) => i != '');
}
getArray(configElement: Record<string, number[]>, id: string): string {
return configElement[id] && Array.isArray(configElement[id]) ? configElement[id].join('; ') : '';
}
setNumberArray(configElement: any, id: string, value: string): void { setNumberArray(configElement: any, id: string, value: string): void {
value = value.replace(new RegExp(',', 'g'), ';'); value = value.replace(new RegExp(',', 'g'), ';');
value = value.replace(new RegExp(' ', 'g'), ';'); value = value.replace(new RegExp(' ', 'g'), ';');
@ -168,9 +179,6 @@ export class WorkflowComponent implements ControlValueAccessor, Validator, OnIni
.filter((i: number) => !isNaN(i) && i > 0); .filter((i: number) => !isNaN(i) && i > 0);
} }
getNumberArray(configElement: Record<string, number[]>, id: string): string {
return configElement[id] ? configElement[id].join('; ') : '';
}
public shouldIdent(curr: JobScheduleDTO, prev: JobScheduleDTO): boolean { public shouldIdent(curr: JobScheduleDTO, prev: JobScheduleDTO): boolean {
return ( return (
@ -284,7 +292,6 @@ export class WorkflowComponent implements ControlValueAccessor, Validator, OnIni
} }
AsSortArray(configElement: string | number | string[] | number[]): SortingMethods[] { AsSortArray(configElement: string | number | string[] | number[]): SortingMethods[] {
return configElement as SortingMethods[]; return configElement as SortingMethods[];
} }
@ -294,6 +301,6 @@ export class WorkflowComponent implements ControlValueAccessor, Validator, OnIni
} }
AddNewSorting(configElement: string | number | string[] | number[]): void { AddNewSorting(configElement: string | number | string[] | number[]): void {
(configElement as SortingMethods[]).push(SortingMethods.ascDate) (configElement as SortingMethods[]).push(SortingMethods.ascDate);
} }
} }