# HG changeset patch # User Matthew Wild # Date 1449847621 0 # Node ID f476e249756816a4b0c490d1581af9f3b497dc8b # Parent 118858bf47cddf948a7b5217cb4ad036b1201e15 MUC: Fire per-field events for the config form, including those with value == nil (no element in form) diff -r 118858bf47cd -r f476e2497568 plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Mon Dec 07 19:44:08 2015 +0100 +++ b/plugins/muc/muc.lib.lua Fri Dec 11 15:27:01 2015 +0000 @@ -644,11 +644,11 @@ if form.attr.type == "cancel" then origin.send(st.reply(stanza)); elseif form.attr.type == "submit" then - local fields; + local fields, errors, present; if form.tags[1] == nil then -- Instant room - fields = {}; + fields, present = {}, {}; else - fields = self:get_form_layout(stanza.attr.from):data(form); + fields, errors, present = self:get_form_layout(stanza.attr.from):data(form); if fields.FORM_TYPE ~= "http://jabber.org/protocol/muc#roomconfig" then origin.send(st.error_reply(stanza, "cancel", "bad-request", "Form is not of type room configuration")); return true; @@ -666,6 +666,11 @@ return true; end module:fire_event("muc-config-submitted", event); + for submitted_field in pairs(present) do + event.field, event.value = submitted_field, fields[submitted_field]; + module:fire_event("muc-config-submitted/"..submitted_field, event); + end + event.field, event.value = nil, nil; if self.save then self:save(true); end origin.send(st.reply(stanza));