mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 10:33:11 -06:00
Refactor PerformJoin to use the new gmsl interface
This commit is contained in:
parent
53787d539d
commit
2f7d4cb2d2
|
|
@ -16,6 +16,7 @@ import (
|
|||
// FederationInternalAPI is used to query information from the federation sender.
|
||||
type FederationInternalAPI interface {
|
||||
gomatrixserverlib.FederatedStateClient
|
||||
gomatrixserverlib.FederatedJoinClient
|
||||
KeyserverFederationAPI
|
||||
gomatrixserverlib.KeyDatabase
|
||||
ClientFederationAPI
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ func (f *fedClient) GetServerKeys(ctx context.Context, matrixServer spec.ServerN
|
|||
}
|
||||
|
||||
func (f *fedClient) MakeJoin(ctx context.Context, origin, s spec.ServerName, roomID, userID string) (res fclient.RespMakeJoin, err error) {
|
||||
f.fedClientMutex.Lock()
|
||||
defer f.fedClientMutex.Unlock()
|
||||
for _, r := range f.allowJoins {
|
||||
if r.ID == roomID {
|
||||
res.RoomVersion = r.Version
|
||||
|
|
|
|||
|
|
@ -12,6 +12,36 @@ import (
|
|||
// Functions here are "proxying" calls to the gomatrixserverlib federation
|
||||
// client.
|
||||
|
||||
func (a *FederationInternalAPI) MakeJoin(
|
||||
ctx context.Context, origin, s spec.ServerName, roomID, userID string,
|
||||
) (res gomatrixserverlib.MakeJoinResponse, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.MakeJoin(ctx, origin, s, roomID, userID)
|
||||
})
|
||||
if err != nil {
|
||||
return &fclient.RespMakeJoin{}, err
|
||||
}
|
||||
r := ires.(fclient.RespMakeJoin)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (a *FederationInternalAPI) SendJoin(
|
||||
ctx context.Context, origin, s spec.ServerName, event *gomatrixserverlib.Event,
|
||||
) (res gomatrixserverlib.SendJoinResponse, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.SendJoin(ctx, origin, s, event)
|
||||
})
|
||||
if err != nil {
|
||||
return &fclient.RespSendJoin{}, err
|
||||
}
|
||||
r := ires.(fclient.RespSendJoin)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (a *FederationInternalAPI) GetEventAuth(
|
||||
ctx context.Context, origin, s spec.ServerName,
|
||||
roomVersion gomatrixserverlib.RoomVersion, roomID, eventID string,
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ func (r *FederationInternalAPI) performJoinUsingServer(
|
|||
return err
|
||||
}
|
||||
|
||||
joinInput := fclient.PerformJoinInput{
|
||||
joinInput := gomatrixserverlib.PerformJoinInput{
|
||||
UserID: user,
|
||||
RoomID: roomID,
|
||||
ServerName: serverName,
|
||||
|
|
@ -161,7 +161,7 @@ func (r *FederationInternalAPI) performJoinUsingServer(
|
|||
KeyRing: r.keyRing,
|
||||
EventProvider: federatedEventProvider(ctx, r.federation, r.keyRing, user.Domain(), serverName),
|
||||
}
|
||||
response, joinErr := fclient.PerformJoin(ctx, r.federation, joinInput)
|
||||
response, joinErr := gomatrixserverlib.PerformJoin(ctx, r, joinInput)
|
||||
|
||||
if err != nil {
|
||||
if !joinErr.Reachable {
|
||||
|
|
|
|||
Loading…
Reference in a new issue