Filter service

The message filter service, provided by the mod_filter module, allows clients to set up mechanisms that can control and manage incoming messages as they arrive at the recipient’s Jabber server—before they start on the final leg of the journey to the recipient’s client.

The service allows each user to maintain her own filter, which is a collection of rules. A rule is a combination of conditions and actions. For each incoming message, the message filter service kicks in and goes through the rules contained in the message recipient’s filter one by one, checking the characteristics of the incoming message using the conditions defined in each rule. If one of the conditions matches, then the action or actions defined in that rule are carried out and the message filter service stops going through the rules—unless the action specified is continue—in which case the service goes on to the next rule. The continue action makes it possible to chain together a complex series of checks and actions.

Figure 4-7 shows what a filter definition looks like.

A message filter
Figure 4-7. A message filter

Each user’s filter is stored on the server using the xdb component (see later). What does a typical filter look like? Well, Example 4-9 shows a filter that contains two rules:

holiday

Checks the message recipient’s presence and sends a “holiday” notice back if the presence is set to Extended Away ...

Get Programming Jabber now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.