From 0db85d21dc9abec23a9ba94c838abd8be4bf3771 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 14 Aug 2020 15:27:08 +0100 Subject: [PATCH] Fix client API return type for send invite error --- clientapi/routing/membership.go | 5 ++++- roomserver/api/wrapper.go | 2 +- roomserver/internal/perform_invite.go | 6 ++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go index fd11d2fc6..cda728dc3 100644 --- a/clientapi/routing/membership.go +++ b/clientapi/routing/membership.go @@ -223,7 +223,10 @@ func SendInvite( ) if err != nil { util.GetLogger(req.Context()).WithError(err).Error("roomserverAPI.SendInvite failed") - return jsonerror.InternalServerError() + return util.JSONResponse{ + Code: http.StatusForbidden, + JSON: jsonerror.Forbidden(err.Error()), + } } return util.JSONResponse{ Code: http.StatusOK, diff --git a/roomserver/api/wrapper.go b/roomserver/api/wrapper.go index 3a76d7783..00640d382 100644 --- a/roomserver/api/wrapper.go +++ b/roomserver/api/wrapper.go @@ -125,7 +125,7 @@ func SendInvite( Kind: KindNew, Event: inviteEvent, AuthEventIDs: inviteEvent.AuthEventIDs(), - SendAsServer: DoNotSendToOtherServers, + SendAsServer: string(sendAsServer), }, }, } diff --git a/roomserver/internal/perform_invite.go b/roomserver/internal/perform_invite.go index 8fa9db1f0..feef584d8 100644 --- a/roomserver/internal/perform_invite.go +++ b/roomserver/internal/perform_invite.go @@ -2,6 +2,7 @@ package internal import ( "context" + "errors" "fmt" federationSenderAPI "github.com/matrix-org/dendrite/federationsender/api" @@ -95,10 +96,7 @@ func (r *RoomserverInternalAPI) PerformInvite( // For now we will implement option 2. Since in the abesence of a retry // mechanism it will be equivalent to option 1, and we don't have a // signalling mechanism to implement option 3. - return &api.PerformError{ - Code: api.PerformErrorNoOperation, - Msg: "user is already joined to room", - } + return errors.New("The user is already in the room") } if isOriginLocal {