Skip to content

Commit

Permalink
feat: Improved email and notification text
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Jul 29, 2024
1 parent 1b2aa21 commit 52c1f36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/Listener/LoginMailListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ private function getMail(SuspiciousLoginEvent $event, IUser $user): IMessage {
$additionalText = '';
// Add explanation for more information about the IP-address (if enabled)
if ($addButton) {
$additionalText = ' ' . $this->l->t('You can get more info by pressing the button which will open %s and show info about the suspicious IP-address.', 'https://iplookup.flagfox.net');
// TODO: deduplicate with \OCA\SuspiciousLogin\Notifications\Notifier::prepare
$additionalText = ' ' . $this->l->t('More info about the suspicious IP address available on %s', 'https://iplookup.flagfox.net');
}
$emailTemplate->addBodyText(
$this->l->t('A new login into your account was detected. The IP address %s was classified as suspicious. If this was you, you can ignore this message. Otherwise you should change your password.', $suspiciousIp) . $additionalText
Expand All @@ -98,7 +99,7 @@ private function getMail(SuspiciousLoginEvent $event, IUser $user): IMessage {
if ($addButton) {
$link = 'https://iplookup.flagfox.net/?ip=' . $suspiciousIp;
$emailTemplate->addBodyButton(
htmlspecialchars($this->l->t('More information')),
htmlspecialchars($this->l->t('Open %s', ['iplookup.flagfox.net'])),
$link,
false
);
Expand Down
5 changes: 3 additions & 2 deletions lib/Notifications/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ public function prepare(INotification $notification, string $languageCode): INot
// Add button for more information about the IP-address
if ($this->config->getAppValue('suspicious_login', 'show_more_info_button', '1') === "1") {
$action = $notification->createAction();
$label = $l->t('More information');
$label = $l->t('Open %s', ['iplookup.flagfox.net']);
$link = 'https://iplookup.flagfox.net/?ip=' . $suspiciousIp;
$action->setLabel($label)
->setParsedLabel($label)
->setLink($link, IAction::TYPE_WEB)
->setPrimary(true);
$notification->addParsedAction($action);
$additionalText = ' ' . $l->t('You can get more info by pressing the button which will open %s and show info about the suspicious IP-address.', 'https://iplookup.flagfox.net');
// TODO: deduplicate with \OCA\SuspiciousLogin\Listener\LoginMailListener::getMail
$additionalText = ' ' . $l->t('More info about the suspicious IP address available on %s', 'https://iplookup.flagfox.net');
}

$notification->setParsedSubject(
Expand Down

0 comments on commit 52c1f36

Please sign in to comment.