mirror of
https://github.com/matrix-org/dendrite
synced 2024-12-14 05:53:48 +01:00
Make the room server RPC API json formats more consistent with our other APIs (#156)
This commit is contained in:
parent
cea9e31723
commit
4e7862e3b9
1 changed files with 19 additions and 18 deletions
|
@ -18,17 +18,18 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryLatestEventsAndStateRequest is a request to QueryLatestEventsAndState
|
// QueryLatestEventsAndStateRequest is a request to QueryLatestEventsAndState
|
||||||
type QueryLatestEventsAndStateRequest struct {
|
type QueryLatestEventsAndStateRequest struct {
|
||||||
// The room ID to query the latest events for.
|
// The room ID to query the latest events for.
|
||||||
RoomID string
|
RoomID string `json:"room_id"`
|
||||||
// The state key tuples to fetch from the room current state.
|
// The state key tuples to fetch from the room current state.
|
||||||
// If this list is empty or nil then no state events are returned.
|
// If this list is empty or nil then no state events are returned.
|
||||||
StateToFetch []gomatrixserverlib.StateKeyTuple
|
StateToFetch []gomatrixserverlib.StateKeyTuple `json:"state_to_fetch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryLatestEventsAndStateResponse is a response to QueryLatestEventsAndState
|
// QueryLatestEventsAndStateResponse is a response to QueryLatestEventsAndState
|
||||||
|
@ -39,29 +40,29 @@ type QueryLatestEventsAndStateResponse struct {
|
||||||
QueryLatestEventsAndStateRequest
|
QueryLatestEventsAndStateRequest
|
||||||
// Does the room exist?
|
// Does the room exist?
|
||||||
// If the room doesn't exist this will be false and LatestEvents will be empty.
|
// If the room doesn't exist this will be false and LatestEvents will be empty.
|
||||||
RoomExists bool
|
RoomExists bool `json:"room_exists"`
|
||||||
// The latest events in the room.
|
// The latest events in the room.
|
||||||
// These are used to set the prev_events when sending an event.
|
// These are used to set the prev_events when sending an event.
|
||||||
LatestEvents []gomatrixserverlib.EventReference
|
LatestEvents []gomatrixserverlib.EventReference `json:"latest_events"`
|
||||||
// The state events requested.
|
// The state events requested.
|
||||||
// This list will be in an arbitrary order.
|
// This list will be in an arbitrary order.
|
||||||
// These are used to set the auth_events when sending an event.
|
// These are used to set the auth_events when sending an event.
|
||||||
// These are used to check whether the event is allowed.
|
// These are used to check whether the event is allowed.
|
||||||
StateEvents []gomatrixserverlib.Event
|
StateEvents []gomatrixserverlib.Event `json:"state_events"`
|
||||||
// The depth of the latest events.
|
// The depth of the latest events.
|
||||||
// This is one greater than the maximum depth of the latest events.
|
// This is one greater than the maximum depth of the latest events.
|
||||||
// This is used to set the depth when sending an event.
|
// This is used to set the depth when sending an event.
|
||||||
Depth int64
|
Depth int64 `json:"depth"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryStateAfterEventsRequest is a request to QueryStateAfterEvents
|
// QueryStateAfterEventsRequest is a request to QueryStateAfterEvents
|
||||||
type QueryStateAfterEventsRequest struct {
|
type QueryStateAfterEventsRequest struct {
|
||||||
// The room ID to query the state in.
|
// The room ID to query the state in.
|
||||||
RoomID string
|
RoomID string `json:"room_id"`
|
||||||
// The list of previous events to return the events after.
|
// The list of previous events to return the events after.
|
||||||
PrevEventIDs []string
|
PrevEventIDs []string `json:"prev_event_ids"`
|
||||||
// The state key tuples to fetch from the state
|
// The state key tuples to fetch from the state
|
||||||
StateToFetch []gomatrixserverlib.StateKeyTuple
|
StateToFetch []gomatrixserverlib.StateKeyTuple `json:"state_to_fetch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryStateAfterEventsResponse is a response to QueryStateAfterEvents
|
// QueryStateAfterEventsResponse is a response to QueryStateAfterEvents
|
||||||
|
@ -70,19 +71,19 @@ type QueryStateAfterEventsResponse struct {
|
||||||
QueryStateAfterEventsRequest
|
QueryStateAfterEventsRequest
|
||||||
// Does the room exist on this roomserver?
|
// Does the room exist on this roomserver?
|
||||||
// If the room doesn't exist this will be false and StateEvents will be empty.
|
// If the room doesn't exist this will be false and StateEvents will be empty.
|
||||||
RoomExists bool
|
RoomExists bool `json:"room_exists"`
|
||||||
// Do all the previous events exist on this roomserver?
|
// Do all the previous events exist on this roomserver?
|
||||||
// If some of previous events do not exist this will be false and StateEvents will be empty.
|
// If some of previous events do not exist this will be false and StateEvents will be empty.
|
||||||
PrevEventsExist bool
|
PrevEventsExist bool `json:"prev_events_exist"`
|
||||||
// The state events requested.
|
// The state events requested.
|
||||||
// This list will be in an arbitrary order.
|
// This list will be in an arbitrary order.
|
||||||
StateEvents []gomatrixserverlib.Event
|
StateEvents []gomatrixserverlib.Event `json:"state_events"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryEventsByIDRequest is a request to QueryEventsByID
|
// QueryEventsByIDRequest is a request to QueryEventsByID
|
||||||
type QueryEventsByIDRequest struct {
|
type QueryEventsByIDRequest struct {
|
||||||
// The event IDs to look up.
|
// The event IDs to look up.
|
||||||
EventIDs []string
|
EventIDs []string `json:"event_ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryEventsByIDResponse is a response to QueryEventsByID
|
// QueryEventsByIDResponse is a response to QueryEventsByID
|
||||||
|
@ -96,7 +97,7 @@ type QueryEventsByIDResponse struct {
|
||||||
// fails to read it from the database then it will fail
|
// fails to read it from the database then it will fail
|
||||||
// the entire request.
|
// the entire request.
|
||||||
// This list will be in an arbitrary order.
|
// This list will be in an arbitrary order.
|
||||||
Events []gomatrixserverlib.Event
|
Events []gomatrixserverlib.Event `json:"events"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoomserverQueryAPI is used to query information from the room server.
|
// RoomserverQueryAPI is used to query information from the room server.
|
||||||
|
@ -121,13 +122,13 @@ type RoomserverQueryAPI interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoomserverQueryLatestEventsAndStatePath is the HTTP path for the QueryLatestEventsAndState API.
|
// RoomserverQueryLatestEventsAndStatePath is the HTTP path for the QueryLatestEventsAndState API.
|
||||||
const RoomserverQueryLatestEventsAndStatePath = "/api/roomserver/QueryLatestEventsAndState"
|
const RoomserverQueryLatestEventsAndStatePath = "/api/roomserver/queryLatestEventsAndState"
|
||||||
|
|
||||||
// RoomserverQueryStateAfterEventsPath is the HTTP path for the QueryStateAfterEvents API.
|
// RoomserverQueryStateAfterEventsPath is the HTTP path for the QueryStateAfterEvents API.
|
||||||
const RoomserverQueryStateAfterEventsPath = "/api/roomserver/QueryStateAfterEvents"
|
const RoomserverQueryStateAfterEventsPath = "/api/roomserver/queryStateAfterEvents"
|
||||||
|
|
||||||
// RoomserverQueryEventsByIDPath is the HTTP path for the QueryEventsByID API.
|
// RoomserverQueryEventsByIDPath is the HTTP path for the QueryEventsByID API.
|
||||||
const RoomserverQueryEventsByIDPath = "/api/roomserver/QueryEventsByID"
|
const RoomserverQueryEventsByIDPath = "/api/roomserver/queryEventsByID"
|
||||||
|
|
||||||
// NewRoomserverQueryAPIHTTP creates a RoomserverQueryAPI implemented by talking to a HTTP POST API.
|
// NewRoomserverQueryAPIHTTP creates a RoomserverQueryAPI implemented by talking to a HTTP POST API.
|
||||||
// If httpClient is nil then it uses the http.DefaultClient
|
// If httpClient is nil then it uses the http.DefaultClient
|
||||||
|
|
Loading…
Reference in a new issue