2020-04-29 10:34:31 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-06-04 13:27:10 +00:00
|
|
|
|
|
|
|
"github.com/matrix-org/dendrite/federationsender/types"
|
2020-06-25 14:04:48 +00:00
|
|
|
"github.com/matrix-org/gomatrix"
|
2020-06-04 13:27:10 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2020-04-29 10:34:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// FederationSenderInternalAPI is used to query information from the federation sender.
|
|
|
|
type FederationSenderInternalAPI interface {
|
2020-05-04 12:53:47 +00:00
|
|
|
// PerformDirectoryLookup looks up a remote room ID from a room alias.
|
|
|
|
PerformDirectoryLookup(
|
|
|
|
ctx context.Context,
|
|
|
|
request *PerformDirectoryLookupRequest,
|
|
|
|
response *PerformDirectoryLookupResponse,
|
|
|
|
) error
|
2020-04-29 10:34:31 +00:00
|
|
|
// Query the server names of the joined hosts in a room.
|
|
|
|
// Unlike QueryJoinedHostsInRoom, this function returns a de-duplicated slice
|
|
|
|
// containing only the server names (without information for membership events).
|
|
|
|
QueryJoinedHostServerNamesInRoom(
|
|
|
|
ctx context.Context,
|
|
|
|
request *QueryJoinedHostServerNamesInRoomRequest,
|
|
|
|
response *QueryJoinedHostServerNamesInRoomResponse,
|
|
|
|
) error
|
|
|
|
// Handle an instruction to make_join & send_join with a remote server.
|
2020-04-29 14:29:39 +00:00
|
|
|
PerformJoin(
|
2020-04-29 10:34:31 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *PerformJoinRequest,
|
|
|
|
response *PerformJoinResponse,
|
2020-06-25 14:04:48 +00:00
|
|
|
)
|
2020-04-29 10:34:31 +00:00
|
|
|
// Handle an instruction to make_leave & send_leave with a remote server.
|
2020-04-29 14:29:39 +00:00
|
|
|
PerformLeave(
|
2020-04-29 10:34:31 +00:00
|
|
|
ctx context.Context,
|
|
|
|
request *PerformLeaveRequest,
|
|
|
|
response *PerformLeaveResponse,
|
|
|
|
) error
|
2020-08-17 10:40:49 +00:00
|
|
|
// Handle sending an invite to a remote server.
|
|
|
|
PerformInvite(
|
|
|
|
ctx context.Context,
|
|
|
|
request *PerformInviteRequest,
|
|
|
|
response *PerformInviteResponse,
|
|
|
|
) error
|
2020-06-01 17:34:08 +00:00
|
|
|
// Notifies the federation sender that these servers may be online and to retry sending messages.
|
|
|
|
PerformServersAlive(
|
|
|
|
ctx context.Context,
|
|
|
|
request *PerformServersAliveRequest,
|
|
|
|
response *PerformServersAliveResponse,
|
|
|
|
) error
|
2020-07-16 12:52:08 +00:00
|
|
|
// Broadcasts an EDU to all servers in rooms we are joined to.
|
|
|
|
PerformBroadcastEDU(
|
|
|
|
ctx context.Context,
|
|
|
|
request *PerformBroadcastEDURequest,
|
|
|
|
response *PerformBroadcastEDUResponse,
|
|
|
|
) error
|
2020-04-29 10:34:31 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 13:27:10 +00:00
|
|
|
type PerformDirectoryLookupRequest struct {
|
|
|
|
RoomAlias string `json:"room_alias"`
|
|
|
|
ServerName gomatrixserverlib.ServerName `json:"server_name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformDirectoryLookupResponse struct {
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
ServerNames []gomatrixserverlib.ServerName `json:"server_names"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformJoinRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
// The sorted list of servers to try. Servers will be tried sequentially, after de-duplication.
|
|
|
|
ServerNames types.ServerNames `json:"server_names"`
|
|
|
|
Content map[string]interface{} `json:"content"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformJoinResponse struct {
|
2020-06-25 14:04:48 +00:00
|
|
|
LastError *gomatrix.HTTPError
|
2020-06-04 13:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PerformLeaveRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
ServerNames types.ServerNames `json:"server_names"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformLeaveResponse struct {
|
|
|
|
}
|
|
|
|
|
2020-08-17 10:40:49 +00:00
|
|
|
type PerformInviteRequest struct {
|
|
|
|
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
|
|
|
Event gomatrixserverlib.HeaderedEvent `json:"event"`
|
|
|
|
InviteRoomState []gomatrixserverlib.InviteV2StrippedState `json:"invite_room_state"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformInviteResponse struct {
|
|
|
|
Event gomatrixserverlib.HeaderedEvent `json:"event"`
|
|
|
|
}
|
|
|
|
|
2020-06-04 13:27:10 +00:00
|
|
|
type PerformServersAliveRequest struct {
|
|
|
|
Servers []gomatrixserverlib.ServerName
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformServersAliveResponse struct {
|
|
|
|
}
|
|
|
|
|
2020-06-11 14:07:16 +00:00
|
|
|
// QueryJoinedHostServerNamesInRoomRequest is a request to QueryJoinedHostServerNames
|
2020-06-04 13:27:10 +00:00
|
|
|
type QueryJoinedHostServerNamesInRoomRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
2020-04-29 10:34:31 +00:00
|
|
|
}
|
|
|
|
|
2020-06-11 14:07:16 +00:00
|
|
|
// QueryJoinedHostServerNamesInRoomResponse is a response to QueryJoinedHostServerNames
|
2020-06-04 13:27:10 +00:00
|
|
|
type QueryJoinedHostServerNamesInRoomResponse struct {
|
|
|
|
ServerNames []gomatrixserverlib.ServerName `json:"server_names"`
|
2020-04-29 10:34:31 +00:00
|
|
|
}
|
2020-07-16 12:52:08 +00:00
|
|
|
|
|
|
|
type PerformBroadcastEDURequest struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformBroadcastEDUResponse struct {
|
|
|
|
}
|