filagora / filagora-notifications
Notification preferences for Filagora: per-person, per-category, per-channel choices, a category registry, suppression, signed unsubscribe, and bridges to push and forums.
Package info
github.com/filagora/filagora-notifications
pkg:composer/filagora/filagora-notifications
Requires
- php: ^8.4
- filagora/filagora-core: ^0.2.2
- filament/filament: ^5.0
Requires (Dev)
- filagora/filagora-entitlements: ^0.2.2
- filagora/filagora-forums: ^0.6
- filagora/filagora-messages: ^0.2
- filagora/filagora-push: ^0.1
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
Suggests
- filagora/filagora-entitlements: Declares the staff ability to see a person's stored choices, so it can be granted in the entitlements screens.
- filagora/filagora-forums: Bridges thread subscription delivery to the person's choices.
- filagora/filagora-messages: Bridges who may be messaged to the person's choice.
- filagora/filagora-push: Bridges push alerts to the person's choices.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-22 19:55:44 UTC
README
Notification preferences for Filagora: what each person wants to hear about, on which channel
(email, push, in-app), a registry of the categories packages and hosts add to, email suppression,
signed and one-click unsubscribe links, and bridges that answer the questions the push and forums
packages ask. Requires filagora/filagora-core.
The package is at
0.1: the API may change between0.xminor versions. There is no settings screen:Preferences::matrix()andset()give your page what it needs.
What it does
-
Stores choices. One row per person, category and channel in
user_notification_preferences(NotificationPreference). No row means the category's default. The table has the shape of the site the package was extracted from, so an existing site can adopt it withfilagora:adopt. -
Registers categories.
NotificationCategories::register(new Category(...))adds a kind of notification: its id (stored for good, so never rename one), a label, the channels it can reach, per-channel defaults, whether a mailed link may switch it off, or a set of modes (such asinstant,daily,weekly). The first registration of an id wins, so a host's own beats a package's. The mentions, private messages, thread updates, digest, moderation and private-message-contactability categories are registered for you (register_standard). -
Answers and records choices.
Preferences::allows($user, 'forum.mention', NotificationChannel::PUSH),mode(),set(),setMode(), andmatrix($user)for a settings page. A category is on unless it says otherwise (or itsdefaultResolveranswers per person). A person's rows are read once per instance and forgotten at every queue job.PreferenceChangedfires when a stored value changes. -
Suppresses mail.
Preferences::canDeliver($user, 'forum.mention')is the one question to ask before optional mail, a push or a bell entry: the person's choice, and for email no suppression.EmailSuppressiondecides suppression; the default stops a person whosereceives_emailis false or whoseemail_statusisbouncedorcomplained(names in config, and a model without those attributes is never suppressed). Bind your own to add rules. Required mail (verification, password reset, security notices) does not ask. -
Unsubscribes by signed link.
Unsubscribe::url()andoneClickUrl()build the links,decorate($mailMessage, $user, $category)adds theList-Unsubscribeheaders, and only a category registered withunsubscribable: truecan be switched off this way, on email only. Turn onroutes.enabledto serve the page and the one-click POST; they live outside the web group (no session or CSRF token; the signature decides) and keep the pathemail-preferences/unsubscribe/{user}/{category}, so links a site has already mailed keep working. Replace the page withunsubscribe.view. -
Bridges the siblings. With
filagora-push,filagora-forumsandfilagora-messagesinstalled, their preference questions are answered from the person's choices: which push alerts (push channel), how and whether followed-thread updates arrive (the frequency and the matching kind of mail; nothing for a suppressed person), and whether a person can be sent private messages. A bridge applies only while the sibling's own default is still bound, so your own binding wins, andbridges.push|forums|messagesswitch each off. Whether posting follows a thread stays a user attribute, which forums reads itself. -
Shows staff what a person chose. Add the
HasNotificationPreferencestrait to your user model andUserNotificationPreferencesRelationManager::classto your user resource's relations. It lists the stored choices, read-only (a category with no row is on its default), for people holdingfilagora.notifications.view; remap that key in thegatesconfig. -
Exports and erases. The privacy contributor adds a person's stored choices to their data export and removes them on erasure.
Install
composer require filagora/filagora-notifications php artisan vendor:publish --tag=filagora-notifications-config
Register the plugin on a Filament panel (it registers nothing of its own yet; the relation manager above is added to your own user resource):
->plugin(\Filagora\Notifications\NotificationsPlugin::make())
Configuration
config/filagora-notifications.php is merged with the host's copy, so list only what differs.
Environment variables are prefixed FILAGORA_.
Extending
Extend through documented contracts, events and registries. Anything not documented is
@internal.
Testing
composer test
License
MIT.