annotate mod_drop_chatstates/mod_drop_chatstates.lua @ 6317:7b693a5539ad

mod_auth_http_async: Update documentation The required async APIs were included in 0.10.0, but at the time of this writing we only consider 0.12.x and later supported. The fallback sync API would have made it work with even earlier versions, but I don't remember specifically and it doesn't matter.
author Kim Alvefur <zash@zash.se>
date Tue, 02 Sep 2025 21:32:01 +0200
parents 2525f247084c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6310
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
1 local jid = require "util.jid"
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
2 local st = require "util.stanza"
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
3
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
4 local CHATSTATES_NS = "http://jabber.org/protocol/chatstates"
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
5 local domains = module:get_option_set("drop_chatstates_domains", {})
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
6
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
7 local function handle_pre_message(event)
6311
2525f247084c mod_drop_chatstates: Fix bug using stanza before its defined
Chaz Kettleson <chaz@pyr3x.com>
parents: 6310
diff changeset
8 local stanza = event.stanza
6310
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
9 local to_host = jid.host(stanza.attr.to)
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
10 if not to_host or not domains:contains(to_host) then return end
6311
2525f247084c mod_drop_chatstates: Fix bug using stanza before its defined
Chaz Kettleson <chaz@pyr3x.com>
parents: 6310
diff changeset
11 if stanza:get_child(nil, CHATSTATES_NS) then return true end
6310
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
12 end
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
13
92e2dcf039d9 mod_drop_chatstates: New module to drop chatstates for specific domains
Chaz Kettleson <chaz@pyr3x.com>
parents:
diff changeset
14 module:hook("pre-message/bare", handle_pre_message)