+function room_mt:get_affiliation(jid)
+ local node, host, resource = jid_split(jid);
+ local bare = node and node.."@"..host or host;
+ local result = self._affiliations[bare]; -- Affiliations are granted, revoked, and maintained based on the user's bare JID.
+ if not result and self._affiliations[host] == "outcast" then result = "outcast"; end -- host banned
+ return result;
+end
+
+function room_mt:set_affiliation(jid, affiliation)
+ local node, host, resource = jid_split(jid);
+ local bare = node and node.."@"..host or host;
+ if affiliation == "none" then affiliation = nil; end
+ if affiliation and affiliation ~= "outcast" and affiliation ~= "owner" and affiliation ~= "admin" and affiliation ~= "member" then return false; end
+ self._affiliations[bare] = affiliation;
+ -- TODO set roles based on new affiliation
+ return true;
+end
+
+local _M = {}; -- module "muc"