1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-10 23:22:22 +02:00

feat(server): email notifications (#8447)

* feat(server): add `react-mail` as mail template engine and `nodemailer`

* feat(server): add `smtp` related configs to `SystemConfig`

* feat(web): add page for SMTP settings

* feat(server): add `react-email.adapter`

This adapter render the React-Email into HTML and plain/text email.
The output is set as the body of the email.

* feat(server): add `MailRepository` and `MailService`

Allow to use the NestJS-modules-mailer module to send SMTP emails.
This is the base transport for the `NotificationRepository`

* feat(server): register the job dispatcher and Job for async email

This allows to queue email sending jobs for the `EmailService`.

* feat(server): add `NotificationRepository` and `NotificationService`

This act as a middleware to properly route the notification to the right transport.
As POC I've only implemented a simple SMTP transport.

* feat(server): add `welcome` email template

* feat(server): add the first notification on `createUser` in `UserService`

This trigger an event for the `NotificationRepository` that once processes
by using the global config and per-user config will carry the payload to the right notification transport.

* chore: clean up

* chore: clean up web

* fix: type errors"

* fix package lock

* fix mail sending, option to ignore certs

* chore: open api

* chore: clean up

* remove unused import

* feat: email feature flag

* chore: remove unused interface

* small styling

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Nicolò
2024-05-02 16:43:18 +02:00
committed by GitHub
parent 4b86c7a298
commit 9bce3417e9
60 changed files with 6499 additions and 371 deletions

View File

@@ -202,10 +202,13 @@ part 'model/system_config_logging_dto.dart';
part 'model/system_config_machine_learning_dto.dart';
part 'model/system_config_map_dto.dart';
part 'model/system_config_new_version_check_dto.dart';
part 'model/system_config_notifications_dto.dart';
part 'model/system_config_o_auth_dto.dart';
part 'model/system_config_password_login_dto.dart';
part 'model/system_config_reverse_geocoding_dto.dart';
part 'model/system_config_server_dto.dart';
part 'model/system_config_smtp_dto.dart';
part 'model/system_config_smtp_transport_dto.dart';
part 'model/system_config_storage_template_dto.dart';
part 'model/system_config_template_storage_option_dto.dart';
part 'model/system_config_theme_dto.dart';

View File

@@ -474,6 +474,8 @@ class ApiClient {
return SystemConfigMapDto.fromJson(value);
case 'SystemConfigNewVersionCheckDto':
return SystemConfigNewVersionCheckDto.fromJson(value);
case 'SystemConfigNotificationsDto':
return SystemConfigNotificationsDto.fromJson(value);
case 'SystemConfigOAuthDto':
return SystemConfigOAuthDto.fromJson(value);
case 'SystemConfigPasswordLoginDto':
@@ -482,6 +484,10 @@ class ApiClient {
return SystemConfigReverseGeocodingDto.fromJson(value);
case 'SystemConfigServerDto':
return SystemConfigServerDto.fromJson(value);
case 'SystemConfigSmtpDto':
return SystemConfigSmtpDto.fromJson(value);
case 'SystemConfigSmtpTransportDto':
return SystemConfigSmtpTransportDto.fromJson(value);
case 'SystemConfigStorageTemplateDto':
return SystemConfigStorageTemplateDto.fromJson(value);
case 'SystemConfigTemplateStorageOptionDto':

View File

@@ -19,6 +19,7 @@ class AllJobStatusResponseDto {
required this.library_,
required this.metadataExtraction,
required this.migration,
required this.notifications,
required this.search,
required this.sidecar,
required this.smartSearch,
@@ -39,6 +40,8 @@ class AllJobStatusResponseDto {
JobStatusDto migration;
JobStatusDto notifications;
JobStatusDto search;
JobStatusDto sidecar;
@@ -59,6 +62,7 @@ class AllJobStatusResponseDto {
other.library_ == library_ &&
other.metadataExtraction == metadataExtraction &&
other.migration == migration &&
other.notifications == notifications &&
other.search == search &&
other.sidecar == sidecar &&
other.smartSearch == smartSearch &&
@@ -75,6 +79,7 @@ class AllJobStatusResponseDto {
(library_.hashCode) +
(metadataExtraction.hashCode) +
(migration.hashCode) +
(notifications.hashCode) +
(search.hashCode) +
(sidecar.hashCode) +
(smartSearch.hashCode) +
@@ -83,7 +88,7 @@ class AllJobStatusResponseDto {
(videoConversion.hashCode);
@override
String toString() => 'AllJobStatusResponseDto[backgroundTask=$backgroundTask, faceDetection=$faceDetection, facialRecognition=$facialRecognition, library_=$library_, metadataExtraction=$metadataExtraction, migration=$migration, search=$search, sidecar=$sidecar, smartSearch=$smartSearch, storageTemplateMigration=$storageTemplateMigration, thumbnailGeneration=$thumbnailGeneration, videoConversion=$videoConversion]';
String toString() => 'AllJobStatusResponseDto[backgroundTask=$backgroundTask, faceDetection=$faceDetection, facialRecognition=$facialRecognition, library_=$library_, metadataExtraction=$metadataExtraction, migration=$migration, notifications=$notifications, search=$search, sidecar=$sidecar, smartSearch=$smartSearch, storageTemplateMigration=$storageTemplateMigration, thumbnailGeneration=$thumbnailGeneration, videoConversion=$videoConversion]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -93,6 +98,7 @@ class AllJobStatusResponseDto {
json[r'library'] = this.library_;
json[r'metadataExtraction'] = this.metadataExtraction;
json[r'migration'] = this.migration;
json[r'notifications'] = this.notifications;
json[r'search'] = this.search;
json[r'sidecar'] = this.sidecar;
json[r'smartSearch'] = this.smartSearch;
@@ -116,6 +122,7 @@ class AllJobStatusResponseDto {
library_: JobStatusDto.fromJson(json[r'library'])!,
metadataExtraction: JobStatusDto.fromJson(json[r'metadataExtraction'])!,
migration: JobStatusDto.fromJson(json[r'migration'])!,
notifications: JobStatusDto.fromJson(json[r'notifications'])!,
search: JobStatusDto.fromJson(json[r'search'])!,
sidecar: JobStatusDto.fromJson(json[r'sidecar'])!,
smartSearch: JobStatusDto.fromJson(json[r'smartSearch'])!,
@@ -175,6 +182,7 @@ class AllJobStatusResponseDto {
'library',
'metadataExtraction',
'migration',
'notifications',
'search',
'sidecar',
'smartSearch',

View File

@@ -16,6 +16,7 @@ class CreateUserDto {
required this.email,
this.memoriesEnabled,
required this.name,
this.notify,
required this.password,
this.quotaSizeInBytes,
this.shouldChangePassword,
@@ -34,6 +35,14 @@ class CreateUserDto {
String name;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? notify;
String password;
/// Minimum value: 1
@@ -54,6 +63,7 @@ class CreateUserDto {
other.email == email &&
other.memoriesEnabled == memoriesEnabled &&
other.name == name &&
other.notify == notify &&
other.password == password &&
other.quotaSizeInBytes == quotaSizeInBytes &&
other.shouldChangePassword == shouldChangePassword &&
@@ -65,13 +75,14 @@ class CreateUserDto {
(email.hashCode) +
(memoriesEnabled == null ? 0 : memoriesEnabled!.hashCode) +
(name.hashCode) +
(notify == null ? 0 : notify!.hashCode) +
(password.hashCode) +
(quotaSizeInBytes == null ? 0 : quotaSizeInBytes!.hashCode) +
(shouldChangePassword == null ? 0 : shouldChangePassword!.hashCode) +
(storageLabel == null ? 0 : storageLabel!.hashCode);
@override
String toString() => 'CreateUserDto[email=$email, memoriesEnabled=$memoriesEnabled, name=$name, password=$password, quotaSizeInBytes=$quotaSizeInBytes, shouldChangePassword=$shouldChangePassword, storageLabel=$storageLabel]';
String toString() => 'CreateUserDto[email=$email, memoriesEnabled=$memoriesEnabled, name=$name, notify=$notify, password=$password, quotaSizeInBytes=$quotaSizeInBytes, shouldChangePassword=$shouldChangePassword, storageLabel=$storageLabel]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -82,6 +93,11 @@ class CreateUserDto {
// json[r'memoriesEnabled'] = null;
}
json[r'name'] = this.name;
if (this.notify != null) {
json[r'notify'] = this.notify;
} else {
// json[r'notify'] = null;
}
json[r'password'] = this.password;
if (this.quotaSizeInBytes != null) {
json[r'quotaSizeInBytes'] = this.quotaSizeInBytes;
@@ -112,6 +128,7 @@ class CreateUserDto {
email: mapValueOfType<String>(json, r'email')!,
memoriesEnabled: mapValueOfType<bool>(json, r'memoriesEnabled'),
name: mapValueOfType<String>(json, r'name')!,
notify: mapValueOfType<bool>(json, r'notify'),
password: mapValueOfType<String>(json, r'password')!,
quotaSizeInBytes: mapValueOfType<int>(json, r'quotaSizeInBytes'),
shouldChangePassword: mapValueOfType<bool>(json, r'shouldChangePassword'),

View File

@@ -35,6 +35,7 @@ class JobName {
static const search = JobName._(r'search');
static const sidecar = JobName._(r'sidecar');
static const library_ = JobName._(r'library');
static const notifications = JobName._(r'notifications');
/// List of all possible values in this [enum][JobName].
static const values = <JobName>[
@@ -50,6 +51,7 @@ class JobName {
search,
sidecar,
library_,
notifications,
];
static JobName? fromJson(dynamic value) => JobNameTypeTransformer().decode(value);
@@ -100,6 +102,7 @@ class JobNameTypeTransformer {
case r'search': return JobName.search;
case r'sidecar': return JobName.sidecar;
case r'library': return JobName.library_;
case r'notifications': return JobName.notifications;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');

View File

@@ -14,6 +14,7 @@ class ServerFeaturesDto {
/// Returns a new [ServerFeaturesDto] instance.
ServerFeaturesDto({
required this.configFile,
required this.email,
required this.facialRecognition,
required this.map,
required this.oauth,
@@ -28,6 +29,8 @@ class ServerFeaturesDto {
bool configFile;
bool email;
bool facialRecognition;
bool map;
@@ -51,6 +54,7 @@ class ServerFeaturesDto {
@override
bool operator ==(Object other) => identical(this, other) || other is ServerFeaturesDto &&
other.configFile == configFile &&
other.email == email &&
other.facialRecognition == facialRecognition &&
other.map == map &&
other.oauth == oauth &&
@@ -66,6 +70,7 @@ class ServerFeaturesDto {
int get hashCode =>
// ignore: unnecessary_parenthesis
(configFile.hashCode) +
(email.hashCode) +
(facialRecognition.hashCode) +
(map.hashCode) +
(oauth.hashCode) +
@@ -78,11 +83,12 @@ class ServerFeaturesDto {
(trash.hashCode);
@override
String toString() => 'ServerFeaturesDto[configFile=$configFile, facialRecognition=$facialRecognition, map=$map, oauth=$oauth, oauthAutoLaunch=$oauthAutoLaunch, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, search=$search, sidecar=$sidecar, smartSearch=$smartSearch, trash=$trash]';
String toString() => 'ServerFeaturesDto[configFile=$configFile, email=$email, facialRecognition=$facialRecognition, map=$map, oauth=$oauth, oauthAutoLaunch=$oauthAutoLaunch, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, search=$search, sidecar=$sidecar, smartSearch=$smartSearch, trash=$trash]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'configFile'] = this.configFile;
json[r'email'] = this.email;
json[r'facialRecognition'] = this.facialRecognition;
json[r'map'] = this.map;
json[r'oauth'] = this.oauth;
@@ -105,6 +111,7 @@ class ServerFeaturesDto {
return ServerFeaturesDto(
configFile: mapValueOfType<bool>(json, r'configFile')!,
email: mapValueOfType<bool>(json, r'email')!,
facialRecognition: mapValueOfType<bool>(json, r'facialRecognition')!,
map: mapValueOfType<bool>(json, r'map')!,
oauth: mapValueOfType<bool>(json, r'oauth')!,
@@ -163,6 +170,7 @@ class ServerFeaturesDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'configFile',
'email',
'facialRecognition',
'map',
'oauth',

View File

@@ -21,6 +21,7 @@ class SystemConfigDto {
required this.machineLearning,
required this.map,
required this.newVersionCheck,
required this.notifications,
required this.oauth,
required this.passwordLogin,
required this.reverseGeocoding,
@@ -47,6 +48,8 @@ class SystemConfigDto {
SystemConfigNewVersionCheckDto newVersionCheck;
SystemConfigNotificationsDto notifications;
SystemConfigOAuthDto oauth;
SystemConfigPasswordLoginDto passwordLogin;
@@ -73,6 +76,7 @@ class SystemConfigDto {
other.machineLearning == machineLearning &&
other.map == map &&
other.newVersionCheck == newVersionCheck &&
other.notifications == notifications &&
other.oauth == oauth &&
other.passwordLogin == passwordLogin &&
other.reverseGeocoding == reverseGeocoding &&
@@ -93,6 +97,7 @@ class SystemConfigDto {
(machineLearning.hashCode) +
(map.hashCode) +
(newVersionCheck.hashCode) +
(notifications.hashCode) +
(oauth.hashCode) +
(passwordLogin.hashCode) +
(reverseGeocoding.hashCode) +
@@ -103,7 +108,7 @@ class SystemConfigDto {
(user.hashCode);
@override
String toString() => 'SystemConfigDto[ffmpeg=$ffmpeg, image=$image, job=$job, library_=$library_, logging=$logging, machineLearning=$machineLearning, map=$map, newVersionCheck=$newVersionCheck, oauth=$oauth, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, server=$server, storageTemplate=$storageTemplate, theme=$theme, trash=$trash, user=$user]';
String toString() => 'SystemConfigDto[ffmpeg=$ffmpeg, image=$image, job=$job, library_=$library_, logging=$logging, machineLearning=$machineLearning, map=$map, newVersionCheck=$newVersionCheck, notifications=$notifications, oauth=$oauth, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, server=$server, storageTemplate=$storageTemplate, theme=$theme, trash=$trash, user=$user]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -115,6 +120,7 @@ class SystemConfigDto {
json[r'machineLearning'] = this.machineLearning;
json[r'map'] = this.map;
json[r'newVersionCheck'] = this.newVersionCheck;
json[r'notifications'] = this.notifications;
json[r'oauth'] = this.oauth;
json[r'passwordLogin'] = this.passwordLogin;
json[r'reverseGeocoding'] = this.reverseGeocoding;
@@ -142,6 +148,7 @@ class SystemConfigDto {
machineLearning: SystemConfigMachineLearningDto.fromJson(json[r'machineLearning'])!,
map: SystemConfigMapDto.fromJson(json[r'map'])!,
newVersionCheck: SystemConfigNewVersionCheckDto.fromJson(json[r'newVersionCheck'])!,
notifications: SystemConfigNotificationsDto.fromJson(json[r'notifications'])!,
oauth: SystemConfigOAuthDto.fromJson(json[r'oauth'])!,
passwordLogin: SystemConfigPasswordLoginDto.fromJson(json[r'passwordLogin'])!,
reverseGeocoding: SystemConfigReverseGeocodingDto.fromJson(json[r'reverseGeocoding'])!,
@@ -205,6 +212,7 @@ class SystemConfigDto {
'machineLearning',
'map',
'newVersionCheck',
'notifications',
'oauth',
'passwordLogin',
'reverseGeocoding',

View File

@@ -18,6 +18,7 @@ class SystemConfigJobDto {
required this.library_,
required this.metadataExtraction,
required this.migration,
required this.notifications,
required this.search,
required this.sidecar,
required this.smartSearch,
@@ -35,6 +36,8 @@ class SystemConfigJobDto {
JobSettingsDto migration;
JobSettingsDto notifications;
JobSettingsDto search;
JobSettingsDto sidecar;
@@ -52,6 +55,7 @@ class SystemConfigJobDto {
other.library_ == library_ &&
other.metadataExtraction == metadataExtraction &&
other.migration == migration &&
other.notifications == notifications &&
other.search == search &&
other.sidecar == sidecar &&
other.smartSearch == smartSearch &&
@@ -66,6 +70,7 @@ class SystemConfigJobDto {
(library_.hashCode) +
(metadataExtraction.hashCode) +
(migration.hashCode) +
(notifications.hashCode) +
(search.hashCode) +
(sidecar.hashCode) +
(smartSearch.hashCode) +
@@ -73,7 +78,7 @@ class SystemConfigJobDto {
(videoConversion.hashCode);
@override
String toString() => 'SystemConfigJobDto[backgroundTask=$backgroundTask, faceDetection=$faceDetection, library_=$library_, metadataExtraction=$metadataExtraction, migration=$migration, search=$search, sidecar=$sidecar, smartSearch=$smartSearch, thumbnailGeneration=$thumbnailGeneration, videoConversion=$videoConversion]';
String toString() => 'SystemConfigJobDto[backgroundTask=$backgroundTask, faceDetection=$faceDetection, library_=$library_, metadataExtraction=$metadataExtraction, migration=$migration, notifications=$notifications, search=$search, sidecar=$sidecar, smartSearch=$smartSearch, thumbnailGeneration=$thumbnailGeneration, videoConversion=$videoConversion]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -82,6 +87,7 @@ class SystemConfigJobDto {
json[r'library'] = this.library_;
json[r'metadataExtraction'] = this.metadataExtraction;
json[r'migration'] = this.migration;
json[r'notifications'] = this.notifications;
json[r'search'] = this.search;
json[r'sidecar'] = this.sidecar;
json[r'smartSearch'] = this.smartSearch;
@@ -103,6 +109,7 @@ class SystemConfigJobDto {
library_: JobSettingsDto.fromJson(json[r'library'])!,
metadataExtraction: JobSettingsDto.fromJson(json[r'metadataExtraction'])!,
migration: JobSettingsDto.fromJson(json[r'migration'])!,
notifications: JobSettingsDto.fromJson(json[r'notifications'])!,
search: JobSettingsDto.fromJson(json[r'search'])!,
sidecar: JobSettingsDto.fromJson(json[r'sidecar'])!,
smartSearch: JobSettingsDto.fromJson(json[r'smartSearch'])!,
@@ -160,6 +167,7 @@ class SystemConfigJobDto {
'library',
'metadataExtraction',
'migration',
'notifications',
'search',
'sidecar',
'smartSearch',

View File

@@ -0,0 +1,98 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class SystemConfigNotificationsDto {
/// Returns a new [SystemConfigNotificationsDto] instance.
SystemConfigNotificationsDto({
required this.smtp,
});
SystemConfigSmtpDto smtp;
@override
bool operator ==(Object other) => identical(this, other) || other is SystemConfigNotificationsDto &&
other.smtp == smtp;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(smtp.hashCode);
@override
String toString() => 'SystemConfigNotificationsDto[smtp=$smtp]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'smtp'] = this.smtp;
return json;
}
/// Returns a new [SystemConfigNotificationsDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SystemConfigNotificationsDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return SystemConfigNotificationsDto(
smtp: SystemConfigSmtpDto.fromJson(json[r'smtp'])!,
);
}
return null;
}
static List<SystemConfigNotificationsDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SystemConfigNotificationsDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SystemConfigNotificationsDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SystemConfigNotificationsDto> mapFromJson(dynamic json) {
final map = <String, SystemConfigNotificationsDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SystemConfigNotificationsDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SystemConfigNotificationsDto-objects as value to a dart map
static Map<String, List<SystemConfigNotificationsDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SystemConfigNotificationsDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SystemConfigNotificationsDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'smtp',
};
}

View File

@@ -0,0 +1,122 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class SystemConfigSmtpDto {
/// Returns a new [SystemConfigSmtpDto] instance.
SystemConfigSmtpDto({
required this.enabled,
required this.from,
required this.replyTo,
required this.transport,
});
bool enabled;
String from;
String replyTo;
SystemConfigSmtpTransportDto transport;
@override
bool operator ==(Object other) => identical(this, other) || other is SystemConfigSmtpDto &&
other.enabled == enabled &&
other.from == from &&
other.replyTo == replyTo &&
other.transport == transport;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(enabled.hashCode) +
(from.hashCode) +
(replyTo.hashCode) +
(transport.hashCode);
@override
String toString() => 'SystemConfigSmtpDto[enabled=$enabled, from=$from, replyTo=$replyTo, transport=$transport]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'enabled'] = this.enabled;
json[r'from'] = this.from;
json[r'replyTo'] = this.replyTo;
json[r'transport'] = this.transport;
return json;
}
/// Returns a new [SystemConfigSmtpDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SystemConfigSmtpDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return SystemConfigSmtpDto(
enabled: mapValueOfType<bool>(json, r'enabled')!,
from: mapValueOfType<String>(json, r'from')!,
replyTo: mapValueOfType<String>(json, r'replyTo')!,
transport: SystemConfigSmtpTransportDto.fromJson(json[r'transport'])!,
);
}
return null;
}
static List<SystemConfigSmtpDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SystemConfigSmtpDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SystemConfigSmtpDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SystemConfigSmtpDto> mapFromJson(dynamic json) {
final map = <String, SystemConfigSmtpDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SystemConfigSmtpDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SystemConfigSmtpDto-objects as value to a dart map
static Map<String, List<SystemConfigSmtpDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SystemConfigSmtpDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SystemConfigSmtpDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'enabled',
'from',
'replyTo',
'transport',
};
}

View File

@@ -0,0 +1,132 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class SystemConfigSmtpTransportDto {
/// Returns a new [SystemConfigSmtpTransportDto] instance.
SystemConfigSmtpTransportDto({
required this.host,
required this.ignoreCert,
required this.password,
required this.port,
required this.username,
});
String host;
bool ignoreCert;
String password;
/// Minimum value: 0
/// Maximum value: 65535
num port;
String username;
@override
bool operator ==(Object other) => identical(this, other) || other is SystemConfigSmtpTransportDto &&
other.host == host &&
other.ignoreCert == ignoreCert &&
other.password == password &&
other.port == port &&
other.username == username;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(host.hashCode) +
(ignoreCert.hashCode) +
(password.hashCode) +
(port.hashCode) +
(username.hashCode);
@override
String toString() => 'SystemConfigSmtpTransportDto[host=$host, ignoreCert=$ignoreCert, password=$password, port=$port, username=$username]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'host'] = this.host;
json[r'ignoreCert'] = this.ignoreCert;
json[r'password'] = this.password;
json[r'port'] = this.port;
json[r'username'] = this.username;
return json;
}
/// Returns a new [SystemConfigSmtpTransportDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SystemConfigSmtpTransportDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return SystemConfigSmtpTransportDto(
host: mapValueOfType<String>(json, r'host')!,
ignoreCert: mapValueOfType<bool>(json, r'ignoreCert')!,
password: mapValueOfType<String>(json, r'password')!,
port: num.parse('${json[r'port']}'),
username: mapValueOfType<String>(json, r'username')!,
);
}
return null;
}
static List<SystemConfigSmtpTransportDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SystemConfigSmtpTransportDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SystemConfigSmtpTransportDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SystemConfigSmtpTransportDto> mapFromJson(dynamic json) {
final map = <String, SystemConfigSmtpTransportDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SystemConfigSmtpTransportDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SystemConfigSmtpTransportDto-objects as value to a dart map
static Map<String, List<SystemConfigSmtpTransportDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SystemConfigSmtpTransportDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SystemConfigSmtpTransportDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'host',
'ignoreCert',
'password',
'port',
'username',
};
}