filagora / filagora-messages
Private conversations between members, with folders, read state and trash, for Filagora.
Requires
- php: ^8.4
- filagora/filagora-core: ^0.2.1
- filament/filament: ^5.0
Requires (Dev)
- filagora/filagora-forums: ^0.6
- 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-forums: Lets private messages carry attachments: adds the link columns to its attachments table, and the rule that only the conversation's participants may see them.
Provides
None
Conflicts
None
Replaces
None
README
Private conversations between members for Filagora: send, reply, per-person folders, read and unread, trash, and a purge of what has sat in the trash too long.
The package is at
0.1: the API may change between0.xminor versions. There is no frontend: it is models and services, and you build the mailbox pages.
What it provides
Overview
Private conversations between members, with folders, read state and trash, for Filagora.
Tables
private_message_folders, private_conversations, private_conversation_participants,
private_messages and ignored_users (prefixed filagora_ by default). A conversation has one participant row per
person, holding that person's folder, read state and trash state, so deleting or trashing is
per person. A site that already has these tables can adopt them with php artisan filagora:adopt.
Models can be swapped in config/filagora-messages.php.
Commands
| Command | What it does |
|---|---|
filagora:messages:link-attachments |
Add the private message links to the forums attachments table. |
filagora:messages:purge-trashed {--days=} {--dry-run} |
Permanently remove private conversations that sat in Trash past the retention window, and conversations no participant keeps. |
Events
ConversationsPurging: Conversations that every participant has removed, fired just before they and their messages are deleted, so a host can remove what it attached to them (uploaded files, search entries).MessageReceived: A new message, and the people it is for (everyone in the conversation but the sender, and only those who have not removed it).UserIgnored: A person put another on their ignore list.UserUnignored: A person took another off their ignore list.
Access
This package defines no abilities.
Using it
$messages = app(\Filagora\Messages\Services\Messages::class); $conversation = $messages->send($sender, [$recipient], 'Subject', 'Body in markdown'); $messages->reply($recipient, $conversation, 'Thanks'); $messages->open($recipient, $conversation); // marks their copy read $mailbox = app(\Filagora\Messages\Services\Mailbox::class); $mailbox->trash($recipient, [$conversation->id]); $mailbox->restore($recipient, [$conversation->id]);
- Who may message whom is the
MessagingPolicycontract; bind your own (a member who switched messages off, a suspended account) and the ignore lists below. Anything refused throwsMessageRefusedwith areason, andblockednames the recipients who may not be messaged. - Ignore lists.
IgnoredUsers::ignore($me, $them)andunignore();isIgnoring()andisIgnoredBy()answer for one direction. Either person ignoring the other blocks private messages between them both ways (isBlockedBetween()), checked on every send and reply, andblockedIdsFor($me)gives your recipient search the people to leave out.UserIgnoredandUserUnignoredfire when a list changes. Messages already in your mailbox stay readable. - Mail. A new message is emailed to its recipients. Set
filagora-messages.mail.enabledto false to notify through your own channels from theMessageReceivedevent. - Trash.
filagora:messages:purge-trashed(schedule it daily) removes copies trashed more thantrash.retention_daysago, then conversations nobody keeps. Core's retention run does the same.ConversationsPurgingfires first so you can remove attachments. - Attachments (with
filagora/filagora-forumsinstalled). Messages can carry files stored by forums'Attachmentsservice. The migration adds two columns to forums' attachments table, linking a file to a message and its conversation (php artisan filagora:messages:link-attachmentsadds them if forums was installed after messages). Upload a file while writing (Attachments::storeInline()), put its URL in the message body, and sending or replying claims the sender's own waiting files that the body refers to, using forums'attachments.inline_pattern. Only people still in the conversation may see the files; removing the conversation takes the access away.PrivateMessage::attachments()lists a message's files. If the conversation is deleted, forums cleans up the orphaned files. - Privacy. Registers a contributor (export and erasure) with core.
Requirements
PHP 8.4, Laravel 13 and Filament 5. Tested against MariaDB 11.4. Requires filagora/filagora-core.
Install
composer require filagora/filagora-messages php artisan migrate
Schedule filagora:messages:purge-trashed daily. Tables are created with the filagora_ prefix; a site
that already has them can run php artisan filagora:adopt instead of migrating.
Configuration
config/filagora-messages.php is merged with the host's copy, so list only what
differs. Publish it with php artisan vendor:publish --tag=filagora-messages-config.
Extending
Extend through documented contracts, events and registries. Anything not documented
is @internal.
Testing
composer test
Tests run against a real MariaDB, never SQLite, so engine behaviour (FULLTEXT,
ONLY_FULL_GROUP_BY, collation) matches production. Host and credentials come from
your environment; the database is always named testing, never your development one.
Local development (DDEV)
.ddev/ is included. ddev start creates both db and testing (run ddev restart once
if testing is missing), then ddev exec vendor/bin/pest.
Licence
MIT. See LICENSE.