mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-10-09 19:22:47 +00:00
Roomserver perform join (#1001)
* Add PerformJoin template * Try roomserver perform join * Send correct server name to FS API * Pass through content, try to handle multiple server names * Fix local server checks * Don't refer to non-existent error * Add directory lookups of aliases * Remove unneeded parameters * Don't repeat join events into the roomserver * Unmarshal the content, that would help * Check if the user is already in the room in the fedeationapi too * Return incompatible room version error * Use Membership, don't try more servers than needed * Review comments, make FS API take list of servernames, dedupe them, break out of loop properly on success * Tweaks
This commit is contained in:
parent
36bbb25561
commit
5c894efd0e
12 changed files with 506 additions and 406 deletions
|
@ -8,6 +8,12 @@ import (
|
|||
|
||||
// FederationSenderInternalAPI is used to query information from the federation sender.
|
||||
type FederationSenderInternalAPI interface {
|
||||
// PerformDirectoryLookup looks up a remote room ID from a room alias.
|
||||
PerformDirectoryLookup(
|
||||
ctx context.Context,
|
||||
request *PerformDirectoryLookupRequest,
|
||||
response *PerformDirectoryLookupResponse,
|
||||
) error
|
||||
// Query the joined hosts and the membership events accounting for their participation in a room.
|
||||
// Note that if a server has multiple users in the room, it will have multiple entries in the returned slice.
|
||||
// See `QueryJoinedHostServerNamesInRoom` for a de-duplicated version.
|
||||
|
|
|
@ -4,11 +4,15 @@ import (
|
|||
"context"
|
||||
|
||||
commonHTTP "github.com/matrix-org/dendrite/common/http"
|
||||
"github.com/matrix-org/dendrite/federationsender/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
)
|
||||
|
||||
const (
|
||||
// FederationSenderPerformJoinRequestPath is the HTTP path for the PerformJoinRequest API.
|
||||
FederationSenderPerformDirectoryLookupRequestPath = "/api/federationsender/performDirectoryLookup"
|
||||
|
||||
// FederationSenderPerformJoinRequestPath is the HTTP path for the PerformJoinRequest API.
|
||||
FederationSenderPerformJoinRequestPath = "/api/federationsender/performJoinRequest"
|
||||
|
||||
|
@ -16,11 +20,34 @@ const (
|
|||
FederationSenderPerformLeaveRequestPath = "/api/federationsender/performLeaveRequest"
|
||||
)
|
||||
|
||||
type PerformJoinRequest struct {
|
||||
RoomID string `json:"room_id"`
|
||||
UserID string `json:"user_id"`
|
||||
type PerformDirectoryLookupRequest struct {
|
||||
RoomAlias string `json:"room_alias"`
|
||||
ServerName gomatrixserverlib.ServerName `json:"server_name"`
|
||||
Content map[string]interface{} `json:"content"`
|
||||
}
|
||||
|
||||
type PerformDirectoryLookupResponse struct {
|
||||
RoomID string `json:"room_id"`
|
||||
ServerNames []gomatrixserverlib.ServerName `json:"server_names"`
|
||||
}
|
||||
|
||||
// Handle an instruction to make_join & send_join with a remote server.
|
||||
func (h *httpFederationSenderInternalAPI) PerformDirectoryLookup(
|
||||
ctx context.Context,
|
||||
request *PerformDirectoryLookupRequest,
|
||||
response *PerformDirectoryLookupResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformDirectoryLookup")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.federationSenderURL + FederationSenderPerformDirectoryLookupRequestPath
|
||||
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
type PerformJoinRequest struct {
|
||||
RoomID string `json:"room_id"`
|
||||
UserID string `json:"user_id"`
|
||||
ServerNames types.ServerNames `json:"server_names"`
|
||||
Content map[string]interface{} `json:"content"`
|
||||
}
|
||||
|
||||
type PerformJoinResponse struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue