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

feat: Notification Email Templates (#13940)

This commit is contained in:
Tim Van Onckelen
2024-12-04 21:26:02 +01:00
committed by GitHub
parent 4bf1b84cc2
commit 292182fa7f
32 changed files with 1136 additions and 105 deletions

View File

@ -250,7 +250,9 @@ 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_emails_dto.dart';
part 'model/system_config_template_storage_option_dto.dart';
part 'model/system_config_templates_dto.dart';
part 'model/system_config_theme_dto.dart';
part 'model/system_config_trash_dto.dart';
part 'model/system_config_user_dto.dart';
@ -262,6 +264,8 @@ part 'model/tag_update_dto.dart';
part 'model/tag_upsert_dto.dart';
part 'model/tags_response.dart';
part 'model/tags_update.dart';
part 'model/template_dto.dart';
part 'model/template_response_dto.dart';
part 'model/test_email_response_dto.dart';
part 'model/time_bucket_response_dto.dart';
part 'model/time_bucket_size.dart';

View File

@ -16,6 +16,58 @@ class NotificationsApi {
final ApiClient apiClient;
/// Performs an HTTP 'POST /notifications/templates/{name}' operation and returns the [Response].
/// Parameters:
///
/// * [String] name (required):
///
/// * [TemplateDto] templateDto (required):
Future<Response> getNotificationTemplateWithHttpInfo(String name, TemplateDto templateDto,) async {
// ignore: prefer_const_declarations
final path = r'/notifications/templates/{name}'
.replaceAll('{name}', name);
// ignore: prefer_final_locals
Object? postBody = templateDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>['application/json'];
return apiClient.invokeAPI(
path,
'POST',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] name (required):
///
/// * [TemplateDto] templateDto (required):
Future<TemplateResponseDto?> getNotificationTemplate(String name, TemplateDto templateDto,) async {
final response = await getNotificationTemplateWithHttpInfo(name, templateDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'TemplateResponseDto',) as TemplateResponseDto;
}
return null;
}
/// Performs an HTTP 'POST /notifications/test-email' operation and returns the [Response].
/// Parameters:
///

View File

@ -554,8 +554,12 @@ class ApiClient {
return SystemConfigSmtpTransportDto.fromJson(value);
case 'SystemConfigStorageTemplateDto':
return SystemConfigStorageTemplateDto.fromJson(value);
case 'SystemConfigTemplateEmailsDto':
return SystemConfigTemplateEmailsDto.fromJson(value);
case 'SystemConfigTemplateStorageOptionDto':
return SystemConfigTemplateStorageOptionDto.fromJson(value);
case 'SystemConfigTemplatesDto':
return SystemConfigTemplatesDto.fromJson(value);
case 'SystemConfigThemeDto':
return SystemConfigThemeDto.fromJson(value);
case 'SystemConfigTrashDto':
@ -578,6 +582,10 @@ class ApiClient {
return TagsResponse.fromJson(value);
case 'TagsUpdate':
return TagsUpdate.fromJson(value);
case 'TemplateDto':
return TemplateDto.fromJson(value);
case 'TemplateResponseDto':
return TemplateResponseDto.fromJson(value);
case 'TestEmailResponseDto':
return TestEmailResponseDto.fromJson(value);
case 'TimeBucketResponseDto':

View File

@ -29,6 +29,7 @@ class SystemConfigDto {
required this.reverseGeocoding,
required this.server,
required this.storageTemplate,
required this.templates,
required this.theme,
required this.trash,
required this.user,
@ -66,6 +67,8 @@ class SystemConfigDto {
SystemConfigStorageTemplateDto storageTemplate;
SystemConfigTemplatesDto templates;
SystemConfigThemeDto theme;
SystemConfigTrashDto trash;
@ -90,6 +93,7 @@ class SystemConfigDto {
other.reverseGeocoding == reverseGeocoding &&
other.server == server &&
other.storageTemplate == storageTemplate &&
other.templates == templates &&
other.theme == theme &&
other.trash == trash &&
other.user == user;
@ -113,12 +117,13 @@ class SystemConfigDto {
(reverseGeocoding.hashCode) +
(server.hashCode) +
(storageTemplate.hashCode) +
(templates.hashCode) +
(theme.hashCode) +
(trash.hashCode) +
(user.hashCode);
@override
String toString() => 'SystemConfigDto[backup=$backup, ffmpeg=$ffmpeg, image=$image, job=$job, library_=$library_, logging=$logging, machineLearning=$machineLearning, map=$map, metadata=$metadata, newVersionCheck=$newVersionCheck, notifications=$notifications, oauth=$oauth, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, server=$server, storageTemplate=$storageTemplate, theme=$theme, trash=$trash, user=$user]';
String toString() => 'SystemConfigDto[backup=$backup, ffmpeg=$ffmpeg, image=$image, job=$job, library_=$library_, logging=$logging, machineLearning=$machineLearning, map=$map, metadata=$metadata, newVersionCheck=$newVersionCheck, notifications=$notifications, oauth=$oauth, passwordLogin=$passwordLogin, reverseGeocoding=$reverseGeocoding, server=$server, storageTemplate=$storageTemplate, templates=$templates, theme=$theme, trash=$trash, user=$user]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -138,6 +143,7 @@ class SystemConfigDto {
json[r'reverseGeocoding'] = this.reverseGeocoding;
json[r'server'] = this.server;
json[r'storageTemplate'] = this.storageTemplate;
json[r'templates'] = this.templates;
json[r'theme'] = this.theme;
json[r'trash'] = this.trash;
json[r'user'] = this.user;
@ -169,6 +175,7 @@ class SystemConfigDto {
reverseGeocoding: SystemConfigReverseGeocodingDto.fromJson(json[r'reverseGeocoding'])!,
server: SystemConfigServerDto.fromJson(json[r'server'])!,
storageTemplate: SystemConfigStorageTemplateDto.fromJson(json[r'storageTemplate'])!,
templates: SystemConfigTemplatesDto.fromJson(json[r'templates'])!,
theme: SystemConfigThemeDto.fromJson(json[r'theme'])!,
trash: SystemConfigTrashDto.fromJson(json[r'trash'])!,
user: SystemConfigUserDto.fromJson(json[r'user'])!,
@ -235,6 +242,7 @@ class SystemConfigDto {
'reverseGeocoding',
'server',
'storageTemplate',
'templates',
'theme',
'trash',
'user',

View File

@ -0,0 +1,115 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// 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 SystemConfigTemplateEmailsDto {
/// Returns a new [SystemConfigTemplateEmailsDto] instance.
SystemConfigTemplateEmailsDto({
required this.albumInviteTemplate,
required this.albumUpdateTemplate,
required this.welcomeTemplate,
});
String albumInviteTemplate;
String albumUpdateTemplate;
String welcomeTemplate;
@override
bool operator ==(Object other) => identical(this, other) || other is SystemConfigTemplateEmailsDto &&
other.albumInviteTemplate == albumInviteTemplate &&
other.albumUpdateTemplate == albumUpdateTemplate &&
other.welcomeTemplate == welcomeTemplate;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(albumInviteTemplate.hashCode) +
(albumUpdateTemplate.hashCode) +
(welcomeTemplate.hashCode);
@override
String toString() => 'SystemConfigTemplateEmailsDto[albumInviteTemplate=$albumInviteTemplate, albumUpdateTemplate=$albumUpdateTemplate, welcomeTemplate=$welcomeTemplate]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'albumInviteTemplate'] = this.albumInviteTemplate;
json[r'albumUpdateTemplate'] = this.albumUpdateTemplate;
json[r'welcomeTemplate'] = this.welcomeTemplate;
return json;
}
/// Returns a new [SystemConfigTemplateEmailsDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SystemConfigTemplateEmailsDto? fromJson(dynamic value) {
upgradeDto(value, "SystemConfigTemplateEmailsDto");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SystemConfigTemplateEmailsDto(
albumInviteTemplate: mapValueOfType<String>(json, r'albumInviteTemplate')!,
albumUpdateTemplate: mapValueOfType<String>(json, r'albumUpdateTemplate')!,
welcomeTemplate: mapValueOfType<String>(json, r'welcomeTemplate')!,
);
}
return null;
}
static List<SystemConfigTemplateEmailsDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SystemConfigTemplateEmailsDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SystemConfigTemplateEmailsDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SystemConfigTemplateEmailsDto> mapFromJson(dynamic json) {
final map = <String, SystemConfigTemplateEmailsDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SystemConfigTemplateEmailsDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SystemConfigTemplateEmailsDto-objects as value to a dart map
static Map<String, List<SystemConfigTemplateEmailsDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SystemConfigTemplateEmailsDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SystemConfigTemplateEmailsDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'albumInviteTemplate',
'albumUpdateTemplate',
'welcomeTemplate',
};
}

View File

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

View File

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

View File

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