Software /
code /
prosody
Comparison
plugins/muc/password.lib.lua @ 8997:8c4dd4375823
MUC/password: Set room password on creation if included in join stanza
This fixes room creation/joining from Gajim if a password has been set.
Otherwise the muc-occupant-pre-join event hook determines that the given
password differs from the unset password and joining is rejected, which
seems unhelpful.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 08 Jul 2018 04:17:54 +0200 |
parent | 8996:2df7dc99566a |
child | 9035:173c0e16e704 |
comparison
equal
deleted
inserted
replaced
8996:2df7dc99566a | 8997:8c4dd4375823 |
---|---|
63 local x = event.stanza:get_child("x", "http://jabber.org/protocol/muc#user"); | 63 local x = event.stanza:get_child("x", "http://jabber.org/protocol/muc#user"); |
64 x:tag("password"):text(password):up(); | 64 x:tag("password"):text(password):up(); |
65 end | 65 end |
66 end); | 66 end); |
67 | 67 |
68 module:hook("muc-room-pre-create", function (event) | |
69 local stanza, room = event.stanza, event.room; | |
70 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc"); | |
71 if not muc_x then return end | |
72 local password = muc_x:get_child_text("password", "http://jabber.org/protocol/muc"); | |
73 set_password(room, password); | |
74 end); | |
75 | |
68 return { | 76 return { |
69 get = get_password; | 77 get = get_password; |
70 set = set_password; | 78 set = set_password; |
71 }; | 79 }; |