Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Content Filters

Content Filter allows you to filter incoming content from all sources or from specific connections. The filtering may be based on words, tags, regular expressions, or language.

You can set global filters for all incoming content in the stream settings.

contfilter01

You can also set individual filters for each of your Connections. Select "Edit" for any connection, then look under Content filter.

contfilter02

If you cannot find the ‘Filter for content’ tab, you must first activate this function. To do so, open the settings for the ‘Connections’ app (small cogwheel next to the app name in the navigation bar).

contfilter02a

Now activate the function in the configuration dialogue.

contfilter02b

If you add filters under Do not import posts with this text, ("deny filtering") these are applied first. Any matching content will be removed.

Then, any filters under Only import posts with this text ("accept filtering") are applied. Only matching content will be kept, and everything that doesn't match will be removed.

Generally speaking, you will be using one or the other; and rarely if ever using both at the same time.

Basic Filters

TEXT

Any text that doesn't start with one of the following: '#', '$', '?', '/', '@', 'lang=', 'lang!=' performs a case-insensitive text match.

Example: apple (matches "apple", "APPLE", "Apples", "pineapple", "applesauce", etc.)

Example: low sub (matches "low sub", "low sub-zero", "Yellow Submarine", etc.)

NOTE: Beware of using short character sequences that will match many dissimilar words. You may want to use REGULAR EXPRESSIONS (see below).

LANGUAGE

lang= Match language (if it can be identified) Example: lang=de (matches German-language content)

lang!= Match anything except this language (if it can be identified) Example: lang!=en (matches non-English content)

HASHTAG

# Match hashtag Example: #cats

#>n Match greater than total number of hashtags Example: #>10

MENTION

@ Match mention Example: @alice

@>n Match greater than total number of mentions Example: @>10

CATEGORY

$ Match category. Example: $Science

ITEMS AND FIELDS

? Discussed below under Advanced Filters

REGULAR EXPRESSIONS (REGEX)

/ Match a "regular expression". See numerous online help sites such as Regular-Expressions.info and regexr.com for regex assistance.

Example: /gr[ae]y/ (matches "gray" and "grey") Example: /\b[Ww]ar\b/ (matches the whole words "war" and "War", but not "wars", "warning", "software", etc.)

LOGICAL OPERATORS

Filters allow the logical operators

&& for AND || for OR

Advanced Filters

ITEMS

? You may perform a string/numeric/array/boolean match on the database fields of an item (a post, comment, etc). A complete listing is beyond the scope of this document, but see install/schema_mysql.sql and search for CREATE TABLE IF NOT EXISTS item``. Here is a sampling:

  • body (content of the message)
  • verb (usually the same as the ActivityPub activity type, e.g. Create, Listen)
  • obj_type (usually the same as the ActivityPub object.type, e.g. Note, Event)
  • item_thread_top (first post in a thread, boolean)
  • item_private (0 = public message, 1 = restricted message, 2 = direct message)
  • ua (User-Agent string of delivery agent - custom item attribute that is not in the database)
  • ...etc...

Available comparison operators are:

  • ?foo ~= baz -- item.foo contains the string 'baz'
  • ?foo == baz -- item.foo is the string 'baz'
  • ?foo != baz -- item.foo is not the string 'baz'
  • ?foo >= 3 -- item.foo is greater than or equal to 3
  • ?foo > 3 -- item.foo is greater than 3
  • ?foo <= 3 -- item.foo is less than or equal to 3
  • ?foo < 3 -- item.foo is less than 3
  • ?foo {} baz -- 'baz' is an array element in item.foo
  • ?foo {*} baz -- 'baz' is an array key in item.foo
  • ?foo -- true condition for item.foo
  • ?!foo -- false condition for item.foo (The values 0, '', an empty array, and an unset value will all evaluate to false)

Example: ?verb == Announce (matches ActivityPub "boosts")

FIELDS

?+ ActivityPub/ActivityStreams object match. This is literally the copied object attribute from the incoming activity.

Supports all the operators listed above.

Examples:

?+type == Question -- matches ActivityPub polls

?+attributedTo ~= spammer -- matches ActivityPub attributedTo: https://o3r56t3c.example.com/u/cryptospammer2355

DATE AND TIME

With the expression until=<year-month-day [hour:minute:second]>, content can be filtered based on time. If this expression is used in the ‘Do not import’ field, all posts up to the specified time will be filtered out. If used in the ‘Import’ field, all posts up to the specified time will be imported.