diff --git a/extend.php b/extend.php index 1ee5d76..2463e98 100644 --- a/extend.php +++ b/extend.php @@ -5,16 +5,25 @@ declare(strict_types=1); use Flarum\Extend; use SbpJm\FlarumMSTeamsWebhook\Console\TestTeamsUserCommand; use SbpJm\FlarumMSTeamsWebhook\Listener\MirrorAlertsToTeams; +use SbpJm\FlarumMSTeamsWebhook\Notification\TeamsChannel; 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) (new Extend\Notification()) ->beforeSending(MirrorAlertsToTeams::class), -]; + + // ✅ NEW: Microsoft Teams notification channel + (new Extend\Notification()) + ->addChannel(TeamsChannel::class), +]; \ No newline at end of file diff --git a/src/Notification/TeamsChannel.php b/src/Notification/TeamsChannel.php new file mode 100644 index 0000000..800f4e1 --- /dev/null +++ b/src/Notification/TeamsChannel.php @@ -0,0 +1,68 @@ +supports($blueprint)) { + return; + } + + $this->notifier->sendToUser($recipient, $blueprint); + } + + /** + * Decide which notification types are allowed for Teams. + */ + public function supports(BlueprintInterface $blueprint): bool + { + return in_array($blueprint::getType(), [ + 'newPost', + 'postMentioned', + 'userMentioned', + 'discussionRenamed', + 'postLiked', + ], true); + } + + /** + * Channel identifier used internally by Flarum. + */ + public function getName(): string + { + return 'teams'; + } + + /** + * Label shown in the user notification settings UI. + */ + public function getLabel(): string + { + return 'Microsoft Teams'; + } + + /** + * Teams is opt‑in by default. + */ + public function isEnabledByDefault(): bool + { + return false; + } +}