2020-04-29 11:34:31 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// FederationSenderInternalAPI is used to query information from the federation sender.
|
|
|
|
type FederationSenderInternalAPI interface {
|
2020-05-04 13:53:47 +01:00
|
|
|
// PerformDirectoryLookup looks up a remote room ID from a room alias.
|
|
|
|
PerformDirectoryLookup(
|
|
|
|
ctx context.Context,
|
|
|
|
request *PerformDirectoryLookupRequest,
|
|
|
|
response *PerformDirectoryLookupResponse,
|
|
|
|
) error
|
2020-04-29 11:34:31 +01:00
|
|
|
// 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.
|
|
|
|
QueryJoinedHostsInRoom(
|
|
|
|
ctx context.Context,
|
|
|
|
request *QueryJoinedHostsInRoomRequest,
|
|
|
|
response *QueryJoinedHostsInRoomResponse,
|
|
|
|
) error
|
|
|
|
// 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 15:29:39 +01:00
|
|
|
PerformJoin(
|
2020-04-29 11:34:31 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *PerformJoinRequest,
|
|
|
|
response *PerformJoinResponse,
|
|
|
|
) error
|
|
|
|
// Handle an instruction to make_leave & send_leave with a remote server.
|
2020-04-29 15:29:39 +01:00
|
|
|
PerformLeave(
|
2020-04-29 11:34:31 +01:00
|
|
|
ctx context.Context,
|
|
|
|
request *PerformLeaveRequest,
|
|
|
|
response *PerformLeaveResponse,
|
|
|
|
) error
|
2020-06-01 18:34:08 +01: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-04-29 11:34:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewFederationSenderInternalAPIHTTP creates a FederationSenderInternalAPI implemented by talking to a HTTP POST API.
|
|
|
|
// If httpClient is nil an error is returned
|
|
|
|
func NewFederationSenderInternalAPIHTTP(federationSenderURL string, httpClient *http.Client) (FederationSenderInternalAPI, error) {
|
|
|
|
if httpClient == nil {
|
|
|
|
return nil, errors.New("NewFederationSenderInternalAPIHTTP: httpClient is <nil>")
|
|
|
|
}
|
|
|
|
return &httpFederationSenderInternalAPI{federationSenderURL, httpClient}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type httpFederationSenderInternalAPI struct {
|
|
|
|
federationSenderURL string
|
|
|
|
httpClient *http.Client
|
|
|
|
}
|