Mercurial > prosody-modules
annotate mod_measure_stanza_counts/mod_measure_stanza_counts.lua @ 3656:3e0f4d727825
mod_vcard_muc: Add an alternative method of signaling avatar change
When the avatar has been changed, a signal is sent that the room
configuration has changed. Clients then do a disco#info query to find
the SHA-1 of the new avatar. They can then fetch it as before, or not if
they have it cached already.
This is meant to be less disruptive than signaling via presence, which
caused problems for some clients.
If clients transition to the new method, the old one can eventually be removed.
The namespace is made up while waiting for standardization.
Otherwise it is very close to what's described in
https://xmpp.org/extensions/inbox/muc-avatars.html
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 25 Aug 2019 20:46:43 +0200 |
parents | 512405077709 |
children | 33b1b6ff23d8 |
rev | line source |
---|---|
2787
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 module:set_global() |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local filters = require"util.filters"; |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local stanza_kinds = { message = true, presence = true, iq = true }; |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 local function rate(measures, dir) |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 return function (stanza, session) |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 measures[dir](); |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 measures[dir .. "_" .. session.type](); |
2788
512405077709
mod_measure_stanza_counts: Fix a crash in mod_bosh.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
2787
diff
changeset
|
11 if stanza.attr and not stanza.attr.xmlns and stanza_kinds[stanza.name] then |
2787
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 measures[dir .. "_" .. session.type .. "_" .. stanza.name](); |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 end |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 return stanza; |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 end |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 local measures = setmetatable({}, { |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 __index = function (t, name) |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 local m = module:measure(name, "rate"); |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 t[name] = m; |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 return m; |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 end |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 }); |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 local function measure_stanza_counts(session) |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 filters.add_filter(session, "stanzas/in", rate(measures, "incoming")); |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 filters.add_filter(session, "stanzas/out", rate(measures, "outgoing")); |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 |
750572f6f59d
mod_measure_stanza_counts: Counts stanzas and reports using 0.10+ statistics API
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 filters.add_filter_hook(measure_stanza_counts); |