Search by

phil / user-blocks

phil

Keep unwanted members, groups, domains and words out of a member's way: mute, ignore or block, expiring keyword filters, one check every feature reads.

0.1.0-alpha 2026-12-02 22:00 UTC

This package is auto-updated.

Last update: 2026-12-03 01:33:46 UTC


README

Members keep unwanted people and topics out of their way: mute, ignore or block a member, mute or ignore a group or a domain, and filter keywords for a while; forum, messages, comments, mentions, reactions and follows all read the same measures through one service.

phil/user-blocks gives every feature of an application one answer to "does this member want to hear from that one?". A member takes one of three measures against another member, each holding the one before it:

  • mute: no more notifications from them; their content stays in sight;
  • ignore: muted, their content hidden, their direct messages refused;
  • block: ignored, and every interaction between the two refused, both ways — replies, mentions, reactions, messages, follows, invitations.

A member also mutes or ignores a group — a forum section, a group, a space, a channel — or a domain, which counts for every host under it: ignoring example.com hides the links to news.example.com. And they save keyword filters: up to 30 words or phrases, matched without regard to case, as whole words or anywhere, in the contexts they choose — feeds, discussions, notifications, messages, profiles —, which show the content behind a warning that names the filter, or hide it. Every measure and filter lasts for good or until a moment the member picks.

The target is never told. Nothing in the library makes a measure public, and a refused interaction is meant to be shown in words that do not say a measure exists. Blocking is private: no shared block lists.

Features ask three questions: may this member do that toward that one (canInteract()), whom among these recipients to notify (recipientsToNotify(), three reads of the store for up to a thousand recipients), and how does this member see each piece of this page (viewerFilter(), compiled once per request, then a verdict per piece: shown, behind a warning, or hidden, with why).

It is a plain PHP library on psr/clock, psr/event-dispatcher, symfony/uid and phil/url. The measures and filters live in a store behind one interface, in memory for tests and scripts. It holds no state between calls and runs in a worker. The settings pages, the database tables and the integration into each feature belong to the application or to a bundle.

Status

Part State
Mute, ignore and block a member; mute or ignore a group or a domain, a domain counting for every host under it; for good or until a moment Implemented and tested
Interactions refused by a block both ways, direct messages refused by an ignore Implemented and tested
Recipients of a notification filtered in three reads of the store, the author's blocks included Implemented and tested
Keyword filters: 1 to 30 keywords, whole words or anywhere, five contexts, warn or hide, expiring; read strictly from an array, with a fuzz target Implemented and tested
A viewer's measures compiled once per request, a verdict per piece of content Implemented and tested
Events with identifiers only; forgetting a member; purging what ended Implemented and tested
In-memory store Implemented and tested
A Symfony bundle: Doctrine store, settings pages, Twig checks, the erasure of an account, the purge on a schedule Not written

Documentation

Document What it covers
Installation Requirements, installing, building the service.
Measures Muting, ignoring and blocking; groups and domains; how long a measure lasts; what each one refuses.
Keyword filters Keywords, contexts, actions, expiry, and the format a form or an API gives.
Integrating a feature Checking an interaction, notifying, judging a page, forgetting an account, purging.
Extension points The port, events and arguments an application chooses or replaces.
Testing The package's tests, fuzz target and benchmark, and how to test code that reads measures.
Reference Every public type, with its role.

Quick start

composer require phil/user-blocks
use Phil\UserBlocks\Content;
use Phil\UserBlocks\Context;
use Phil\UserBlocks\FilterDefinition;
use Phil\UserBlocks\InMemoryUserBlocksStore;
use Phil\UserBlocks\Interaction;
use Phil\UserBlocks\UserBlocks;
use Symfony\Component\Clock\NativeClock;

$blocks = new UserBlocks(new InMemoryUserBlocksStore(), new NativeClock());

$blocks->block('member-7', 'member-12');
$blocks->addFilter('member-7', FilterDefinition::fromArray([
    'title' => 'Spoilers',
    'keywords' => ['season finale', ['keyword' => 'spoil', 'whole_word' => false]],
    'contexts' => ['feed', 'notifications'],
]));

$blocks->canInteract('member-12', 'member-7', Interaction::Reply);        // false

$page = $blocks->viewerFilter('member-7');
$page->decide(new Content('member-3', 'No spoilers, please'), Context::Feed);   // a warning naming "Spoilers"

Requirements

PHP 8.5 or later with ext-mbstring.

Contributing

Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.

License

MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.