'Returns whether there may be any new events that should be sent down
the sync. Returns True if there are.'

@defer.inlineCallbacks
def _have_rooms_changed(self, sync_result_builder):

    user_id = sync_result_builder.sync_config.user.to_string()
    since_token = sync_result_builder.since_token
    now_token = sync_result_builder.now_token
    assert since_token
    rooms_changed = (yield self.store.get_membership_changes_for_user(user_id, since_token.room_key, now_token.room_key))
    if rooms_changed:
        defer.returnValue(True)
    app_service = self.store.get_app_service_by_user_id(user_id)
    if app_service:
        rooms = (yield self.store.get_app_service_rooms(app_service))
        joined_room_ids = set((r.room_id for r in rooms))
    else:
        joined_room_ids = (yield self.store.get_rooms_for_user(user_id))
    stream_id = RoomStreamToken.parse_stream_token(since_token.room_key).stream
    for room_id in joined_room_ids:
        if self.store.has_room_changed_since(room_id, stream_id):
            defer.returnValue(True)
    defer.returnValue(False)
