mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-11 16:13:10 -06:00
Pull context out of invite input structs
This commit is contained in:
parent
d93f03c445
commit
a4fc905f8d
|
|
@ -15,6 +15,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
|
@ -76,7 +77,6 @@ func InviteV2(
|
|||
}
|
||||
|
||||
input := gomatrixserverlib.HandleInviteInput{
|
||||
Context: httpReq.Context(),
|
||||
RoomVersion: inviteReq.RoomVersion(),
|
||||
RoomID: roomID,
|
||||
EventID: eventID,
|
||||
|
|
@ -90,7 +90,7 @@ func InviteV2(
|
|||
InviteEvent: inviteReq.Event(),
|
||||
StrippedState: inviteReq.InviteRoomState(),
|
||||
}
|
||||
event, jsonErr := handleInvite(input, rsAPI)
|
||||
event, jsonErr := handleInvite(httpReq.Context(), input, rsAPI)
|
||||
if jsonErr != nil {
|
||||
return *jsonErr
|
||||
}
|
||||
|
|
@ -161,7 +161,6 @@ func InviteV1(
|
|||
}
|
||||
|
||||
input := gomatrixserverlib.HandleInviteInput{
|
||||
Context: httpReq.Context(),
|
||||
RoomVersion: roomVer,
|
||||
RoomID: roomID,
|
||||
EventID: eventID,
|
||||
|
|
@ -175,7 +174,7 @@ func InviteV1(
|
|||
InviteEvent: event,
|
||||
StrippedState: strippedState,
|
||||
}
|
||||
event, jsonErr := handleInvite(input, rsAPI)
|
||||
event, jsonErr := handleInvite(httpReq.Context(), input, rsAPI)
|
||||
if jsonErr != nil {
|
||||
return *jsonErr
|
||||
}
|
||||
|
|
@ -185,18 +184,18 @@ func InviteV1(
|
|||
}
|
||||
}
|
||||
|
||||
func handleInvite(input gomatrixserverlib.HandleInviteInput, rsAPI api.FederationRoomserverAPI) (gomatrixserverlib.PDU, *util.JSONResponse) {
|
||||
inviteEvent, err := gomatrixserverlib.HandleInvite(input)
|
||||
func handleInvite(ctx context.Context, input gomatrixserverlib.HandleInviteInput, rsAPI api.FederationRoomserverAPI) (gomatrixserverlib.PDU, *util.JSONResponse) {
|
||||
inviteEvent, err := gomatrixserverlib.HandleInvite(ctx, input)
|
||||
switch e := err.(type) {
|
||||
case nil:
|
||||
case spec.InternalServerError:
|
||||
util.GetLogger(input.Context).WithError(err)
|
||||
util.GetLogger(ctx).WithError(err)
|
||||
return nil, &util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: spec.InternalServerError{},
|
||||
}
|
||||
case spec.MatrixError:
|
||||
util.GetLogger(input.Context).WithError(err)
|
||||
util.GetLogger(ctx).WithError(err)
|
||||
code := http.StatusInternalServerError
|
||||
switch e.ErrCode {
|
||||
case spec.ErrorForbidden:
|
||||
|
|
@ -212,7 +211,7 @@ func handleInvite(input gomatrixserverlib.HandleInviteInput, rsAPI api.Federatio
|
|||
JSON: e,
|
||||
}
|
||||
default:
|
||||
util.GetLogger(input.Context).WithError(err)
|
||||
util.GetLogger(ctx).WithError(err)
|
||||
return nil, &util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: spec.Unknown("unknown error"),
|
||||
|
|
@ -220,8 +219,8 @@ func handleInvite(input gomatrixserverlib.HandleInviteInput, rsAPI api.Federatio
|
|||
}
|
||||
|
||||
headeredInvite := &types.HeaderedEvent{PDU: inviteEvent}
|
||||
if err = rsAPI.HandleInvite(input.Context, headeredInvite); err != nil {
|
||||
util.GetLogger(input.Context).WithError(err).Error("HandleInvite failed")
|
||||
if err = rsAPI.HandleInvite(ctx, headeredInvite); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("HandleInvite failed")
|
||||
return nil, &util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: spec.InternalServerError{},
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -22,7 +22,7 @@ require (
|
|||
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524155842-456850e19e68
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524162524-cfd2b5c1046f
|
||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a
|
||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -323,8 +323,8 @@ github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91 h1:s7fexw
|
|||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo=
|
||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U=
|
||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524155842-456850e19e68 h1:Zf62GOLrN2VqifAreL5xjmnSKe7uz9J+ttj7AdeJ8ts=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524155842-456850e19e68/go.mod h1:H9V9N3Uqn1bBJqYJNGK1noqtgJTaCEhtTdcH/mp50uU=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524162524-cfd2b5c1046f h1:64K53Gd4mPI9FBWAUV9KhSOrgC33JBxj5d0A2k8iID8=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524162524-cfd2b5c1046f/go.mod h1:H9V9N3Uqn1bBJqYJNGK1noqtgJTaCEhtTdcH/mp50uU=
|
||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a h1:awrPDf9LEFySxTLKYBMCiObelNx/cBuv/wzllvCCH3A=
|
||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a/go.mod h1:HchJX9oKMXaT2xYFs0Ha/6Zs06mxLU8k6F1ODnrGkeQ=
|
||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
|
||||
|
|
|
|||
|
|
@ -149,7 +149,6 @@ func (r *Inviter) PerformInvite(
|
|||
}
|
||||
|
||||
input := gomatrixserverlib.PerformInviteInput{
|
||||
Context: ctx,
|
||||
RoomID: *validRoomID,
|
||||
Event: event.PDU,
|
||||
InvitedUser: *invitedUser,
|
||||
|
|
@ -158,7 +157,7 @@ func (r *Inviter) PerformInvite(
|
|||
MembershipQuerier: &api.MembershipQuerier{Roomserver: r.RSAPI},
|
||||
StateQuerier: &QueryState{r.DB},
|
||||
}
|
||||
inviteEvent, err := gomatrixserverlib.PerformInvite(input, r.FSAPI)
|
||||
inviteEvent, err := gomatrixserverlib.PerformInvite(ctx, input, r.FSAPI)
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case spec.MatrixError:
|
||||
|
|
|
|||
Loading…
Reference in a new issue