Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include event_id when /state/:type[/:key]?format=event #15454

Open
matrixbot opened this issue Dec 21, 2023 · 0 comments
Open

Include event_id when /state/:type[/:key]?format=event #15454

matrixbot opened this issue Dec 21, 2023 · 0 comments

Comments

@matrixbot
Copy link
Collaborator

matrixbot commented Dec 21, 2023

This issue has been migrated from #15454.


Problem

Currently when you GET /_matrix/client/v3/rooms/{room_id}/state/m.room.create?format=event (notice the event format), it doesn't include event_id which is kinda annoying to work with and reference.

Example:

{
    "content": {
        "creator": "@foo:bar",
        "room_version": "6"
    },
    "origin_server_ts": 1606978812896,
    "room_id": "!abc",
    "sender": "@foo:bar",
    "state_key": "",
    "type": "m.room.create",
    "unsigned": {
        "age_ts": 1606978812896
    }
}

Proposal

Add event_id to the output. There is no spec to go off of but seems like a non-breaking change we can do.


Spawning from a need in matrix-org/matrix-viewer#167 to get the event_id of the m.room.create event in the room.

Is there a better way to do this? Perhaps /_matrix/client/v3/rooms/{room_id}/messages?dir=f&limit=1

Dev notes

Relevant code:

https://github.com/matrix-org/synapse/blob/d935b806a52c967543f59def690aec0fa873d13c/synapse/rest/client/room.py#L258-L262

Currently, we use format_event_for_client_v2(data.get_dict()) against the EventBase PDU JSON dictionary which doesn't include event_id. We could instead use serialize_event(data, self.clock.time_msec()) which would get us something more workable.

We could also alternatively, add event_id to the dictionary returned by EventBase.get_dict() but that probably has too many downstream side-effects like messing with the PDU JSON serialization stuff.

https://github.com/matrix-org/synapse/blob/d935b806a52c967543f59def690aec0fa873d13c/synapse/events/__init__.py#L362-L366


Separately, it would be good to standardize with the ?event_format=client|federation parameter used with other endpoints

@matrixbot matrixbot changed the title Dummy issue Include event_id when /state/:type[/:key]?format=event Dec 21, 2023
@matrixbot matrixbot reopened this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant