Filter
Represents a user-defined filter for determining which statuses should not be shown to the user.
Example
Attributes
id
id
Description: The ID of the filter in the database. Type: String (cast from an integer, but not guaranteed to be a number) Version history: Added in 2.4.3
phrase
phrase
Description: The text to be filtered. Type: String Version history: Added in 2.4.3
context
context
Description: The contexts in which the filter should be applied.
Type: Array of String (Enumerable anyOf)
- home
= home timeline
- notifications
= notifications timeline
- public
= public timelines
- thread
= expanded thread of a detailed status
Version history: Added in 2.4.3
expires_at
expires_at
Description: When the filter should no longer be applied Type: String (ISO 8601 Datetime), or null if the filter does not expire Version history: Added in 2.4.3
irreversible
irreversible
Description: Should matching entities in home and notifications be dropped by the server? Type: Boolean Version history: Added in 2.4.3
whole_word
whole_word
Description: Should the filter consider word boundaries? Type: Boolean Version history: Added in 2.4.3
Implementation notes
If whole_word
is true , client app should do:
Define ‘word constituent character’ for your app. In the official implementation, it’s
[A-Za-z0-9_]
in JavaScript, and[[:word:]]
in Ruby. Ruby uses the POSIX character class (Letter | Mark | Decimal_Number | Connector_Punctuation).If the phrase starts with a word character, and if the previous character before matched range is a word character, its matched range should be treated to not match.
If the phrase ends with a word character, and if the next character after matched range is a word character, its matched range should be treated to not match.
Please check app/javascript/mastodon/selectors/index.js
and app/lib/feed_manager.rb
in the Mastodon source code for more details.
See also
Last updated
Was this helpful?