mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
feat: notification unsubscribe & email overhaul with HTML multipart (#3872)
This commit is contained in:
@@ -70,40 +70,43 @@ flarum-mentions:
|
||||
# These translations are used in emails sent when a post is replied to
|
||||
post_mentioned:
|
||||
subject: "{replier_display_name} replied to your post in {title}"
|
||||
body: |
|
||||
Hey {recipient_display_name}!
|
||||
plain:
|
||||
body: |
|
||||
{replier_display_name} replied to your post (#{post_number}) in {title}.
|
||||
|
||||
{replier_display_name} replied to your post (#{post_number}) in {title}.
|
||||
{url}
|
||||
|
||||
{url}
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{content}
|
||||
{content}
|
||||
html:
|
||||
body: "{replier_display_name} replied to your post (#{post_number}) in [{title}]({url})."
|
||||
|
||||
# These translations are used in emails sent when a user is mentioned
|
||||
user_mentioned:
|
||||
subject: "{mentioner_display_name} mentioned you in {title}"
|
||||
body: |
|
||||
Hey {recipient_display_name}!
|
||||
plain:
|
||||
body: |
|
||||
{mentioner_display_name} mentioned you in a post in {title}.
|
||||
|
||||
{mentioner_display_name} mentioned you in a post in {title}.
|
||||
{url}
|
||||
|
||||
{url}
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{content}
|
||||
{content}
|
||||
html:
|
||||
body: "{mentioner_display_name} mentioned you in a post in [{title}]({url})."
|
||||
# These translations are used in emails sent when a group is mentioned
|
||||
group_mentioned:
|
||||
subject: "{mentioner_display_name} mentioned a group you're a member of in {title}"
|
||||
body: |
|
||||
Hey {recipient_display_name}!
|
||||
plain:
|
||||
body: |
|
||||
{mentioner_display_name} mentioned a group you're a member of in {title}.
|
||||
|
||||
{mentioner_display_name} mentioned a group you're a member of in {title}.
|
||||
{url}
|
||||
|
||||
{url}
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{content}
|
||||
{content}
|
||||
html:
|
||||
body: "{mentioner_display_name} mentioned a group you're a member of in [{title}]({url})."
|
||||
|
@@ -38,9 +38,11 @@ class GroupMentionedBlueprint implements BlueprintInterface, MailableInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getEmailView(): string|array
|
||||
public function getEmailViews(): array
|
||||
{
|
||||
return ['text' => 'flarum-mentions::emails.groupMentioned'];
|
||||
return [
|
||||
'text' => 'flarum-mentions::emails.plain.groupMentioned',
|
||||
'html' => 'flarum-mentions::emails.html.groupMentioned', ];
|
||||
}
|
||||
|
||||
public function getEmailSubject(TranslatorInterface $translator): string
|
||||
|
@@ -39,9 +39,12 @@ class PostMentionedBlueprint implements BlueprintInterface, MailableInterface
|
||||
return ['replyNumber' => (int) $this->reply->number];
|
||||
}
|
||||
|
||||
public function getEmailView(): string|array
|
||||
public function getEmailViews(): array
|
||||
{
|
||||
return ['text' => 'flarum-mentions::emails.postMentioned'];
|
||||
return [
|
||||
'text' => 'flarum-mentions::emails.plain.postMentioned',
|
||||
'html' => 'flarum-mentions::emails.html.postMentioned',
|
||||
];
|
||||
}
|
||||
|
||||
public function getEmailSubject(TranslatorInterface $translator): string
|
||||
|
@@ -38,9 +38,12 @@ class UserMentionedBlueprint implements BlueprintInterface, MailableInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getEmailView(): string|array
|
||||
public function getEmailViews(): array
|
||||
{
|
||||
return ['text' => 'flarum-mentions::emails.userMentioned'];
|
||||
return [
|
||||
'text' => 'flarum-mentions::emails.plain.userMentioned',
|
||||
'html' => 'flarum-mentions::emails.html.userMentioned'
|
||||
];
|
||||
}
|
||||
|
||||
public function getEmailSubject(TranslatorInterface $translator): string
|
||||
|
@@ -0,0 +1,13 @@
|
||||
@extends('flarum.forum::email.html.notification.base')
|
||||
|
||||
@section('notificationContent')
|
||||
{!! $formatter->convert($translator->trans('flarum-mentions.email.group_mentioned.html.body', [
|
||||
'{mentioner_display_name}' => $blueprint->post->user->display_name,
|
||||
'{title}' => $blueprint->post->discussion->title,
|
||||
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
|
||||
])) !!}
|
||||
@endsection
|
||||
|
||||
@section('contentPreview')
|
||||
{!! $blueprint->post->formatContent() !!}
|
||||
@endsection
|
@@ -0,0 +1,14 @@
|
||||
@extends('flarum.forum::email.html.notification.base')
|
||||
|
||||
@section('notificationContent')
|
||||
{!! $formatter->convert($translator->trans('flarum-mentions.email.post_mentioned.html.body', [
|
||||
'{replier_display_name}' => $blueprint->reply->user->display_name,
|
||||
'{post_number}' => $blueprint->post->number,
|
||||
'{title}' => $blueprint->post->discussion->title,
|
||||
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->reply->discussion_id, 'near' => $blueprint->reply->number])
|
||||
])) !!}
|
||||
@endsection
|
||||
|
||||
@section('contentPreview')
|
||||
{!! $blueprint->reply->formatContent() !!}
|
||||
@endsection
|
@@ -0,0 +1,13 @@
|
||||
@extends('flarum.forum::email.html.notification.base')
|
||||
|
||||
@section('notificationContent')
|
||||
{!! $formatter->convert($translator->trans('flarum-mentions.email.user_mentioned.html.body', [
|
||||
'{mentioner_display_name}' => $blueprint->post->user->display_name,
|
||||
'{title}' => $blueprint->post->discussion->title,
|
||||
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
|
||||
])) !!}
|
||||
@endsection
|
||||
|
||||
@section('contentPreview')
|
||||
{!! $blueprint->post->formatContent() !!}
|
||||
@endsection
|
@@ -1,7 +1,10 @@
|
||||
{!! $translator->trans('flarum-mentions.email.group_mentioned.body', [
|
||||
'{recipient_display_name}' => $user->display_name,
|
||||
@extends('flarum.forum::email.plain.notification.base')
|
||||
|
||||
@section('content')
|
||||
{!! $translator->trans('flarum-mentions.email.group_mentioned.plain.body', [
|
||||
'{mentioner_display_name}' => $blueprint->post->user->display_name,
|
||||
'{title}' => $blueprint->post->discussion->title,
|
||||
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
|
||||
'{content}' => $blueprint->post->content
|
||||
]) !!}
|
||||
@endsection
|
@@ -1,8 +1,11 @@
|
||||
{!! $translator->trans('flarum-mentions.email.post_mentioned.body', [
|
||||
'{recipient_display_name}' => $user->display_name,
|
||||
@extends('flarum.forum::email.plain.notification.base')
|
||||
|
||||
@section('content')
|
||||
{!! $translator->trans('flarum-mentions.email.post_mentioned.plain.body', [
|
||||
'{replier_display_name}' => $blueprint->reply->user->display_name,
|
||||
'{post_number}' => $blueprint->post->number,
|
||||
'{title}' => $blueprint->post->discussion->title,
|
||||
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->reply->discussion_id, 'near' => $blueprint->reply->number]),
|
||||
'{content}' => $blueprint->reply->content
|
||||
]) !!}
|
||||
@endsection
|
@@ -1,7 +1,10 @@
|
||||
{!! $translator->trans('flarum-mentions.email.user_mentioned.body', [
|
||||
'{recipient_display_name}' => $user->display_name,
|
||||
@extends('flarum.forum::email.plain.notification.base')
|
||||
|
||||
@section('content')
|
||||
{!! $translator->trans('flarum-mentions.email.user_mentioned.plain.body', [
|
||||
'{mentioner_display_name}' => $blueprint->post->user->display_name,
|
||||
'{title}' => $blueprint->post->discussion->title,
|
||||
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
|
||||
'{content}' => $blueprint->post->content
|
||||
]) !!}
|
||||
@endsection
|
@@ -51,21 +51,25 @@ flarum-subscriptions:
|
||||
# These translations are used in emails sent when a post is made in a subscribed discussion
|
||||
new_post:
|
||||
subject: "[New Post] {title}"
|
||||
body: |
|
||||
Hey {recipient_display_name}!
|
||||
plain:
|
||||
body: |
|
||||
{poster_display_name} just posted in a discussion you're following: {title}.
|
||||
|
||||
{poster_display_name} made a post in a discussion you're following: {title}.
|
||||
To view the new activity, check out the following link:
|
||||
{url}
|
||||
|
||||
To view the new activity, check out the following link:
|
||||
{url}
|
||||
---
|
||||
|
||||
---
|
||||
{content}
|
||||
|
||||
{content}
|
||||
---
|
||||
|
||||
---
|
||||
You won't receive any more notifications about this discussion until you're up-to-date.
|
||||
html:
|
||||
body: |
|
||||
{poster_display_name} just posted in a discussion you're following: [{title}]({url}).
|
||||
|
||||
You won't receive any more notifications about this discussion until you're up-to-date.
|
||||
You won't recieve any more notifications about this discussion until you're up-to-date.
|
||||
|
||||
##
|
||||
# REUSED TRANSLATIONS - These keys should not be used directly in code!
|
||||
|
@@ -39,9 +39,11 @@ class NewPostBlueprint implements BlueprintInterface, MailableInterface
|
||||
return ['postNumber' => (int) $this->post->number];
|
||||
}
|
||||
|
||||
public function getEmailView(): string|array
|
||||
public function getEmailViews(): array
|
||||
{
|
||||
return ['text' => 'flarum-subscriptions::emails.newPost'];
|
||||
return [
|
||||
'text' => 'flarum-subscriptions::emails.plain.newPost',
|
||||
'html' => 'flarum-subscriptions::emails.html.newPost', ];
|
||||
}
|
||||
|
||||
public function getEmailSubject(TranslatorInterface $translator): string
|
||||
|
13
extensions/subscriptions/views/emails/html/newPost.blade.php
Normal file
13
extensions/subscriptions/views/emails/html/newPost.blade.php
Normal file
@@ -0,0 +1,13 @@
|
||||
@extends('flarum.forum::email.html.notification.base')
|
||||
|
||||
@section('notificationContent')
|
||||
{!! $formatter->convert($translator->trans('flarum-subscriptions.email.new_post.html.body', [
|
||||
'{poster_display_name}' => $blueprint->post->user->display_name,
|
||||
'{title}' => $blueprint->post->discussion->title,
|
||||
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
|
||||
])) !!}
|
||||
@endsection
|
||||
|
||||
@section('contentPreview')
|
||||
{!! $blueprint->post->formatContent() !!}
|
||||
@endsection
|
@@ -1,7 +1,10 @@
|
||||
{!! $translator->trans('flarum-subscriptions.email.new_post.body', [
|
||||
'{recipient_display_name}' => $user->display_name,
|
||||
@extends('flarum.forum::email.plain.notification.base')
|
||||
|
||||
@section('content')
|
||||
{!! $translator->trans('flarum-subscriptions.email.new_post.plain.body', [
|
||||
'{poster_display_name}' => $blueprint->post->user->display_name,
|
||||
'{title}' => $blueprint->post->discussion->title,
|
||||
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
|
||||
'{content}' => $blueprint->post->content
|
||||
]) !!}
|
||||
@endsection
|
@@ -52,20 +52,22 @@ flarum-suspend:
|
||||
no_reason_given: No reason was given for this suspension.
|
||||
suspended:
|
||||
subject: Your account has been suspended
|
||||
body: |
|
||||
Hey {recipient_display_name},
|
||||
plain:
|
||||
body: |
|
||||
You have been suspended for the following reason:
|
||||
|
||||
You have been suspended for the following reason:
|
||||
|
||||
---
|
||||
{suspension_message}
|
||||
---
|
||||
---
|
||||
{suspension_message}
|
||||
---
|
||||
html:
|
||||
body: "You have been suspended from {forumTitle} for the following reason:"
|
||||
|
||||
unsuspended:
|
||||
subject: Your account has been unsuspended
|
||||
body: |
|
||||
Hey {recipient_display_name},
|
||||
plain:
|
||||
body: |
|
||||
You have been unsuspended. You can head back to the forum by clicking on the following link:
|
||||
|
||||
You have been unsuspended. You can head back to the forum by clicking on the following link:
|
||||
|
||||
{forum_url}
|
||||
{forum_url}
|
||||
html:
|
||||
body: "You have been unsuspended. You can head back to [{forumTitle}]({forum_url}) when you are ready."
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace Flarum\Suspend\Notification;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonInterface;
|
||||
use Flarum\Database\AbstractModel;
|
||||
use Flarum\Locale\TranslatorInterface;
|
||||
@@ -35,7 +36,7 @@ class UserSuspendedBlueprint implements BlueprintInterface, MailableInterface
|
||||
|
||||
public function getData(): CarbonInterface
|
||||
{
|
||||
return $this->user->suspended_until;
|
||||
return Carbon::now();
|
||||
}
|
||||
|
||||
public static function getType(): string
|
||||
@@ -48,9 +49,11 @@ class UserSuspendedBlueprint implements BlueprintInterface, MailableInterface
|
||||
return User::class;
|
||||
}
|
||||
|
||||
public function getEmailView(): string|array
|
||||
public function getEmailViews(): array
|
||||
{
|
||||
return ['text' => 'flarum-suspend::emails.suspended'];
|
||||
return [
|
||||
'text' => 'flarum-suspend::emails.plain.suspended',
|
||||
'html' => 'flarum-suspend::emails.html.suspended', ];
|
||||
}
|
||||
|
||||
public function getEmailSubject(TranslatorInterface $translator): string
|
||||
|
@@ -49,9 +49,11 @@ class UserUnsuspendedBlueprint implements BlueprintInterface, MailableInterface
|
||||
return User::class;
|
||||
}
|
||||
|
||||
public function getEmailView(): string|array
|
||||
public function getEmailViews(): array
|
||||
{
|
||||
return ['text' => 'flarum-suspend::emails.unsuspended'];
|
||||
return [
|
||||
'text' => 'flarum-suspend::emails.plain.unsuspended',
|
||||
'html' => 'flarum-suspend::emails.html.unsuspended', ];
|
||||
}
|
||||
|
||||
public function getEmailSubject(TranslatorInterface $translator): string
|
||||
|
@@ -50,7 +50,7 @@ class SuspendUserTest extends TestCase
|
||||
{
|
||||
$response = $this->sendSuspensionRequest($authenticatedAs, $targetUserId);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals(200, $response->getStatusCode(), $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
|
11
extensions/suspend/views/emails/html/suspended.blade.php
Normal file
11
extensions/suspend/views/emails/html/suspended.blade.php
Normal file
@@ -0,0 +1,11 @@
|
||||
@extends('flarum.forum::email.html.information.base')
|
||||
|
||||
@section('informationContent')
|
||||
{!! $formatter->convert($translator->trans('flarum-suspend.email.suspended.html.body', [
|
||||
'{forumTitle}' => $settings->get('forum_title')
|
||||
])) !!}
|
||||
@endsection
|
||||
|
||||
@section('contentPreview')
|
||||
{!! $formatter->convert($blueprint->user->suspend_message ?? $translator->trans('flarum-suspend.email.no_reason_given')) !!}
|
||||
@endsection
|
@@ -0,0 +1,8 @@
|
||||
@extends('flarum.forum::email.html.information.base')
|
||||
|
||||
@section('content')
|
||||
{!! $formatter->convert($translator->trans('flarum-suspend.email.unsuspended.html.body', [
|
||||
'{forumTitle}' => $settings->get('forum_title'),
|
||||
'{forum_url}' => $url->to('forum')->base(),
|
||||
])) !!}
|
||||
@endsection
|
@@ -0,0 +1,7 @@
|
||||
@extends('flarum.forum::email.plain.information.base')
|
||||
|
||||
@section('content')
|
||||
{!! $translator->trans('flarum-suspend.email.suspended.plain.body', [
|
||||
'{suspension_message}' => $blueprint->user->suspend_message ?? $translator->trans('flarum-suspend.email.no_reason_given'),
|
||||
]) !!}
|
||||
@endsection
|
@@ -0,0 +1,7 @@
|
||||
@extends('flarum.forum::email.plain.information.base')
|
||||
|
||||
@section('content')
|
||||
{!! $translator->trans('flarum-suspend.email.unsuspended.plain.body', [
|
||||
'{forum_url}' => $url->to('forum')->base(),
|
||||
]) !!}
|
||||
@endsection
|
@@ -1,4 +0,0 @@
|
||||
{!! $translator->trans('flarum-suspend.email.suspended.body', [
|
||||
'{recipient_display_name}' => $user->display_name,
|
||||
'{suspension_message}' => $blueprint->user->suspend_message ?? $translator->trans('flarum-suspend.email.no_reason_given'),
|
||||
]) !!}
|
@@ -1,4 +0,0 @@
|
||||
{!! $translator->trans('flarum-suspend.email.unsuspended.body', [
|
||||
'{recipient_display_name}' => $user->display_name,
|
||||
'{forum_url}' => $url->to('forum')->base(),
|
||||
]) !!}
|
Reference in New Issue
Block a user