Comparison

mod_report_forward/mod_report_forward.lua @ 6043:7b093a9b95ea

mod_report_forward: Fix traceback on error message passed to datetime function If archive:get() returns an error, e.g. because it can't find a message with the given ID, it may return e.g. nil, "item-not-found" or similar where the error condition ends up in reported_message_time, which gets passed to util.datetime, which thus ends up doing math to a string or error object.
author Kim Alvefur <zash@zash.se>
date Wed, 06 Nov 2024 22:25:41 +0100
parent 5940:1927d4d27a26
child 6066:91590d92b919
comparison
equal deleted inserted replaced
6042:c038b1e01a0e 6043:7b093a9b95ea
106 local reported_message, reported_message_time, reported_message_with; 106 local reported_message, reported_message_time, reported_message_with;
107 if reported_message_el then 107 if reported_message_el then
108 reported_message, reported_message_time, reported_message_with = archive:get(reporter_username, reported_message_el.attr.id); 108 reported_message, reported_message_time, reported_message_with = archive:get(reporter_username, reported_message_el.attr.id);
109 if jid.bare(reported_message_with) ~= event.jid then 109 if jid.bare(reported_message_with) ~= event.jid then
110 reported_message = nil; 110 reported_message = nil;
111 reported_message_time = nil;
111 end 112 end
112 end 113 end
113 114
114 local body_text = render(body_template, { 115 local body_text = render(body_template, {
115 reporter_jid = reporter_jid; 116 reporter_jid = reporter_jid;