From 2dc7088de2373a3a1cfa7a31193a3d736b314b83 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Fri, 18 Feb 2022 10:11:55 +0100 Subject: [PATCH] Add custom error for rejecting server notice invite --- clientapi/jsonerror/jsonerror.go | 9 +++++++++ clientapi/routing/leaveroom.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clientapi/jsonerror/jsonerror.go b/clientapi/jsonerror/jsonerror.go index caa216e62..97c597030 100644 --- a/clientapi/jsonerror/jsonerror.go +++ b/clientapi/jsonerror/jsonerror.go @@ -149,6 +149,15 @@ func MissingParam(msg string) *MatrixError { return &MatrixError{"M_MISSING_PARAM", msg} } +// LeaveServerNoticeError is an error returned when trying to reject an invite +// for a server notice room. +func LeaveServerNoticeError() *MatrixError { + return &MatrixError{ + ErrCode: "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM", + Err: "You cannot reject this invite", + } +} + type IncompatibleRoomVersionError struct { RoomVersion string `json:"room_version"` Error string `json:"error"` diff --git a/clientapi/routing/leaveroom.go b/clientapi/routing/leaveroom.go index f40b4d85a..a34dd02d3 100644 --- a/clientapi/routing/leaveroom.go +++ b/clientapi/routing/leaveroom.go @@ -41,7 +41,7 @@ func LeaveRoomByID( if leaveRes.Code != 0 { return util.JSONResponse{ Code: leaveRes.Code, - JSON: jsonerror.Forbidden(leaveRes.Message), + JSON: jsonerror.LeaveServerNoticeError(), } } return util.JSONResponse{