1196 return jid, affiliation; |
1196 return jid, affiliation; |
1197 end, self._affiliations, nil |
1197 end, self._affiliations, nil |
1198 end |
1198 end |
1199 end |
1199 end |
1200 |
1200 |
1201 function room_mt:set_affiliation(actor, jid, affiliation, reason) |
1201 function room_mt:set_affiliation(actor, jid, affiliation, reason, data) |
|
1202 module:log("debug", "data is %s", tostring(data)); |
1202 if not actor then return nil, "modify", "not-acceptable"; end; |
1203 if not actor then return nil, "modify", "not-acceptable"; end; |
1203 |
1204 |
1204 local node, host, resource = jid_split(jid); |
1205 local node, host, resource = jid_split(jid); |
1205 if not host then return nil, "modify", "not-acceptable"; end |
1206 if not host then return nil, "modify", "not-acceptable"; end |
1206 jid = jid_join(node, host); -- Bare |
1207 jid = jid_join(node, host); -- Bare |
1238 end |
1239 end |
1239 end |
1240 end |
1240 |
1241 |
1241 -- Set in 'database' |
1242 -- Set in 'database' |
1242 self._affiliations[jid] = affiliation; |
1243 self._affiliations[jid] = affiliation; |
|
1244 if not affiliation or data == false or (data ~= nil and next(data) == nil) then |
|
1245 module:log("debug", "Clearing affiliation data for %s", jid); |
|
1246 self._affiliation_data[jid] = nil; |
|
1247 elseif data then |
|
1248 module:log("debug", "Updating affiliation data for %s", jid); |
|
1249 self._affiliation_data[jid] = data; |
|
1250 end |
1243 |
1251 |
1244 -- Update roles |
1252 -- Update roles |
1245 local role = self:get_default_role(affiliation); |
1253 local role = self:get_default_role(affiliation); |
1246 local role_rank = valid_roles[role or "none"]; |
1254 local role_rank = valid_roles[role or "none"]; |
1247 local occupants_updated = {}; -- Filled with old roles |
1255 local occupants_updated = {}; -- Filled with old roles |
1423 }; |
1434 }; |
1424 end |
1435 end |
1425 |
1436 |
1426 local occupants = {}; |
1437 local occupants = {}; |
1427 local room_name, room_host = jid_split(room_jid); |
1438 local room_name, room_host = jid_split(room_jid); |
|
1439 |
|
1440 room._affiliation_data = frozen._affiliation_data; |
1428 |
1441 |
1429 if frozen.jid and frozen._affiliations then |
1442 if frozen.jid and frozen._affiliations then |
1430 room._affiliations = frozen._affiliations; |
1443 room._affiliations = frozen._affiliations; |
1431 else |
1444 else |
1432 for jid, data in pairs(frozen) do |
1445 for jid, data in pairs(frozen) do |