Extract System emails from enotify

- Removed every SYSTEM_EMAIL occurrence in enotify
- Introduced a "SystemMailBuilder" for build system emails
- Replaced every SYSTEM_EMAIL usage in the classes with calling this builder
- Added tests for this new Builder
- Split the email templates between "base" template for email and concrete usages for different use cases
This commit is contained in:
nupplaPhil 2020-02-01 20:08:54 +01:00
parent 74490d6594
commit 3291728059
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
18 changed files with 647 additions and 118 deletions

View file

@ -252,7 +252,7 @@ class Update
}
$sent[] = $admin['email'];
$lang = (($admin['language'])?$admin['language']:'en');
$lang = (($admin['language']) ? $admin['language'] : 'en');
$l10n = DI::l10n()->withLang($lang);
$preamble = Strings::deindent($l10n->t("
@ -261,17 +261,15 @@ class Update
This needs to be fixed soon and I can't do it alone. Please contact a
friendica developer if you can not help me on your own. My database might be invalid.",
$update_id));
$body = $l10n->t("The error message is\n[pre]%s[/pre]", $error_message);
$body = $l10n->t("The error message is\n[pre]%s[/pre]", $error_message);
notification([
'uid' => $admin['uid'],
'type' => SYSTEM_EMAIL,
'to_email' => $admin['email'],
'subject' => $l10n->t('[Friendica Notify] Database update'),
'preamble' => $preamble,
'body' => $body,
'language' => $lang]
);
$email = DI::emailer()
->newSystemMail($l10n)
->withMessage($l10n->t('[Friendica Notify] Database update'), $preamble, $body)
->forUser($admin['uid'] ?? 0)
->withRecipient($admin['email'])
->build();
DI::emailer()->send($email);
}
//try the logger
@ -301,15 +299,13 @@ class Update
The friendica database was successfully updated from %s to %s.",
$from_build, $to_build));
notification([
'uid' => $admin['uid'],
'type' => SYSTEM_EMAIL,
'to_email' => $admin['email'],
'subject' => DI::l10n()->t('[Friendica Notify] Database update'),
'preamble' => $preamble,
'body' => $preamble,
'language' => $lang]
);
$email = DI::emailer()
->newSystemMail($l10n)
->withMessage($l10n->t('[Friendica Notify] Database update'), $preamble)
->forUser($admin['uid'] ?? 0)
->withRecipient($admin['email'])
->build();
DI::emailer()->send($email);
}
}