Skip to main content

event_id_from_pdu

Function event_id_from_pdu 

Source
pub fn event_id_from_pdu(
    pdu: &RawValue,
    room_version: KnownRoomVersionId,
) -> Result<OwnedEventId, EventIdGenerationError>
Expand description

Resolves the event ID for a federation PDU.

Room versions 1 and 2 carry the event ID in the PDU. Later room versions derive it from the event’s reference hash.

See Matrix Specification v1.19, Server-Server API: https://spec.matrix.org/v1.19/server-server-api/#calculating-the-reference-hash-for-an-event.

§Errors

Returns EventIdGenerationError if the embedded event ID is missing or invalid, the PDU is not canonical JSON, or reference hash generation fails.