mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
Define component interfaces based on consumers (2/2) (#2425)
* convert remaining interfaces * Tidy up the userapi interfaces
This commit is contained in:
parent
e4da04e75b
commit
9957752a9d
42 changed files with 153 additions and 162 deletions
|
@ -33,7 +33,7 @@ import (
|
|||
func Backfill(
|
||||
httpReq *http.Request,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID string,
|
||||
cfg *config.FederationAPI,
|
||||
) util.JSONResponse {
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
func GetEventAuth(
|
||||
ctx context.Context,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID string,
|
||||
eventID string,
|
||||
) util.JSONResponse {
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
func GetEvent(
|
||||
ctx context.Context,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
eventID string,
|
||||
origin gomatrixserverlib.ServerName,
|
||||
) util.JSONResponse {
|
||||
|
@ -56,7 +56,7 @@ func GetEvent(
|
|||
func allowedToSeeEvent(
|
||||
ctx context.Context,
|
||||
origin gomatrixserverlib.ServerName,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
eventID string,
|
||||
) *util.JSONResponse {
|
||||
var authResponse api.QueryServerAllowedToSeeEventResponse
|
||||
|
@ -82,7 +82,7 @@ func allowedToSeeEvent(
|
|||
}
|
||||
|
||||
// fetchEvent fetches the event without auth checks. Returns an error if the event cannot be found.
|
||||
func fetchEvent(ctx context.Context, rsAPI api.RoomserverInternalAPI, eventID string) (*gomatrixserverlib.Event, *util.JSONResponse) {
|
||||
func fetchEvent(ctx context.Context, rsAPI api.FederationRoomserverAPI, eventID string) (*gomatrixserverlib.Event, *util.JSONResponse) {
|
||||
var eventsResponse api.QueryEventsByIDResponse
|
||||
err := rsAPI.QueryEventsByID(
|
||||
ctx,
|
||||
|
|
|
@ -35,7 +35,7 @@ func InviteV2(
|
|||
roomID string,
|
||||
eventID string,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
keys gomatrixserverlib.JSONVerifier,
|
||||
) util.JSONResponse {
|
||||
inviteReq := gomatrixserverlib.InviteV2Request{}
|
||||
|
@ -72,7 +72,7 @@ func InviteV1(
|
|||
roomID string,
|
||||
eventID string,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
keys gomatrixserverlib.JSONVerifier,
|
||||
) util.JSONResponse {
|
||||
roomVer := gomatrixserverlib.RoomVersionV1
|
||||
|
@ -110,7 +110,7 @@ func processInvite(
|
|||
roomID string,
|
||||
eventID string,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
keys gomatrixserverlib.JSONVerifier,
|
||||
) util.JSONResponse {
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func MakeJoin(
|
|||
httpReq *http.Request,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID, userID string,
|
||||
remoteVersions []gomatrixserverlib.RoomVersion,
|
||||
) util.JSONResponse {
|
||||
|
@ -165,7 +165,7 @@ func SendJoin(
|
|||
httpReq *http.Request,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
keys gomatrixserverlib.JSONVerifier,
|
||||
roomID, eventID string,
|
||||
) util.JSONResponse {
|
||||
|
|
|
@ -30,7 +30,7 @@ func MakeLeave(
|
|||
httpReq *http.Request,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID, userID string,
|
||||
) util.JSONResponse {
|
||||
_, domain, err := gomatrixserverlib.SplitID('@', userID)
|
||||
|
@ -122,7 +122,7 @@ func SendLeave(
|
|||
httpReq *http.Request,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
keys gomatrixserverlib.JSONVerifier,
|
||||
roomID, eventID string,
|
||||
) util.JSONResponse {
|
||||
|
|
|
@ -34,7 +34,7 @@ type getMissingEventRequest struct {
|
|||
func GetMissingEvents(
|
||||
httpReq *http.Request,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID string,
|
||||
) util.JSONResponse {
|
||||
var gme getMissingEventRequest
|
||||
|
|
|
@ -30,7 +30,7 @@ type openIDUserInfoResponse struct {
|
|||
// GetOpenIDUserInfo implements GET /_matrix/federation/v1/openid/userinfo
|
||||
func GetOpenIDUserInfo(
|
||||
httpReq *http.Request,
|
||||
userAPI userapi.UserInternalAPI,
|
||||
userAPI userapi.FederationUserAPI,
|
||||
) util.JSONResponse {
|
||||
token := httpReq.URL.Query().Get("access_token")
|
||||
if len(token) == 0 {
|
||||
|
|
|
@ -29,7 +29,7 @@ func Peek(
|
|||
httpReq *http.Request,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID, peekID string,
|
||||
remoteVersions []gomatrixserverlib.RoomVersion,
|
||||
) util.JSONResponse {
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
// GetProfile implements GET /_matrix/federation/v1/query/profile
|
||||
func GetProfile(
|
||||
httpReq *http.Request,
|
||||
userAPI userapi.UserInternalAPI,
|
||||
userAPI userapi.FederationUserAPI,
|
||||
cfg *config.FederationAPI,
|
||||
) util.JSONResponse {
|
||||
userID, field := httpReq.FormValue("user_id"), httpReq.FormValue("field")
|
||||
|
|
|
@ -23,7 +23,7 @@ type filter struct {
|
|||
}
|
||||
|
||||
// GetPostPublicRooms implements GET and POST /publicRooms
|
||||
func GetPostPublicRooms(req *http.Request, rsAPI roomserverAPI.RoomserverInternalAPI) util.JSONResponse {
|
||||
func GetPostPublicRooms(req *http.Request, rsAPI roomserverAPI.FederationRoomserverAPI) util.JSONResponse {
|
||||
var request PublicRoomReq
|
||||
if fillErr := fillPublicRoomsReq(req, &request); fillErr != nil {
|
||||
return *fillErr
|
||||
|
@ -42,7 +42,7 @@ func GetPostPublicRooms(req *http.Request, rsAPI roomserverAPI.RoomserverInterna
|
|||
}
|
||||
|
||||
func publicRooms(
|
||||
ctx context.Context, request PublicRoomReq, rsAPI roomserverAPI.RoomserverInternalAPI,
|
||||
ctx context.Context, request PublicRoomReq, rsAPI roomserverAPI.FederationRoomserverAPI,
|
||||
) (*gomatrixserverlib.RespPublicRooms, error) {
|
||||
|
||||
var response gomatrixserverlib.RespPublicRooms
|
||||
|
@ -111,7 +111,7 @@ func fillPublicRoomsReq(httpReq *http.Request, request *PublicRoomReq) *util.JSO
|
|||
}
|
||||
|
||||
// due to lots of switches
|
||||
func fillInRooms(ctx context.Context, roomIDs []string, rsAPI roomserverAPI.RoomserverInternalAPI) ([]gomatrixserverlib.PublicRoom, error) {
|
||||
func fillInRooms(ctx context.Context, roomIDs []string, rsAPI roomserverAPI.FederationRoomserverAPI) ([]gomatrixserverlib.PublicRoom, error) {
|
||||
avatarTuple := gomatrixserverlib.StateKeyTuple{EventType: "m.room.avatar", StateKey: ""}
|
||||
nameTuple := gomatrixserverlib.StateKeyTuple{EventType: "m.room.name", StateKey: ""}
|
||||
canonicalTuple := gomatrixserverlib.StateKeyTuple{EventType: gomatrixserverlib.MRoomCanonicalAlias, StateKey: ""}
|
||||
|
|
|
@ -32,7 +32,7 @@ func RoomAliasToID(
|
|||
httpReq *http.Request,
|
||||
federation *gomatrixserverlib.FederationClient,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI roomserverAPI.RoomserverInternalAPI,
|
||||
rsAPI roomserverAPI.FederationRoomserverAPI,
|
||||
senderAPI federationAPI.FederationInternalAPI,
|
||||
) util.JSONResponse {
|
||||
roomAlias := httpReq.FormValue("room_alias")
|
||||
|
|
|
@ -47,11 +47,11 @@ import (
|
|||
func Setup(
|
||||
fedMux, keyMux, wkMux *mux.Router,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI roomserverAPI.RoomserverInternalAPI,
|
||||
rsAPI roomserverAPI.FederationRoomserverAPI,
|
||||
fsAPI federationAPI.FederationInternalAPI,
|
||||
keys gomatrixserverlib.JSONVerifier,
|
||||
federation *gomatrixserverlib.FederationClient,
|
||||
userAPI userapi.UserInternalAPI,
|
||||
userAPI userapi.FederationUserAPI,
|
||||
keyAPI keyserverAPI.KeyInternalAPI,
|
||||
mscCfg *config.MSCs,
|
||||
servers federationAPI.ServersInRoomProvider,
|
||||
|
@ -497,7 +497,7 @@ func Setup(
|
|||
|
||||
func ErrorIfLocalServerNotInRoom(
|
||||
ctx context.Context,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID string,
|
||||
) *util.JSONResponse {
|
||||
// Check if we think we're in this room. If we aren't then
|
||||
|
|
|
@ -82,7 +82,7 @@ func Send(
|
|||
request *gomatrixserverlib.FederationRequest,
|
||||
txnID gomatrixserverlib.TransactionID,
|
||||
cfg *config.FederationAPI,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
keyAPI keyapi.KeyInternalAPI,
|
||||
keys gomatrixserverlib.JSONVerifier,
|
||||
federation *gomatrixserverlib.FederationClient,
|
||||
|
@ -182,7 +182,7 @@ func Send(
|
|||
|
||||
type txnReq struct {
|
||||
gomatrixserverlib.Transaction
|
||||
rsAPI api.RoomserverInternalAPI
|
||||
rsAPI api.FederationRoomserverAPI
|
||||
keyAPI keyapi.KeyInternalAPI
|
||||
ourServerName gomatrixserverlib.ServerName
|
||||
keys gomatrixserverlib.JSONVerifier
|
||||
|
|
|
@ -183,7 +183,7 @@ func (c *txnFedClient) LookupMissingEvents(ctx context.Context, s gomatrixserver
|
|||
return c.getMissingEvents(missing)
|
||||
}
|
||||
|
||||
func mustCreateTransaction(rsAPI api.RoomserverInternalAPI, fedClient txnFederationClient, pdus []json.RawMessage) *txnReq {
|
||||
func mustCreateTransaction(rsAPI api.FederationRoomserverAPI, fedClient txnFederationClient, pdus []json.RawMessage) *txnReq {
|
||||
t := &txnReq{
|
||||
rsAPI: rsAPI,
|
||||
keys: &test.NopJSONVerifier{},
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
func GetState(
|
||||
ctx context.Context,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID string,
|
||||
) util.JSONResponse {
|
||||
eventID, err := parseEventIDParam(request)
|
||||
|
@ -50,7 +50,7 @@ func GetState(
|
|||
func GetStateIDs(
|
||||
ctx context.Context,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID string,
|
||||
) util.JSONResponse {
|
||||
eventID, err := parseEventIDParam(request)
|
||||
|
@ -97,7 +97,7 @@ func parseEventIDParam(
|
|||
func getState(
|
||||
ctx context.Context,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
roomID string,
|
||||
eventID string,
|
||||
) (stateEvents, authEvents []*gomatrixserverlib.HeaderedEvent, errRes *util.JSONResponse) {
|
||||
|
|
|
@ -55,10 +55,10 @@ var (
|
|||
|
||||
// CreateInvitesFrom3PIDInvites implements POST /_matrix/federation/v1/3pid/onbind
|
||||
func CreateInvitesFrom3PIDInvites(
|
||||
req *http.Request, rsAPI api.RoomserverInternalAPI,
|
||||
req *http.Request, rsAPI api.FederationRoomserverAPI,
|
||||
cfg *config.FederationAPI,
|
||||
federation *gomatrixserverlib.FederationClient,
|
||||
userAPI userapi.UserInternalAPI,
|
||||
userAPI userapi.FederationUserAPI,
|
||||
) util.JSONResponse {
|
||||
var body invites
|
||||
if reqErr := httputil.UnmarshalJSONRequest(req, &body); reqErr != nil {
|
||||
|
@ -105,7 +105,7 @@ func ExchangeThirdPartyInvite(
|
|||
httpReq *http.Request,
|
||||
request *gomatrixserverlib.FederationRequest,
|
||||
roomID string,
|
||||
rsAPI api.RoomserverInternalAPI,
|
||||
rsAPI api.FederationRoomserverAPI,
|
||||
cfg *config.FederationAPI,
|
||||
federation *gomatrixserverlib.FederationClient,
|
||||
) util.JSONResponse {
|
||||
|
@ -203,10 +203,10 @@ func ExchangeThirdPartyInvite(
|
|||
// Returns an error if there was a problem building the event or fetching the
|
||||
// necessary data to do so.
|
||||
func createInviteFrom3PIDInvite(
|
||||
ctx context.Context, rsAPI api.RoomserverInternalAPI,
|
||||
ctx context.Context, rsAPI api.FederationRoomserverAPI,
|
||||
cfg *config.FederationAPI,
|
||||
inv invite, federation *gomatrixserverlib.FederationClient,
|
||||
userAPI userapi.UserInternalAPI,
|
||||
userAPI userapi.FederationUserAPI,
|
||||
) (*gomatrixserverlib.Event, error) {
|
||||
verReq := api.QueryRoomVersionForRoomRequest{RoomID: inv.RoomID}
|
||||
verRes := api.QueryRoomVersionForRoomResponse{}
|
||||
|
@ -270,7 +270,7 @@ func createInviteFrom3PIDInvite(
|
|||
// Returns an error if something failed during the process.
|
||||
func buildMembershipEvent(
|
||||
ctx context.Context,
|
||||
builder *gomatrixserverlib.EventBuilder, rsAPI api.RoomserverInternalAPI,
|
||||
builder *gomatrixserverlib.EventBuilder, rsAPI api.FederationRoomserverAPI,
|
||||
cfg *config.FederationAPI,
|
||||
) (*gomatrixserverlib.Event, error) {
|
||||
eventsNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(builder)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue