Software /
code /
prosody
Comparison
plugins/muc/subject.lib.lua @ 7353:ca31d3271cf8
MUC: Save room to storage once after form processing, not in each individual setter
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 15 Apr 2016 11:50:55 +0200 |
parent | 7352:50b24b3476e6 |
child | 7357:d69521003e91 |
comparison
equal
deleted
inserted
replaced
7352:50b24b3476e6 | 7353:ca31d3271cf8 |
---|---|
23 | 23 |
24 local function set_changesubject(room, changesubject) | 24 local function set_changesubject(room, changesubject) |
25 changesubject = changesubject and true or nil; | 25 changesubject = changesubject and true or nil; |
26 if get_changesubject(room) == changesubject then return false; end | 26 if get_changesubject(room) == changesubject then return false; end |
27 room._data.changesubject = changesubject; | 27 room._data.changesubject = changesubject; |
28 room:save(true); | |
29 return true; | 28 return true; |
30 end | 29 end |
31 | 30 |
32 module:hook("muc-config-form", function(event) | 31 module:hook("muc-config-form", function(event) |
33 table.insert(event.form, { | 32 table.insert(event.form, { |
59 if subject == "" then subject = nil; end | 58 if subject == "" then subject = nil; end |
60 local old_from, old_subject = get_subject(room); | 59 local old_from, old_subject = get_subject(room); |
61 if old_subject == subject and old_from == from then return false; end | 60 if old_subject == subject and old_from == from then return false; end |
62 room._data.subject_from = from; | 61 room._data.subject_from = from; |
63 room._data.subject = subject; | 62 room._data.subject = subject; |
64 room:save(); | |
65 local msg = create_subject_message(from, subject); | 63 local msg = create_subject_message(from, subject); |
66 room:broadcast_message(msg); | 64 room:broadcast_message(msg); |
67 return true; | 65 return true; |
68 end | 66 end |
69 | 67 |