'Handle a room having potentially changed from/to world_readable/publically
joinable.
Args:
room_id (str)
prev_event_id (str|None): The previous event before the state change
event_id (str|None): The new event after the state change
typ (str): Type of the event'

@defer.inlineCallbacks
def _handle_room_publicity_change(self, room_id, prev_event_id, event_id, typ):

    logger.debug('Handling    change    for    %s:    %s', typ, room_id)
    if (typ == EventTypes.RoomHistoryVisibility):
        change = (yield self._get_key_change(prev_event_id, event_id, key_name='history_visibility', public_value='world_readable'))
    elif (typ == EventTypes.JoinRules):
        change = (yield self._get_key_change(prev_event_id, event_id, key_name='join_rule', public_value=JoinRules.PUBLIC))
    else:
        raise Exception('Invalid    event    type')
    if (change is None):
        logger.debug('No    change')
        return
    is_public = (yield self.store.is_room_world_readable_or_publicly_joinable(room_id))
    logger.debug('Change:    %r,    is_public:    %r', change, is_public)
    if (change and (not is_public)):
        return
    elif ((not change) and is_public):
        return
    if change:
        users_with_profile = (yield self.state.get_current_user_in_room(room_id))
        for (user_id, profile) in users_with_profile.iteritems():
            (yield self._handle_new_user(room_id, user_id, profile))
    else:
        users = (yield self.store.get_users_in_public_due_to_room(room_id))
        for user_id in users:
            (yield self._handle_remove_user(room_id, user_id))
