Fix client API return type for send invite error

This commit is contained in:
Neil Alexander 2020-08-14 15:27:08 +01:00
parent db57d7e00b
commit 0db85d21dc
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 7 additions and 6 deletions

View file

@ -223,7 +223,10 @@ func SendInvite(
) )
if err != nil { if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("roomserverAPI.SendInvite failed") 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{ return util.JSONResponse{
Code: http.StatusOK, Code: http.StatusOK,

View file

@ -125,7 +125,7 @@ func SendInvite(
Kind: KindNew, Kind: KindNew,
Event: inviteEvent, Event: inviteEvent,
AuthEventIDs: inviteEvent.AuthEventIDs(), AuthEventIDs: inviteEvent.AuthEventIDs(),
SendAsServer: DoNotSendToOtherServers, SendAsServer: string(sendAsServer),
}, },
}, },
} }

View file

@ -2,6 +2,7 @@ package internal
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
federationSenderAPI "github.com/matrix-org/dendrite/federationsender/api" 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 // 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 // mechanism it will be equivalent to option 1, and we don't have a
// signalling mechanism to implement option 3. // signalling mechanism to implement option 3.
return &api.PerformError{ return errors.New("The user is already in the room")
Code: api.PerformErrorNoOperation,
Msg: "user is already joined to room",
}
} }
if isOriginLocal { if isOriginLocal {