```coffeescript
Meteor.methods
	updateRoom: (rid, name, users, accessPermissions) ->

		if not Meteor.userId()
			throw new Meteor.Error('invalid-user', "[methods] updateRoom -> Invalid user")

		room = ChatRoom.findOne rid

		if room.t not in ['d'] and name? and name isnt room.name
			Meteor.call 'saveRoomName', rid, name
		Meteor.call 'relabelRoom', rid, accessPermissions
		if users?
			# remove the current users
			users = _.without.apply _,room.usernames.concat users
			for user in users
				Meteor.call 'addUserToRoom', rid, user
		return true
```

Validate parameters, and: 1. check that room creator is not removed 2. relabel room if access permissions changed 3. add new members that we're previously in the room 4. remove existing members that should no longer be in the room
user
```coffeescript
Meteor.methods
	updateRoom: (rid, name, usernames, accessPermissions) ->

		console.log '[method] updateRoom -> arguments', arguments

		if not Meteor.userId()
			throw new Meteor.Error('invalid-user', "[methods] updateRoom -> Requires authenticated user")

		# validate params exist
		unless rid and name and usernames and accessPermissions
			throw new Meteor.Error 'invalid-argument', 'Missing required values'

		room = ChatRoom.findOne rid

		# don't allow the room creator to be removed
		unless room.u.username in usernames
			throw new Meteor.Error 'invalid-argument', 'You cannot remove the room creator'

		if room.t not in ['d'] and name? and name isnt room.name
			Meteor.call 'saveRoomName', rid, name

		# relabel room if permissions changed
		if _.difference( room.accessPermissions, accessPermissions ).length > 0
			Meteor.call 'relabelRoom', rid, accessPermissions

		# add users to the room that weren't previously in the room
		usersToAdd = _.difference( usernames, room.usernames)
		for username in usersToAdd
			Meteor.call 'addUserToRoom', {rid: rid, username: username}

		# remove users from the room that were previously in the room
		usersToRemove = _.difference( room.usernames, usernames)
		for username in usersToRemove
			Meteor.call 'removeUserFromRoom', {rid: rid, username: username}

		return {rid:rid}
```
assistant