Add custom error for rejecting server notice invite

This commit is contained in:
Till Faelligen 2022-02-18 10:11:55 +01:00
parent 2e1e0c81a1
commit 2dc7088de2
2 changed files with 10 additions and 1 deletions

View file

@ -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"`

View file

@ -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{