lass uns raten!
This commit is contained in:
parent
65a332178c
commit
f4aa28df8a
|
|
@ -26,6 +26,13 @@ return [
|
||||||
->beforeSending(MirrorAlertsToTeams::class),
|
->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())
|
(new Extend\User())
|
||||||
->registerPreference('sbp-jm-msteams.enabled', 'boolval', false)
|
->registerPreference('sbp-jm-msteams.enabled', 'boolval', false)
|
||||||
|
|
@ -34,3 +41,4 @@ return [
|
||||||
->registerPreference('sbp-jm-msteams.types.userMentioned', 'boolval', false),
|
->registerPreference('sbp-jm-msteams.types.userMentioned', 'boolval', false),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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'),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import app from 'flarum/forum/app';
|
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();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -15,3 +15,9 @@ sbp-jm-msteams:
|
||||||
newPost: Someone replies to a discussion I am following
|
newPost: Someone replies to a discussion I am following
|
||||||
postMentioned: Someone mentions me in a post
|
postMentioned: Someone mentions me in a post
|
||||||
userMentioned: Someone mentions me
|
userMentioned: Someone mentions me
|
||||||
|
|
||||||
|
|
||||||
|
sbp-jm-flarum-msteams-webhook:
|
||||||
|
forum:
|
||||||
|
notification_method:
|
||||||
|
teams: Teams
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SbpJm\FlarumMSTeamsWebhook\Notification;
|
||||||
|
|
||||||
|
use Flarum\Notification\Blueprint\BlueprintInterface;
|
||||||
|
use Flarum\Notification\Driver\NotificationDriverInterface;
|
||||||
|
use Flarum\User\User;
|
||||||
|
|
||||||
|
class TeamsNotificationDriver implements NotificationDriverInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Sendet Benachrichtigungen über "teams".
|
||||||
|
*
|
||||||
|
* Wichtig: Für reine UI+Preference-Integration kannst du hier erstmal NO-OP lassen,
|
||||||
|
* oder du hängst deine bestehende Teams-Sende-Logik an die Preference an.
|
||||||
|
*/
|
||||||
|
public function send(BlueprintInterface $blueprint, array $users): void
|
||||||
|
{
|
||||||
|
foreach ($users as $user) {
|
||||||
|
// notify_<type>_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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue