Benachrichtigungen
Die client.notifications-API verwaltet das Abrufen, Schließen und Konfigurieren von Benachrichtigungen.
Benachrichtigungen abrufen
Liste
final page = await client.notifications.fetch(limit: 20);
for (final n in page.items) {
print('${n.type}: ${n.account?.displayName}');
}
Nach Typ filtern
// Only mentions and favourites
final page = await client.notifications.fetch(
types: ['mention', 'favourite'],
);
// Everything except follows
final page = await client.notifications.fetch(
excludeTypes: ['follow'],
);
Einzelne Benachrichtigung
final notification = await client.notifications.fetchById('12345');
Anzahl ungelesener Benachrichtigungen (Mastodon 4.3+)
final count = await client.notifications.fetchUnreadCount();
print(count.count);
Benachrichtigungen schließen
Einzelne schließen
await client.notifications.dismiss('12345');
Alle verwerfen
await client.notifications.clear();
Benachrichtigungsrichtlinie (Mastodon 4.3+)
Aktuelle Richtlinie abrufen
final policy = await client.notifications.fetchPolicy();
print(policy.forNotFollowing); // accept, filter, drop
Richtlinie aktualisieren
await client.notifications.updatePolicy(policy);
Benachrichtigungsanfragen (Mastodon 4.3+)
Gefilterte Benachrichtigungen von Accounts, die der Richtlinie entsprechen, werden als Anfragen gesammelt.
Anfragen auflisten
final page = await client.notifications.fetchRequests(limit: 20);
Annehmen / Ablehnen
// Single
await client.notifications.acceptRequest('12345');
await client.notifications.dismissRequest('12345');
// Batch
await client.notifications.acceptRequests(['1', '2', '3']);
await client.notifications.dismissRequests(['4', '5']);
Zusammenführungsstatus prüfen
final merged = await client.notifications.checkRequestsMerged();
if (merged) {
// Accepted requests have been merged into the notification list
}
Gruppierte Benachrichtigungen (v2)
Für die gruppierte Benachrichtigungs-API client.groupedNotifications verwenden:
final result = await client.groupedNotifications.fetch(limit: 20);
for (final group in result.notificationGroups) {
print('${group.type}: ${group.notificationsCount} notifications');
}