comparison plugins/mod_carbons.lua @ 14070:d7f2ffc25273 13.0

mod_carbons: Fix some carbons decision-making bugs (fixes #1861) This was introduced when refactoring into an event in commit 063ce658c181 (released in 0.12.0). Known policies to be affected: - Copying of outgoing MUC PMs (#1861) - Copying of archived stanzas (if not copied by other rules)
author Matthew Wild <mwild1@gmail.com>
date Wed, 11 Feb 2026 11:38:55 +0000
parents 74b9e05af71e
children 54b30a374953 d79ef7a38fe8
comparison
equal deleted inserted replaced
14068:2462247ec377 14070:d7f2ffc25273
68 68
69 return false, "default"; 69 return false, "default";
70 end 70 end
71 71
72 module:hook("carbons-should-copy", function (event) 72 module:hook("carbons-should-copy", function (event)
73 local should, why = should_copy(event.stanza); 73 local should, why = should_copy(event.stanza, event.from_c2s, event.user_bare);
74 event.reason = why; 74 event.reason = why;
75 return should; 75 return should;
76 end, -1) 76 end, -1)
77 77
78 local function message_handler(event, c2s) 78 local function message_handler(event, c2s)
105 if not user_sessions then 105 if not user_sessions then
106 module:log("debug", "Skip carbons for offline user"); 106 module:log("debug", "Skip carbons for offline user");
107 return -- No use in sending carbons to an offline user 107 return -- No use in sending carbons to an offline user
108 end 108 end
109 109
110 local event_payload = { stanza = stanza; session = origin }; 110 local event_payload = {
111 stanza = stanza;
112 session = origin;
113 from_c2s = c2s;
114 user_bare = bare_jid;
115 };
111 local should = module:fire_event("carbons-should-copy", event_payload); 116 local should = module:fire_event("carbons-should-copy", event_payload);
112 local why = event_payload.reason; 117 local why = event_payload.reason;
113 118
114 if not should then 119 if not should then
115 module:log("debug", "Not copying stanza: %s (%s)", stanza:top_tag(), why); 120 module:log("debug", "Not copying stanza: %s (%s)", stanza:top_tag(), why);