Comparison

plugins/muc/password.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 7401:e16b3fd0bd80
comparison
equal deleted inserted replaced
7352:50b24b3476e6 7353:ca31d3271cf8
15 15
16 local function set_password(room, password) 16 local function set_password(room, password)
17 if password == "" then password = nil; end 17 if password == "" then password = nil; end
18 if room._data.password == password then return false; end 18 if room._data.password == password then return false; end
19 room._data.password = password; 19 room._data.password = password;
20 room:save(true);
21 return true; 20 return true;
22 end 21 end
23 22
24 module:hook("muc-disco#info", function(event) 23 module:hook("muc-disco#info", function(event)
25 event.reply:tag("feature", {var = get_password(event.room) and "muc_passwordprotected" or "muc_unsecured"}):up(); 24 event.reply:tag("feature", {var = get_password(event.room) and "muc_passwordprotected" or "muc_unsecured"}):up();