From 3a6befa2831447fdb9e0e99ba6b100a5f8e85bbd Mon Sep 17 00:00:00 2001 From: JM Date: Tue, 5 May 2026 18:22:42 +0200 Subject: [PATCH] add channel gibt es erst ab version 2 --- extend.php | 11 +++----- locale/en.yml | 3 +++ src/Notification/TeamsDriver.php | 43 ++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 src/Notification/TeamsDriver.php diff --git a/extend.php b/extend.php index 2463e98..f3632cf 100644 --- a/extend.php +++ b/extend.php @@ -5,25 +5,22 @@ declare(strict_types=1); use Flarum\Extend; use SbpJm\FlarumMSTeamsWebhook\Console\TestTeamsUserCommand; use SbpJm\FlarumMSTeamsWebhook\Listener\MirrorAlertsToTeams; -use SbpJm\FlarumMSTeamsWebhook\Notification\TeamsChannel; +use SbpJm\FlarumMSTeamsWebhook\Notification\TeamsDriver; return [ - // Localization (new Extend\Locales(__DIR__ . '/locale')), - // Admin frontend (settings UI) (new Extend\Frontend('admin')) ->js(__DIR__ . '/js/dist/admin.js'), - // CLI test command (new Extend\Console()) ->command(TestTeamsUserCommand::class), - // Existing hook (leave it intact) + // ✅ EXISTING hook (unchanged) (new Extend\Notification()) ->beforeSending(MirrorAlertsToTeams::class), - // ✅ NEW: Microsoft Teams notification channel + // ✅ NEW: Microsoft Teams notification driver (new Extend\Notification()) - ->addChannel(TeamsChannel::class), + ->driver('teams', TeamsDriver::class), ]; \ No newline at end of file diff --git a/locale/en.yml b/locale/en.yml index 8f9202a..c9ca0d5 100644 --- a/locale/en.yml +++ b/locale/en.yml @@ -2,3 +2,6 @@ sbp-jm-msteams-webhook: admin: title: MS Teams Activity Feed description: Mirror Flarum web notifications to Microsoft Teams. +notification: + drivers: + teams: Microsoft Teams \ No newline at end of file diff --git a/src/Notification/TeamsDriver.php b/src/Notification/TeamsDriver.php new file mode 100644 index 0000000..2f15824 --- /dev/null +++ b/src/Notification/TeamsDriver.php @@ -0,0 +1,43 @@ +supports($blueprint)) { + return; + } + + $this->notifier->sendToUser($recipient, $blueprint); + } + + /** + * Limit which notification types go to Teams. + */ + protected function supports(BlueprintInterface $blueprint): bool + { + return in_array($blueprint::getType(), [ + 'newPost', + 'postMentioned', + 'userMentioned', + 'discussionRenamed', + 'postLiked', + ], true); + } +}