aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-03-24 13:36:43 -0400
committerdaurnimator <quae@daurnimator.com>2014-03-24 13:36:43 -0400
commit9b13e219b6b39ba568f62cf821b9a68bc4c56930 (patch)
tree41c1a8ba4cbc10e5ac4fee6e173fbd31de4d4338 /plugins/muc
parent9dce8113050677fc6e1e227aa3c11644296b1285 (diff)
downloadprosody-9b13e219b6b39ba568f62cf821b9a68bc4c56930.tar.gz
prosody-9b13e219b6b39ba568f62cf821b9a68bc4c56930.zip
plugins/muc/muc.lib: Extra utility functions around subjects
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/muc.lib.lua26
1 files changed, 19 insertions, 7 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 791938db..d0a5641c 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -246,11 +246,6 @@ function room_mt:send_history(stanza)
self:_route_stanza(msg);
end
end
-function room_mt:send_subject(to)
- if self._data['subject'] then
- self:_route_stanza(st.message({type='groupchat', from=self._data['subject_from'] or self.jid, to=to}):tag("subject"):text(self._data['subject']));
- end
-end
function room_mt:get_disco_info(stanza)
local count = 0; for _ in pairs(self._occupants) do count = count + 1; end
@@ -277,13 +272,30 @@ function room_mt:get_disco_items(stanza)
end
return reply;
end
+
+function room_mt:get_subject()
+ return self._data['subject'], self._data['subject_from']
+end
+local function create_subject_message(subject)
+ return st.message({type='groupchat'})
+ :tag('subject'):text(subject):up();
+end
+function room_mt:send_subject(to)
+ local from, subject = self:get_subject()
+ if subject then
+ local msg = create_subject_message(subject)
+ msg.attr.from = from
+ msg.attr.to = to
+ self:_route_stanza(msg);
+ end
+end
function room_mt:set_subject(current_nick, subject)
if subject == "" then subject = nil; end
self._data['subject'] = subject;
self._data['subject_from'] = current_nick;
if self.save then self:save(); end
- local msg = st.message({type='groupchat', from=current_nick})
- :tag('subject'):text(subject):up();
+ local msg = create_subject_message(subject)
+ msg.attr.from = current_nick
self:broadcast_message(msg, false);
return true;
end