Comparison

plugins/muc/subject.lib.lua @ 6228:4968d18e2c1e

plugins/muc/subject.lib: If subject is not set by an occupant, it should come from room jid itself
author daurnimator <quae@daurnimator.com>
date Fri, 18 Apr 2014 12:20:07 -0400
parent 6224:2a9aff163545
child 6277:f2c9c36979b3
comparison
equal deleted inserted replaced
6227:bb75c011b15e 6228:4968d18e2c1e
41 event.status_codes["104"] = true; 41 event.status_codes["104"] = true;
42 end 42 end
43 end); 43 end);
44 44
45 local function get_subject(room) 45 local function get_subject(room)
46 return room._data.subject_from, room._data.subject; 46 -- a <message/> stanza from the room JID (or from the occupant JID of the entity that set the subject)
47 return room._data.subject_from or room.jid, room._data.subject;
47 end 48 end
48 49
49 local function send_subject(room, to) 50 local function send_subject(room, to)
50 local msg = create_subject_message(get_subject(room)); 51 local msg = create_subject_message(get_subject(room));
51 msg.attr.to = to; 52 msg.attr.to = to;
64 return true; 65 return true;
65 end 66 end
66 67
67 -- Send subject to joining user 68 -- Send subject to joining user
68 module:hook("muc-occupant-joined", function(event) 69 module:hook("muc-occupant-joined", function(event)
69 event.room:send_subject(event.stanza.attr.from); 70 send_subject(event.room, event.stanza.attr.from);
70 end, 20); 71 end, 20);
71 72
72 -- Role check for subject changes 73 -- Role check for subject changes
73 module:hook("muc-subject-change", function(event) 74 module:hook("muc-subject-change", function(event)
74 local room, stanza = event.room, event.stanza; 75 local room, stanza = event.room, event.stanza;