Comparison

plugins/muc/muc.lib.lua @ 6191:5956f4e69ab2

plugins/muc/muc.lib: Subjects get sent even if empty.
author daurnimator <quae@daurnimator.com>
date Fri, 28 Mar 2014 20:25:10 -0400
parent 6190:6580e557cc61
child 6192:f97aa1f4b1f1
comparison
equal deleted inserted replaced
6190:6580e557cc61 6191:5956f4e69ab2
422 end 422 end
423 423
424 function room_mt:get_subject() 424 function room_mt:get_subject()
425 return self._data['subject'], self._data['subject_from'] 425 return self._data['subject'], self._data['subject_from']
426 end 426 end
427 local function create_subject_message(subject) 427 local function create_subject_message(from, subject)
428 return st.message({type='groupchat'}) 428 return st.message({from = from; type = "groupchat"})
429 :tag('subject'):text(subject):up(); 429 :tag('subject'):text(subject):up();
430 end 430 end
431 function room_mt:send_subject(to) 431 function room_mt:send_subject(to)
432 local from, subject = self:get_subject() 432 local msg = create_subject_message(self:get_subject());
433 if subject then 433 msg.attr.to = to;
434 local msg = create_subject_message(subject) 434 self:route_stanza(msg);
435 msg.attr.from = from
436 msg.attr.to = to
437 self:route_stanza(msg);
438 end
439 end 435 end
440 function room_mt:set_subject(current_nick, subject) 436 function room_mt:set_subject(current_nick, subject)
441 if subject == "" then subject = nil; end 437 if subject == "" then subject = nil; end
442 self._data['subject'] = subject; 438 self._data['subject'] = subject;
443 self._data['subject_from'] = current_nick; 439 self._data['subject_from'] = current_nick;
444 if self.save then self:save(); end 440 if self.save then self:save(); end
445 local msg = create_subject_message(subject) 441 local msg = create_subject_message(current_nick, subject);
446 msg.attr.from = current_nick
447 self:broadcast_message(msg, false); 442 self:broadcast_message(msg, false);
448 return true; 443 return true;
449 end 444 end
450 445
451 function room_mt:handle_kickable(origin, stanza) 446 function room_mt:handle_kickable(origin, stanza)