2017-04-20 22:40:52 +00:00
|
|
|
// Copyright 2017 Vector Creations Ltd
|
2020-02-05 18:06:39 +00:00
|
|
|
// Copyright 2018 New Vector Ltd
|
|
|
|
// Copyright 2019-2020 The Matrix.org Foundation C.I.C.
|
2017-04-20 22:40:52 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2017-03-06 14:29:39 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2017-09-13 12:37:50 +00:00
|
|
|
"context"
|
2017-07-12 13:13:10 +00:00
|
|
|
|
2020-05-21 13:40:13 +00:00
|
|
|
internalHTTP "github.com/matrix-org/dendrite/internal/http"
|
2017-07-12 13:13:10 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2020-05-20 15:04:31 +00:00
|
|
|
"github.com/matrix-org/util"
|
2018-07-17 14:36:04 +00:00
|
|
|
opentracing "github.com/opentracing/opentracing-go"
|
2017-03-06 14:29:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// QueryLatestEventsAndStateRequest is a request to QueryLatestEventsAndState
|
|
|
|
type QueryLatestEventsAndStateRequest struct {
|
2017-05-30 16:44:31 +00:00
|
|
|
// The room ID to query the latest events for.
|
2017-07-12 13:13:10 +00:00
|
|
|
RoomID string `json:"room_id"`
|
2017-03-06 14:29:39 +00:00
|
|
|
// The state key tuples to fetch from the room current state.
|
2020-05-05 14:48:37 +00:00
|
|
|
// If this list is empty or nil then *ALL* current state events are returned.
|
2017-07-12 13:13:10 +00:00
|
|
|
StateToFetch []gomatrixserverlib.StateKeyTuple `json:"state_to_fetch"`
|
2017-03-06 14:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryLatestEventsAndStateResponse is a response to QueryLatestEventsAndState
|
2017-06-27 14:28:44 +00:00
|
|
|
// This is used when sending events to set the prev_events, auth_events and depth.
|
|
|
|
// It is also used to tell whether the event is allowed by the event auth rules.
|
2017-03-06 14:29:39 +00:00
|
|
|
type QueryLatestEventsAndStateResponse struct {
|
|
|
|
// Copy of the request for debugging.
|
|
|
|
QueryLatestEventsAndStateRequest
|
|
|
|
// Does the room exist?
|
|
|
|
// If the room doesn't exist this will be false and LatestEvents will be empty.
|
2017-07-12 13:13:10 +00:00
|
|
|
RoomExists bool `json:"room_exists"`
|
2020-03-19 12:07:01 +00:00
|
|
|
// The room version of the room.
|
|
|
|
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
2017-03-06 14:29:39 +00:00
|
|
|
// The latest events in the room.
|
2017-06-27 14:28:44 +00:00
|
|
|
// These are used to set the prev_events when sending an event.
|
2017-07-12 13:13:10 +00:00
|
|
|
LatestEvents []gomatrixserverlib.EventReference `json:"latest_events"`
|
2017-03-06 14:29:39 +00:00
|
|
|
// The state events requested.
|
2017-06-02 13:32:36 +00:00
|
|
|
// This list will be in an arbitrary order.
|
2017-06-27 14:28:44 +00:00
|
|
|
// These are used to set the auth_events when sending an event.
|
|
|
|
// These are used to check whether the event is allowed.
|
2020-03-16 17:29:52 +00:00
|
|
|
StateEvents []gomatrixserverlib.HeaderedEvent `json:"state_events"`
|
2017-06-27 14:28:44 +00:00
|
|
|
// The 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.
|
2017-07-12 13:13:10 +00:00
|
|
|
Depth int64 `json:"depth"`
|
2017-03-06 14:29:39 +00:00
|
|
|
}
|
|
|
|
|
2017-05-30 16:44:31 +00:00
|
|
|
// QueryStateAfterEventsRequest is a request to QueryStateAfterEvents
|
|
|
|
type QueryStateAfterEventsRequest struct {
|
|
|
|
// The room ID to query the state in.
|
2017-07-12 13:13:10 +00:00
|
|
|
RoomID string `json:"room_id"`
|
2017-05-30 16:44:31 +00:00
|
|
|
// The list of previous events to return the events after.
|
2017-07-12 13:13:10 +00:00
|
|
|
PrevEventIDs []string `json:"prev_event_ids"`
|
2017-05-30 16:44:31 +00:00
|
|
|
// The state key tuples to fetch from the state
|
2017-07-12 13:13:10 +00:00
|
|
|
StateToFetch []gomatrixserverlib.StateKeyTuple `json:"state_to_fetch"`
|
2017-05-30 16:44:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryStateAfterEventsResponse is a response to QueryStateAfterEvents
|
|
|
|
type QueryStateAfterEventsResponse struct {
|
|
|
|
// Copy of the request for debugging.
|
|
|
|
QueryStateAfterEventsRequest
|
|
|
|
// Does the room exist on this roomserver?
|
|
|
|
// If the room doesn't exist this will be false and StateEvents will be empty.
|
2017-07-12 13:13:10 +00:00
|
|
|
RoomExists bool `json:"room_exists"`
|
2020-03-19 12:07:01 +00:00
|
|
|
// The room version of the room.
|
|
|
|
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
2017-05-30 16:44:31 +00:00
|
|
|
// 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.
|
2017-07-12 13:13:10 +00:00
|
|
|
PrevEventsExist bool `json:"prev_events_exist"`
|
2017-05-30 16:44:31 +00:00
|
|
|
// The state events requested.
|
2017-06-02 13:32:36 +00:00
|
|
|
// This list will be in an arbitrary order.
|
2020-03-16 17:29:52 +00:00
|
|
|
StateEvents []gomatrixserverlib.HeaderedEvent `json:"state_events"`
|
2017-05-30 16:44:31 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 13:32:36 +00:00
|
|
|
// QueryEventsByIDRequest is a request to QueryEventsByID
|
|
|
|
type QueryEventsByIDRequest struct {
|
|
|
|
// The event IDs to look up.
|
2017-07-12 13:13:10 +00:00
|
|
|
EventIDs []string `json:"event_ids"`
|
2017-06-02 13:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryEventsByIDResponse is a response to QueryEventsByID
|
|
|
|
type QueryEventsByIDResponse struct {
|
|
|
|
// Copy of the request for debugging.
|
|
|
|
QueryEventsByIDRequest
|
|
|
|
// A list of events with the requested IDs.
|
|
|
|
// If the roomserver does not have a copy of a requested event
|
|
|
|
// then it will omit that event from the list.
|
|
|
|
// If the roomserver thinks it has a copy of the event, but
|
|
|
|
// fails to read it from the database then it will fail
|
|
|
|
// the entire request.
|
|
|
|
// This list will be in an arbitrary order.
|
2020-03-16 17:29:52 +00:00
|
|
|
Events []gomatrixserverlib.HeaderedEvent `json:"events"`
|
2017-06-02 13:32:36 +00:00
|
|
|
}
|
|
|
|
|
2018-07-11 10:10:37 +00:00
|
|
|
// QueryMembershipForUserRequest is a request to QueryMembership
|
|
|
|
type QueryMembershipForUserRequest struct {
|
|
|
|
// ID of the room to fetch membership from
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
// ID of the user for whom membership is requested
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryMembershipForUserResponse is a response to QueryMembership
|
|
|
|
type QueryMembershipForUserResponse struct {
|
|
|
|
// The EventID of the latest "m.room.member" event for the sender,
|
|
|
|
// if HasBeenInRoom is true.
|
|
|
|
EventID string `json:"event_id"`
|
|
|
|
// True if the user has been in room before and has either stayed in it or left it.
|
|
|
|
HasBeenInRoom bool `json:"has_been_in_room"`
|
|
|
|
// True if the user is in room.
|
|
|
|
IsInRoom bool `json:"is_in_room"`
|
|
|
|
}
|
|
|
|
|
2017-08-21 15:34:26 +00:00
|
|
|
// QueryMembershipsForRoomRequest is a request to QueryMembershipsForRoom
|
|
|
|
type QueryMembershipsForRoomRequest struct {
|
2017-08-24 15:00:14 +00:00
|
|
|
// If true, only returns the membership events of "join" membership
|
|
|
|
JoinedOnly bool `json:"joined_only"`
|
2017-08-21 15:34:26 +00:00
|
|
|
// ID of the room to fetch memberships from
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
// ID of the user sending the request
|
|
|
|
Sender string `json:"sender"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryMembershipsForRoomResponse is a response to QueryMembershipsForRoom
|
|
|
|
type QueryMembershipsForRoomResponse struct {
|
|
|
|
// The "m.room.member" events (of "join" membership) in the client format
|
|
|
|
JoinEvents []gomatrixserverlib.ClientEvent `json:"join_events"`
|
|
|
|
// True if the user has been in room before and has either stayed in it or
|
|
|
|
// left it.
|
|
|
|
HasBeenInRoom bool `json:"has_been_in_room"`
|
|
|
|
}
|
|
|
|
|
2017-08-23 14:08:48 +00:00
|
|
|
// QueryInvitesForUserRequest is a request to QueryInvitesForUser
|
|
|
|
type QueryInvitesForUserRequest struct {
|
|
|
|
// The room ID to look up invites in.
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
// The User ID to look up invites for.
|
|
|
|
TargetUserID string `json:"target_user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryInvitesForUserResponse is a response to QueryInvitesForUser
|
|
|
|
// This is used when accepting an invite or rejecting a invite to tell which
|
|
|
|
// remote matrix servers to contact.
|
|
|
|
type QueryInvitesForUserResponse struct {
|
|
|
|
// A list of matrix user IDs for each sender of an active invite targeting
|
|
|
|
// the requested user ID.
|
|
|
|
InviteSenderUserIDs []string `json:"invite_sender_user_ids"`
|
|
|
|
}
|
|
|
|
|
2017-09-06 11:38:22 +00:00
|
|
|
// QueryServerAllowedToSeeEventRequest is a request to QueryServerAllowedToSeeEvent
|
|
|
|
type QueryServerAllowedToSeeEventRequest struct {
|
|
|
|
// The event ID to look up invites in.
|
|
|
|
EventID string `json:"event_id"`
|
|
|
|
// The server interested in the event
|
|
|
|
ServerName gomatrixserverlib.ServerName `json:"server_name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryServerAllowedToSeeEventResponse is a response to QueryServerAllowedToSeeEvent
|
|
|
|
type QueryServerAllowedToSeeEventResponse struct {
|
|
|
|
// Wether the server in question is allowed to see the event
|
|
|
|
AllowedToSeeEvent bool `json:"can_see_event"`
|
|
|
|
}
|
|
|
|
|
2018-06-26 10:25:49 +00:00
|
|
|
// QueryMissingEventsRequest is a request to QueryMissingEvents
|
|
|
|
type QueryMissingEventsRequest struct {
|
|
|
|
// Events which are known previous to the gap in the timeline.
|
|
|
|
EarliestEvents []string `json:"earliest_events"`
|
|
|
|
// Latest known events.
|
|
|
|
LatestEvents []string `json:"latest_events"`
|
|
|
|
// Limit the number of events this query returns.
|
|
|
|
Limit int `json:"limit"`
|
|
|
|
// The server interested in the event
|
|
|
|
ServerName gomatrixserverlib.ServerName `json:"server_name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryMissingEventsResponse is a response to QueryMissingEvents
|
|
|
|
type QueryMissingEventsResponse struct {
|
|
|
|
// Missing events, arbritrary order.
|
2020-03-16 17:29:52 +00:00
|
|
|
Events []gomatrixserverlib.HeaderedEvent `json:"events"`
|
2018-06-26 10:25:49 +00:00
|
|
|
}
|
|
|
|
|
2017-11-27 10:20:00 +00:00
|
|
|
// QueryStateAndAuthChainRequest is a request to QueryStateAndAuthChain
|
|
|
|
type QueryStateAndAuthChainRequest struct {
|
|
|
|
// The room ID to query the state in.
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
// The list of prev events for the event. Used to calculate the state at
|
|
|
|
// the event
|
|
|
|
PrevEventIDs []string `json:"prev_event_ids"`
|
|
|
|
// The list of auth events for the event. Used to calculate the auth chain
|
|
|
|
AuthEventIDs []string `json:"auth_event_ids"`
|
Federation for v3/v4 rooms (#954)
* Update gomatrixserverlib
* Default to room version 4
* Update gomatrixserverlib
* Limit prev_events and auth_events
* Fix auth_events, prev_events
* Fix linter issues
* Update gomatrixserverlib
* Fix getState
* Update sytest-whitelist
* Squashed commit of the following:
commit 067b87506357c996fd6ddb11271db9469ad4ce80
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Fri Apr 3 14:29:06 2020 +0100
Invites v2 endpoint (#952)
* Start converting v1 invite endpoint to v2
* Update gomatrixserverlib
* Early federationsender code for sending invites
* Sending invites sorta happens now
* Populate invite request with stripped state
* Remodel a bit, don't reflect received invites
* Handle invite_room_state
* Handle room versions a bit better
* Update gomatrixserverlib
* Tweak order in destinationQueue.next
* Revert check in processMessage
* Tweak federation sender destination queue code a bit
* Add comments
commit 955244c09298d0e6c870377dad3af2ffa1f5e578
Author: Ben B <benne@klimlive.de>
Date: Fri Apr 3 12:40:50 2020 +0200
use custom http client instead of the http DefaultClient (#823)
This commit replaces the default client from the http lib with a custom one.
The previously used default client doesn't come with a timeout. This could cause
unwanted locks.
That solution chosen here creates a http client in the base component dendrite
with a constant timeout of 30 seconds. If it should be necessary to overwrite
this, we could include the timeout in the dendrite configuration.
Here it would be a good idea to extend the type "Address" by a timeout and
create an http client for each service.
Closes #820
Signed-off-by: Benedikt Bongartz <benne@klimlive.de>
Co-authored-by: Kegsay <kegan@matrix.org>
* Update sytest-whitelist, sytest-blacklist
* Update go.mod/go.sum
* Add some error wrapping for debug
* Add a NOTSPEC to common/events.go
* Perform state resolution at send_join
* Set default room version to v2 again
* Tweak GetCapabilities
* Add comments to ResolveConflictsAdhoc
* Update sytest-blacklist
* go mod tidy
* Update sytest-whitelist, sytest-blacklist
* Update versions
* Updates from review comments
* Update sytest-blacklist, sytest-whitelist
* Check room versions compatible at make_join, add some comments, update gomatrixserverlib, other tweaks
* Set default room version back to v2
* Update gomatrixserverlib, sytest-whitelist
2020-04-09 14:46:06 +00:00
|
|
|
// Should state resolution be ran on the result events?
|
|
|
|
// TODO: check call sites and remove if we always want to do state res
|
|
|
|
ResolveState bool `json:"resolve_state"`
|
2017-11-27 10:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryStateAndAuthChainResponse is a response to QueryStateAndAuthChain
|
|
|
|
type QueryStateAndAuthChainResponse struct {
|
|
|
|
// Copy of the request for debugging.
|
|
|
|
QueryStateAndAuthChainRequest
|
|
|
|
// Does the room exist on this roomserver?
|
|
|
|
// If the room doesn't exist this will be false and StateEvents will be empty.
|
|
|
|
RoomExists bool `json:"room_exists"`
|
2020-03-19 12:07:01 +00:00
|
|
|
// The room version of the room.
|
|
|
|
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
2017-11-27 10:20:00 +00:00
|
|
|
// 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.
|
|
|
|
PrevEventsExist bool `json:"prev_events_exist"`
|
|
|
|
// The state and auth chain events that were requested.
|
|
|
|
// The lists will be in an arbitrary order.
|
2020-03-16 17:29:52 +00:00
|
|
|
StateEvents []gomatrixserverlib.HeaderedEvent `json:"state_events"`
|
|
|
|
AuthChainEvents []gomatrixserverlib.HeaderedEvent `json:"auth_chain_events"`
|
2017-11-27 10:20:00 +00:00
|
|
|
}
|
|
|
|
|
2018-11-07 11:38:01 +00:00
|
|
|
// QueryBackfillRequest is a request to QueryBackfill.
|
|
|
|
type QueryBackfillRequest struct {
|
2020-04-28 10:46:47 +00:00
|
|
|
// The room to backfill
|
|
|
|
RoomID string `json:"room_id"`
|
2020-05-20 15:04:31 +00:00
|
|
|
// A map of backwards extremity event ID to a list of its prev_event IDs.
|
|
|
|
BackwardsExtremities map[string][]string `json:"backwards_extremities"`
|
2018-11-07 11:38:01 +00:00
|
|
|
// The maximum number of events to retrieve.
|
|
|
|
Limit int `json:"limit"`
|
|
|
|
// The server interested in the events.
|
|
|
|
ServerName gomatrixserverlib.ServerName `json:"server_name"`
|
|
|
|
}
|
|
|
|
|
2020-05-20 15:04:31 +00:00
|
|
|
// PrevEventIDs returns the prev_event IDs of all backwards extremities, de-duplicated in a lexicographically sorted order.
|
|
|
|
func (r *QueryBackfillRequest) PrevEventIDs() []string {
|
|
|
|
var prevEventIDs []string
|
|
|
|
for _, pes := range r.BackwardsExtremities {
|
|
|
|
prevEventIDs = append(prevEventIDs, pes...)
|
|
|
|
}
|
|
|
|
prevEventIDs = util.UniqueStrings(prevEventIDs)
|
|
|
|
return prevEventIDs
|
|
|
|
}
|
|
|
|
|
2018-11-07 11:38:01 +00:00
|
|
|
// QueryBackfillResponse is a response to QueryBackfill.
|
|
|
|
type QueryBackfillResponse struct {
|
|
|
|
// Missing events, arbritrary order.
|
2020-03-16 17:29:52 +00:00
|
|
|
Events []gomatrixserverlib.HeaderedEvent `json:"events"`
|
2018-11-07 11:38:01 +00:00
|
|
|
}
|
|
|
|
|
2020-04-28 10:46:47 +00:00
|
|
|
// QueryRoomVersionCapabilitiesRequest asks for the default room version
|
2020-02-05 18:06:39 +00:00
|
|
|
type QueryRoomVersionCapabilitiesRequest struct{}
|
|
|
|
|
2020-03-19 12:07:01 +00:00
|
|
|
// QueryRoomVersionCapabilitiesResponse is a response to QueryRoomVersionCapabilitiesRequest
|
2020-02-05 18:06:39 +00:00
|
|
|
type QueryRoomVersionCapabilitiesResponse struct {
|
2020-03-19 12:07:01 +00:00
|
|
|
DefaultRoomVersion gomatrixserverlib.RoomVersion `json:"default"`
|
|
|
|
AvailableRoomVersions map[gomatrixserverlib.RoomVersion]string `json:"available"`
|
2020-02-05 18:06:39 +00:00
|
|
|
}
|
|
|
|
|
2020-04-28 10:46:47 +00:00
|
|
|
// QueryRoomVersionForRoomRequest asks for the room version for a given room.
|
2020-03-27 16:28:22 +00:00
|
|
|
type QueryRoomVersionForRoomRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
}
|
|
|
|
|
2020-04-28 10:46:47 +00:00
|
|
|
// QueryRoomVersionForRoomResponse is a response to QueryRoomVersionForRoomRequest
|
2020-03-27 16:28:22 +00:00
|
|
|
type QueryRoomVersionForRoomResponse struct {
|
|
|
|
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
|
|
|
}
|
|
|
|
|
2017-03-06 14:29:39 +00:00
|
|
|
// RoomserverQueryLatestEventsAndStatePath is the HTTP path for the QueryLatestEventsAndState API.
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryLatestEventsAndStatePath = "/roomserver/queryLatestEventsAndState"
|
2017-03-06 14:29:39 +00:00
|
|
|
|
2017-05-30 16:44:31 +00:00
|
|
|
// RoomserverQueryStateAfterEventsPath is the HTTP path for the QueryStateAfterEvents API.
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryStateAfterEventsPath = "/roomserver/queryStateAfterEvents"
|
2017-05-30 16:44:31 +00:00
|
|
|
|
2017-06-02 13:32:36 +00:00
|
|
|
// RoomserverQueryEventsByIDPath is the HTTP path for the QueryEventsByID API.
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryEventsByIDPath = "/roomserver/queryEventsByID"
|
2017-06-02 13:32:36 +00:00
|
|
|
|
2018-07-11 10:10:37 +00:00
|
|
|
// RoomserverQueryMembershipForUserPath is the HTTP path for the QueryMembershipForUser API.
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryMembershipForUserPath = "/roomserver/queryMembershipForUser"
|
2018-07-11 10:10:37 +00:00
|
|
|
|
2017-08-21 15:34:26 +00:00
|
|
|
// RoomserverQueryMembershipsForRoomPath is the HTTP path for the QueryMembershipsForRoom API
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryMembershipsForRoomPath = "/roomserver/queryMembershipsForRoom"
|
2017-08-21 15:34:26 +00:00
|
|
|
|
2017-08-23 14:08:48 +00:00
|
|
|
// RoomserverQueryInvitesForUserPath is the HTTP path for the QueryInvitesForUser API
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryInvitesForUserPath = "/roomserver/queryInvitesForUser"
|
2017-08-23 14:08:48 +00:00
|
|
|
|
2017-09-06 11:38:22 +00:00
|
|
|
// RoomserverQueryServerAllowedToSeeEventPath is the HTTP path for the QueryServerAllowedToSeeEvent API
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryServerAllowedToSeeEventPath = "/roomserver/queryServerAllowedToSeeEvent"
|
2017-09-06 11:38:22 +00:00
|
|
|
|
2018-06-26 10:25:49 +00:00
|
|
|
// RoomserverQueryMissingEventsPath is the HTTP path for the QueryMissingEvents API
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryMissingEventsPath = "/roomserver/queryMissingEvents"
|
2018-06-26 10:25:49 +00:00
|
|
|
|
2017-11-27 10:20:00 +00:00
|
|
|
// RoomserverQueryStateAndAuthChainPath is the HTTP path for the QueryStateAndAuthChain API
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryStateAndAuthChainPath = "/roomserver/queryStateAndAuthChain"
|
2017-11-27 10:20:00 +00:00
|
|
|
|
2020-01-23 17:51:10 +00:00
|
|
|
// RoomserverQueryBackfillPath is the HTTP path for the QueryBackfillPath API
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryBackfillPath = "/roomserver/queryBackfill"
|
2020-01-23 17:51:10 +00:00
|
|
|
|
2020-02-05 18:06:39 +00:00
|
|
|
// RoomserverQueryRoomVersionCapabilitiesPath is the HTTP path for the QueryRoomVersionCapabilities API
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryRoomVersionCapabilitiesPath = "/roomserver/queryRoomVersionCapabilities"
|
2020-02-05 18:06:39 +00:00
|
|
|
|
2020-04-28 10:46:47 +00:00
|
|
|
// RoomserverQueryRoomVersionForRoomPath is the HTTP path for the QueryRoomVersionForRoom API
|
2020-05-22 10:43:17 +00:00
|
|
|
const RoomserverQueryRoomVersionForRoomPath = "/roomserver/queryRoomVersionForRoom"
|
2020-03-27 16:28:22 +00:00
|
|
|
|
2017-03-06 14:29:39 +00:00
|
|
|
// QueryLatestEventsAndState implements RoomserverQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryLatestEventsAndState(
|
2017-09-13 12:37:50 +00:00
|
|
|
ctx context.Context,
|
2017-03-06 14:29:39 +00:00
|
|
|
request *QueryLatestEventsAndStateRequest,
|
|
|
|
response *QueryLatestEventsAndStateResponse,
|
|
|
|
) error {
|
2017-09-28 13:50:40 +00:00
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryLatestEventsAndState")
|
|
|
|
defer span.Finish()
|
|
|
|
|
2017-03-06 14:29:39 +00:00
|
|
|
apiURL := h.roomserverURL + RoomserverQueryLatestEventsAndStatePath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2017-03-06 14:29:39 +00:00
|
|
|
}
|
|
|
|
|
2017-05-30 16:44:31 +00:00
|
|
|
// QueryStateAfterEvents implements RoomserverQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryStateAfterEvents(
|
2017-09-13 12:37:50 +00:00
|
|
|
ctx context.Context,
|
2017-05-30 16:44:31 +00:00
|
|
|
request *QueryStateAfterEventsRequest,
|
|
|
|
response *QueryStateAfterEventsResponse,
|
|
|
|
) error {
|
2017-09-28 13:50:40 +00:00
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryStateAfterEvents")
|
|
|
|
defer span.Finish()
|
|
|
|
|
2017-05-30 16:44:31 +00:00
|
|
|
apiURL := h.roomserverURL + RoomserverQueryStateAfterEventsPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2017-05-30 16:44:31 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 13:32:36 +00:00
|
|
|
// QueryEventsByID implements RoomserverQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryEventsByID(
|
2017-09-13 12:37:50 +00:00
|
|
|
ctx context.Context,
|
2017-06-02 13:32:36 +00:00
|
|
|
request *QueryEventsByIDRequest,
|
|
|
|
response *QueryEventsByIDResponse,
|
|
|
|
) error {
|
2017-09-28 13:50:40 +00:00
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryEventsByID")
|
|
|
|
defer span.Finish()
|
|
|
|
|
2017-06-02 13:32:36 +00:00
|
|
|
apiURL := h.roomserverURL + RoomserverQueryEventsByIDPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2017-06-02 13:32:36 +00:00
|
|
|
}
|
|
|
|
|
2018-07-11 10:10:37 +00:00
|
|
|
// QueryMembershipForUser implements RoomserverQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryMembershipForUser(
|
2018-07-11 10:10:37 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *QueryMembershipForUserRequest,
|
|
|
|
response *QueryMembershipForUserResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryMembershipForUser")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.roomserverURL + RoomserverQueryMembershipForUserPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2018-07-11 10:10:37 +00:00
|
|
|
}
|
|
|
|
|
2017-08-21 15:34:26 +00:00
|
|
|
// QueryMembershipsForRoom implements RoomserverQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryMembershipsForRoom(
|
2017-09-13 12:37:50 +00:00
|
|
|
ctx context.Context,
|
2017-08-21 15:34:26 +00:00
|
|
|
request *QueryMembershipsForRoomRequest,
|
|
|
|
response *QueryMembershipsForRoomResponse,
|
|
|
|
) error {
|
2017-09-28 13:50:40 +00:00
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryMembershipsForRoom")
|
|
|
|
defer span.Finish()
|
|
|
|
|
2017-08-21 15:34:26 +00:00
|
|
|
apiURL := h.roomserverURL + RoomserverQueryMembershipsForRoomPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2017-08-21 15:34:26 +00:00
|
|
|
}
|
|
|
|
|
2017-08-23 14:08:48 +00:00
|
|
|
// QueryInvitesForUser implements RoomserverQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryInvitesForUser(
|
2017-09-13 12:37:50 +00:00
|
|
|
ctx context.Context,
|
2017-08-23 14:08:48 +00:00
|
|
|
request *QueryInvitesForUserRequest,
|
|
|
|
response *QueryInvitesForUserResponse,
|
|
|
|
) error {
|
2017-09-28 13:50:40 +00:00
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryInvitesForUser")
|
|
|
|
defer span.Finish()
|
|
|
|
|
2017-08-23 14:08:48 +00:00
|
|
|
apiURL := h.roomserverURL + RoomserverQueryInvitesForUserPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2017-08-23 14:08:48 +00:00
|
|
|
}
|
|
|
|
|
2017-09-06 11:38:22 +00:00
|
|
|
// QueryServerAllowedToSeeEvent implements RoomserverQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryServerAllowedToSeeEvent(
|
2017-09-13 12:37:50 +00:00
|
|
|
ctx context.Context,
|
2017-09-06 11:38:22 +00:00
|
|
|
request *QueryServerAllowedToSeeEventRequest,
|
|
|
|
response *QueryServerAllowedToSeeEventResponse,
|
2017-09-20 09:59:19 +00:00
|
|
|
) (err error) {
|
2017-09-28 13:50:40 +00:00
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryServerAllowedToSeeEvent")
|
|
|
|
defer span.Finish()
|
|
|
|
|
2017-09-06 11:38:22 +00:00
|
|
|
apiURL := h.roomserverURL + RoomserverQueryServerAllowedToSeeEventPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2017-09-06 11:38:22 +00:00
|
|
|
}
|
|
|
|
|
2018-06-26 10:25:49 +00:00
|
|
|
// QueryMissingEvents implements RoomServerQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryMissingEvents(
|
2018-06-26 10:25:49 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *QueryMissingEventsRequest,
|
|
|
|
response *QueryMissingEventsResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryMissingEvents")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.roomserverURL + RoomserverQueryMissingEventsPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2018-06-26 10:25:49 +00:00
|
|
|
}
|
|
|
|
|
2017-11-27 10:20:00 +00:00
|
|
|
// QueryStateAndAuthChain implements RoomserverQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryStateAndAuthChain(
|
2017-11-27 10:20:00 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *QueryStateAndAuthChainRequest,
|
|
|
|
response *QueryStateAndAuthChainResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryStateAndAuthChain")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.roomserverURL + RoomserverQueryStateAndAuthChainPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2017-03-06 14:29:39 +00:00
|
|
|
}
|
2018-11-07 11:38:01 +00:00
|
|
|
|
|
|
|
// QueryBackfill implements RoomServerQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryBackfill(
|
2018-11-07 11:38:01 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *QueryBackfillRequest,
|
|
|
|
response *QueryBackfillResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryBackfill")
|
|
|
|
defer span.Finish()
|
|
|
|
|
2019-12-20 15:00:25 +00:00
|
|
|
apiURL := h.roomserverURL + RoomserverQueryBackfillPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2018-11-07 11:38:01 +00:00
|
|
|
}
|
2020-01-23 17:51:10 +00:00
|
|
|
|
2020-03-19 12:07:01 +00:00
|
|
|
// QueryRoomVersionCapabilities implements RoomServerQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryRoomVersionCapabilities(
|
2020-02-05 18:06:39 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *QueryRoomVersionCapabilitiesRequest,
|
|
|
|
response *QueryRoomVersionCapabilitiesResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryRoomVersionCapabilities")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.roomserverURL + RoomserverQueryRoomVersionCapabilitiesPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2020-02-05 18:06:39 +00:00
|
|
|
}
|
2020-03-27 16:28:22 +00:00
|
|
|
|
|
|
|
// QueryRoomVersionForRoom implements RoomServerQueryAPI
|
2020-05-01 09:48:17 +00:00
|
|
|
func (h *httpRoomserverInternalAPI) QueryRoomVersionForRoom(
|
2020-03-27 16:28:22 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *QueryRoomVersionForRoomRequest,
|
|
|
|
response *QueryRoomVersionForRoomResponse,
|
|
|
|
) error {
|
2020-04-22 12:00:05 +00:00
|
|
|
if roomVersion, ok := h.immutableCache.GetRoomVersion(request.RoomID); ok {
|
|
|
|
response.RoomVersion = roomVersion
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:28:22 +00:00
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryRoomVersionForRoom")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.roomserverURL + RoomserverQueryRoomVersionForRoomPath
|
2020-05-21 13:40:13 +00:00
|
|
|
err := internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2020-04-22 12:00:05 +00:00
|
|
|
if err == nil {
|
|
|
|
h.immutableCache.StoreRoomVersion(request.RoomID, response.RoomVersion)
|
|
|
|
}
|
|
|
|
return err
|
2020-03-27 16:28:22 +00:00
|
|
|
}
|