Mercurial > prosody-modules
annotate mod_csi/mod_csi.lua @ 1503:c4c9ccc6e6c9
mod_profile: Set metadata nodes ItemID to the same hash as the data node
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 16 Sep 2014 16:23:15 +0200 |
parents | 90fe03e65d2c |
children | fbb4cd2922a1 |
rev | line source |
---|---|
1483
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local st = require "util.stanza"; |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 local csi_feature = st.stanza("csi", { xmlns = "urn:xmpp:csi" }); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 module:hook("stream-features", function (event) |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 if event.origin.username then |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 event.features:add_child(csi_feature); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 end |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 end); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 function refire_event(name) |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 return function (event) |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 if event.origin.username then |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 module:fire_event(name, event); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 return true; |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 end |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 end; |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 end |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 module:hook("stanza/urn:xmpp:csi:active", refire_event("csi-client-active")); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 module:hook("stanza/urn:xmpp:csi:inactive", refire_event("csi-client-inactive")); |
90fe03e65d2c
mod_csi: Client State Indication support
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 |