Software /
code /
prosody-modules
Diff
mod_vcard_muc/mod_vcard_muc.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 |
parent | 3655:d7b589dec591 |
child | 4043:a533abe6ffd0 |
line wrap: on
line diff
--- a/mod_vcard_muc/mod_vcard_muc.lua Fri Aug 23 23:01:16 2019 +0200 +++ b/mod_vcard_muc/mod_vcard_muc.lua Sun Aug 25 20:46:43 2019 +0200 @@ -42,7 +42,7 @@ local function broadcast_presence(room_jid, to) local room = get_room_from_jid(room_jid); - local photo_hash = get_photo_hash(room) + local photo_hash = get_photo_hash(room); local presence_vcard = st.presence({to = to, from = room_jid}) :tag("x", { xmlns = "vcard-temp:x:update" }) :tag("photo"):text(photo_hash):up(); @@ -78,6 +78,10 @@ if vcards:set(room_node, st.preserialize(stanza.tags[1])) then session.send(st.reply(stanza):tag("vCard", { xmlns = "vcard-temp" })); broadcast_presence(room_jid, nil) + + room:broadcast_message(st.message({ from = room.jid, type = "groupchat" }) + :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }) + :tag("status", { code = "104" })); else -- TODO unable to write file, file may be locked, etc, what's the correct error? session.send(st.error_reply(stanza, "wait", "internal-server-error")); @@ -95,6 +99,12 @@ module:hook("muc-disco#info", function(event) event.reply:tag("feature", { var = "vcard-temp" }):up(); + + table.insert(event.form, { + name = "{http://modules.prosody.im/mod_vcard_muc}avatar#sha1", + type = "text-single", + }); + event.formdata["{http://modules.prosody.im/mod_vcard_muc}avatar#sha1"] = get_photo_hash(event.room); end); module:hook("muc-occupant-session-new", function(event)