Comparison

plugins/muc/history.lib.lua @ 8780:4cab4ee5dfcc

MUC: Introduce an event to allow plugins to influence which messages are added to history
author Kim Alvefur <zash@zash.se>
date Mon, 07 May 2018 22:10:29 +0200
parent 8779:11b4ae162db7
child 8794:0e2c1c4d4f78
comparison
equal deleted inserted replaced
8779:11b4ae162db7 8780:4cab4ee5dfcc
154 end, -1); 154 end, -1);
155 155
156 -- Have a single muc-add-history event, so that plugins can mark it 156 -- Have a single muc-add-history event, so that plugins can mark it
157 -- as handled without stopping other muc-broadcast-message handlers 157 -- as handled without stopping other muc-broadcast-message handlers
158 module:hook("muc-broadcast-message", function(event) 158 module:hook("muc-broadcast-message", function(event)
159 local historic = event.stanza:get_child("body"); 159 if module:fire_event("muc-message-is-historic", event) then
160 if historic then
161 module:fire_event("muc-add-history", event); 160 module:fire_event("muc-add-history", event);
162 end 161 end
163 end); 162 end);
163
164 module:hook("muc-message-is-historic", function (event)
165 return event.stanza:get_child("body");
166 end, -1);
164 167
165 return { 168 return {
166 set_max_length = set_max_history_length; 169 set_max_length = set_max_history_length;
167 parse_history = parse_history; 170 parse_history = parse_history;
168 send = send_history; 171 send = send_history;