# HG changeset patch # User Matthew Wild # Date 1679051718 0 # Node ID 68a4fb45afbc688686e7ef38cafc6119e79e1ab3 # Parent fca0c7672148804e3f8161e8e7001e81c29f7ed0 disco: Fire disco-info-changed when necessary, move presence resending there diff -r fca0c7672148 -r 68a4fb45afbc plugins/disco.lua --- a/plugins/disco.lua Fri Mar 17 11:12:12 2023 +0000 +++ b/plugins/disco.lua Fri Mar 17 11:15:18 2023 +0000 @@ -94,25 +94,25 @@ function stream:set_identity(identity, node) self.disco.info[node or false].identities = { identity }; - stream:resend_presence(); + stream:event("disco-info-changed"); end function stream:add_identity(identity, node) local identities = self.disco.info[node or false].identities; identities[#identities + 1] = identity; - stream:resend_presence(); + stream:event("disco-info-changed"); end function stream:add_disco_feature(feature, node) local feature = feature.var or feature; self.disco.info[node or false].features[feature] = true; - stream:resend_presence(); + stream:event("disco-info-changed"); end function stream:remove_disco_feature(feature, node) local feature = feature.var or feature; self.disco.info[node or false].features[feature] = nil; - stream:resend_presence(); + stream:event("disco-info-changed"); end function stream:add_disco_item(item, node) @@ -339,6 +339,10 @@ presence:remove_children("c", xmlns_caps); presence:reset():add_child(stream:caps()):reset(); end, 10); + + stream:hook("disco-info-changed", function () + stream:resend_presence(); + end); end -- end of disco.lua