'Encode the joined rooms in a sync result
Args:
rooms(list[synapse.handlers.sync.JoinedSyncResult]): list of sync
results for rooms this user is joined to
time_now(int): current time - used as a baseline for age
calculations
token_id(int): ID of the user\'s auth token - used for namespacing
of transaction IDs
event_fields(list<str>): List of event fields to include. If empty,
all fields will be returned.
Returns:
dict[str, dict[str, object]]: the joined rooms list, in our
response format'

def encode_joined(self, rooms, time_now, token_id, event_fields):

    joined = {}
    for room in rooms:
        joined[room.room_id] = self.encode_room(room, time_now, token_id, only_fields=event_fields)
    return joined
