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:
parent
7317b354ee
commit
e9f9a3aa88
@ -44,17 +44,11 @@ export class TopPickSendJob extends Job<{
|
||||
defaultValue: 5,
|
||||
}, {
|
||||
id: 'emailTo',
|
||||
type: 'email',
|
||||
type: 'string-array',
|
||||
name: backendTexts.emailTo.name,
|
||||
description: backendTexts.emailTo.description,
|
||||
defaultValue: '',
|
||||
}, {
|
||||
id: 'emailFrom',
|
||||
type: 'email',
|
||||
name: backendTexts.emailFrom.name,
|
||||
description: backendTexts.emailFrom.description,
|
||||
defaultValue: 'norelpy@pigallery2.com',
|
||||
}, {
|
||||
defaultValue: [],
|
||||
}, {
|
||||
id: 'emailSubject',
|
||||
type: 'string',
|
||||
name: backendTexts.emailSubject.name,
|
||||
@ -105,7 +99,6 @@ export class TopPickSendJob extends Job<{
|
||||
this.Progress.log('Sending emails');
|
||||
const messenger = new EmailMediaMessenger();
|
||||
await messenger.sendMedia({
|
||||
from: this.config.emailFrom,
|
||||
to: this.config.emailTo,
|
||||
subject: this.config.emailSubject,
|
||||
text: this.config.emailText
|
||||
|
@ -42,7 +42,6 @@ export class EmailMediaMessenger {
|
||||
}
|
||||
|
||||
public async sendMedia(mailSettings: {
|
||||
from: string,
|
||||
to: string,
|
||||
subject: string,
|
||||
text: string
|
||||
@ -84,7 +83,7 @@ export class EmailMediaMessenger {
|
||||
}
|
||||
|
||||
return await this.transporter.sendMail({
|
||||
from: mailSettings.from,
|
||||
from: Config.Messaging.Email.emailFrom,
|
||||
to: mailSettings.to,
|
||||
subject: mailSettings.subject,
|
||||
html: htmlStart + htmlMiddle + htmlEnd,
|
||||
|
@ -7,7 +7,6 @@ export const backendTexts = {
|
||||
sortBy: {name: 50, description: 52},
|
||||
pickAmount: {name: 60, description: 62},
|
||||
emailTo: {name: 70, description: 72},
|
||||
emailFrom: {name: 80, description: 82},
|
||||
emailSubject: {name: 90, description: 92},
|
||||
emailText: {name: 100, description: 102}
|
||||
|
||||
|
@ -3,6 +3,7 @@ import {SubConfigClass} from '../../../../node_modules/typeconfig/src/decorators
|
||||
import {ConfigPriority, TAGS} from '../public/ClientConfig';
|
||||
import {ConfigProperty} from '../../../../node_modules/typeconfig/src/decorators/property/ConfigPropoerty';
|
||||
import {ServerConfig} from './PrivateConfig';
|
||||
|
||||
declare let $localize: (s: TemplateStringsArray) => string;
|
||||
|
||||
if (typeof $localize === 'undefined') {
|
||||
@ -10,6 +11,7 @@ if (typeof $localize === 'undefined') {
|
||||
// @ts-ignore
|
||||
global.$localize = (s) => s;
|
||||
}
|
||||
|
||||
export enum EmailMessagingType {
|
||||
sendmail = 1,
|
||||
SMTP = 2,
|
||||
@ -91,6 +93,16 @@ export class EmailMessagingConfig {
|
||||
})
|
||||
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({
|
||||
tags:
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 {
|
||||
Indexing = 1,
|
||||
|
@ -35,10 +35,6 @@ export class BackendtextService {
|
||||
return $localize`E-mail to`;
|
||||
case backendTexts.emailTo.description:
|
||||
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:
|
||||
return $localize`Subject`;
|
||||
case backendTexts.emailSubject.description:
|
||||
|
@ -176,12 +176,12 @@
|
||||
[(ngModel)]="schedule.config[configEntry.id]" required>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngSwitchCase="'email'">
|
||||
<input type="email" class="form-control" [name]="configEntry.id+'_'+i"
|
||||
<ng-container *ngSwitchCase="'string-array'">
|
||||
<input type="text" class="form-control"
|
||||
[name]="configEntry.id+'_'+i"
|
||||
[id]="configEntry.id+'_'+i"
|
||||
placeholder="adress@domain.com"
|
||||
(ngModelChange)="onChange($event)"
|
||||
[(ngModel)]="schedule.config[configEntry.id]" required>
|
||||
(ngModelChange)="setEmailArray(schedule.config,configEntry.id,$event); onChange($event);"
|
||||
[ngModel]="getArray($any(schedule.config),configEntry.id)" required>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngSwitchCase="'number'">
|
||||
@ -196,7 +196,7 @@
|
||||
[name]="configEntry.id+'_'+i"
|
||||
[id]="configEntry.id+'_'+i"
|
||||
(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>
|
||||
|
||||
<app-gallery-search-field
|
||||
|
@ -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 {
|
||||
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);
|
||||
}
|
||||
|
||||
getNumberArray(configElement: Record<string, number[]>, id: string): string {
|
||||
return configElement[id] ? configElement[id].join('; ') : '';
|
||||
}
|
||||
|
||||
public shouldIdent(curr: JobScheduleDTO, prev: JobScheduleDTO): boolean {
|
||||
return (
|
||||
@ -284,7 +292,6 @@ export class WorkflowComponent implements ControlValueAccessor, Validator, OnIni
|
||||
}
|
||||
|
||||
|
||||
|
||||
AsSortArray(configElement: string | number | string[] | number[]): SortingMethods[] {
|
||||
return configElement as SortingMethods[];
|
||||
}
|
||||
@ -294,6 +301,6 @@ export class WorkflowComponent implements ControlValueAccessor, Validator, OnIni
|
||||
}
|
||||
|
||||
AddNewSorting(configElement: string | number | string[] | number[]): void {
|
||||
(configElement as SortingMethods[]).push(SortingMethods.ascDate)
|
||||
(configElement as SortingMethods[]).push(SortingMethods.ascDate);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user