MCPcopy Create free account
hub / github.com/daodst/chat / fetchEvent

Function fetchEvent

federationapi/routing/events.go:85–102  ·  view source on GitHub ↗

fetchEvent fetches the event without auth checks. Returns an error if the event cannot be found.

(ctx context.Context, rsAPI api.FederationRoomserverAPI, eventID string)

Source from the content-addressed store, hash-verified

83
84// fetchEvent fetches the event without auth checks. Returns an error if the event cannot be found.
85func fetchEvent(ctx context.Context, rsAPI api.FederationRoomserverAPI, eventID string) (*gomatrixserverlib.Event, *util.JSONResponse) {
86 var eventsResponse api.QueryEventsByIDResponse
87 err := rsAPI.QueryEventsByID(
88 ctx,
89 &api.QueryEventsByIDRequest{EventIDs: []string{eventID}},
90 &eventsResponse,
91 )
92 if err != nil {
93 resErr := util.ErrorResponse(err)
94 return nil, &resErr
95 }
96
97 if len(eventsResponse.Events) == 0 {
98 return nil, &util.JSONResponse{Code: http.StatusNotFound, JSON: nil}
99 }
100
101 return eventsResponse.Events[0].Event, nil
102}

Callers 3

GetEventAuthFunction · 0.85
getStateFunction · 0.85
GetEventFunction · 0.85

Calls 1

QueryEventsByIDMethod · 0.65

Tested by

no test coverage detected