annotate mod_host_status_check/mod_host_status_check.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 3d80f8dba886
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2219
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local time = require "socket".gettime;
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local heartbeats = module:shared("/*/host_status_check/heartbeats");
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local connection_events = module:shared("/*/host_status_check/connection_events");
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 if prosody.hosts[module.host].type == "component" and module:get_option_string("component_module") == "component" then
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 module:hook("component-authenticated", function ()
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 connection_events[module.host] = { connected = true; timestamp = time() };
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 end);
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 -- Note: this event is not in 0.9, and requires a recent 0.10 or trunk build
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 module:hook("component-disconnected", function ()
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 connection_events[module.host] = { connected = false; timestamp = time() };
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 end);
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 module:hook("stanza/xmpp:prosody.im/heartbeat:heartbeat", function ()
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 heartbeats[module.host] = time();
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 return true;
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 end);
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 else
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 connection_events[module.host] = { connected = true, timestamp = time() };
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 end
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 function module.unload()
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 connection_events[module.host] = { connected = false, timestamp = time() };
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 heartbeats[module.host] = nil;
5fcf9d558250 Three new modules: mod_host_status_check, mod_host_status_heartbeat and mod_http_host_status_check
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 end