From f4aa28df8a1d82f4ee0a486add79e53d1c669ad6 Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 6 May 2026 14:22:33 +0200 Subject: [PATCH] lass uns raten! --- extend.php | 12 ++++- .../forum/extendNotificationGridWithTeams.js | 13 +++++ js/src/forum/index.js | 8 +-- js/src/forum/src - Verknüpfung.lnk | Bin 0 -> 1234 bytes locale/en.yml | 6 +++ src/Notification/TeamsNotificationDriver.php | 46 ++++++++++++++++++ 6 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 js/src/forum/extendNotificationGridWithTeams.js create mode 100644 js/src/forum/src - Verknüpfung.lnk create mode 100644 src/Notification/TeamsNotificationDriver.php diff --git a/extend.php b/extend.php index a55dcfe..1ee7569 100644 --- a/extend.php +++ b/extend.php @@ -24,7 +24,14 @@ return [ // ✅ EINZIGER Notification-Hook (richtig für Flarum 1.8.x) (new Extend\Notification()) ->beforeSending(MirrorAlertsToTeams::class), - + + + (new Extend\Notification()) + ->driver('teams', TeamsNotificationDriver::class, [ + // Absichtlich leer: Teams ist nicht default-on, + // kann aber im Notification-Grid pro Zeile aktiviert werden. + ]), + (new Extend\User()) @@ -33,4 +40,5 @@ return [ ->registerPreference('sbp-jm-msteams.types.postMentioned', 'boolval', false) ->registerPreference('sbp-jm-msteams.types.userMentioned', 'boolval', false), -]; \ No newline at end of file +]; + diff --git a/js/src/forum/extendNotificationGridWithTeams.js b/js/src/forum/extendNotificationGridWithTeams.js new file mode 100644 index 0000000..eb256a9 --- /dev/null +++ b/js/src/forum/extendNotificationGridWithTeams.js @@ -0,0 +1,13 @@ +import { extend } from 'flarum/common/extend'; +import NotificationGrid from 'flarum/forum/components/NotificationGrid'; +import app from 'flarum/forum/app'; + +export default function extendNotificationGridWithTeams() { + extend(NotificationGrid.prototype, 'notificationMethods', function (items) { + items.add('teams', { + name: 'teams', + icon: 'fab fa-microsoft', + label: app.translator.trans('sbp-jm-flarum-msteams-webhook.forum.notification_method.teams'), + }); + }); +} \ No newline at end of file diff --git a/js/src/forum/index.js b/js/src/forum/index.js index 2dc6dfc..2f9e9e9 100644 --- a/js/src/forum/index.js +++ b/js/src/forum/index.js @@ -1,6 +1,6 @@ import app from 'flarum/forum/app'; -import addTeamsSettings from './addTeamsSettings'; +import extendNotificationGridWithTeams from './extendNotificationGridWithTeams('sbp-jm/flarum-msteams-webhook', () => {import extendNotificationGridWithTeams from './extendNotificationGridWithTeams'; + extendNotificationGridWithTeams(); +}); + -app.initializers.add('sbp-jm-msteams-webhook-forum', () => { - addTeamsSettings(); -}); \ No newline at end of file diff --git a/js/src/forum/src - Verknüpfung.lnk b/js/src/forum/src - Verknüpfung.lnk new file mode 100644 index 0000000000000000000000000000000000000000..bc19ddbdcdea2724fdc735e28dffa5c8d230ba11 GIT binary patch literal 1234 zcmb_bUr3Wt6#q?qPz(DsTP`dm2n?A{gR-HbO?1U{;`*mv%Bfr1^mDdP(?o>CP|K(Y z9|9AJIScZ^EP@~r0v{qogCuK$4^dEr_|{|Re4A4v@TL24&OP^h=lssUdo2Jo$x+0C zS(T&oHew->oVhfoy%7v*MxN`6s#b!U+`B6;Cg~h9BfkwHyf15#kyg2CT}c07bW4vv z#Uj&Sc%(zN$teCZ723C?D_uU!TT!+8Copf4a^t9Yx+j54$drAn5rdvKx|cKFav zsDKvN!k7V(R4<{_Qe1VeyeAj96h`G({ExG&7-g6z%(g6D{Ma^BJs~S<-gZ^eql0Rw zhYMc%n#eN+=1A0cg%Ugpa6A&Pi{d%dD*RS0SsS;+V$sr73lBvAl5i%{k?(yH6kh}K z{(3no?4z!nD)?h zs`o@s_srGkfv*qF_Ya%b6K}=M=2y?Zo!jaE7b+qS7`sVuIkrmMFT(cd>z)=ydgBdi<_6>vZ(ubnsX&H!HIK0MBdxEdT%j literal 0 HcmV?d00001 diff --git a/locale/en.yml b/locale/en.yml index e6c6262..01d4589 100644 --- a/locale/en.yml +++ b/locale/en.yml @@ -15,3 +15,9 @@ sbp-jm-msteams: newPost: Someone replies to a discussion I am following postMentioned: Someone mentions me in a post userMentioned: Someone mentions me + + +sbp-jm-flarum-msteams-webhook: + forum: + notification_method: + teams: Teams diff --git a/src/Notification/TeamsNotificationDriver.php b/src/Notification/TeamsNotificationDriver.php new file mode 100644 index 0000000..6dafa8b --- /dev/null +++ b/src/Notification/TeamsNotificationDriver.php @@ -0,0 +1,46 @@ +_teams + $prefKey = User::getNotificationPreferenceKey($blueprint::getType(), 'teams'); + + // Wenn User "Teams" in dieser Zeile nicht aktiviert hat, nichts senden. + if (! $user->getPreference($prefKey)) { + continue; + } + + // TODO: Hier deine bestehende Teams-Sende-Logik aufrufen. + // Beispiel: + // $this->mirrorToTeams($blueprint, $user); + } + } + + /** + * Wird vom Core für jeden bekannten Notification-Type aufgerufen. + * Hier registrieren wir den Preference-Key, damit er im Grid angezeigt + gespeichert wird. + */ + public function registerType(string $blueprintClass, array $driversEnabledByDefault): void + { + User::registerPreference( + User::getNotificationPreferenceKey($blueprintClass::getType(), 'teams'), + 'boolval', + in_array('teams', $driversEnabledByDefault) + ); + } +} \ No newline at end of file