From 55a01df5c905dca2c0c32db14b82628bb43a79b0 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Thu, 23 Nov 2023 12:51:50 +0100 Subject: [PATCH] Fix oopps --- federationapi/routing/leave.go | 23 +++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/federationapi/routing/leave.go b/federationapi/routing/leave.go index 98a5810f0..c4b46af93 100644 --- a/federationapi/routing/leave.go +++ b/federationapi/routing/leave.go @@ -176,6 +176,29 @@ func SendLeave( keys gomatrixserverlib.JSONVerifier, roomID, eventID string, ) util.JSONResponse { + parsedRoomID, err := spec.NewRoomID(roomID) + if err != nil { + return util.JSONResponse{ + Code: http.StatusInternalServerError, + JSON: spec.InternalServerError{}, + } + } + roomInfo, err := rsAPI.QueryRoomInfo(httpReq.Context(), *parsedRoomID) + if err != nil { + return util.JSONResponse{ + Code: http.StatusInternalServerError, + JSON: spec.InternalServerError{}, + } + } + // Either the room does not exist or does not + // have any events. + if roomInfo == nil || roomInfo.IsStub() { + return util.JSONResponse{ + Code: http.StatusOK, + JSON: struct{}{}, + } + } + roomVersion, err := rsAPI.QueryRoomVersionForRoom(httpReq.Context(), roomID) if err != nil { return util.JSONResponse{ diff --git a/go.mod b/go.mod index 7b709a88e..709e679b8 100644 --- a/go.mod +++ b/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-20231123112137-2369defc080e + github.com/matrix-org/gomatrixserverlib v0.0.0-20231123113708-498c48650dc9 github.com/matrix-org/pinecone v0.11.1-0.20230810010612-ea4c33717fd7 github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 github.com/mattn/go-sqlite3 v1.14.17 diff --git a/go.sum b/go.sum index 213a5f166..13960a796 100644 --- a/go.sum +++ b/go.sum @@ -208,8 +208,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-20231123112137-2369defc080e h1:+E3txSR4+DEo39eoTlVxo9lNXfjJ8f8iXsyYwr1Yugs= -github.com/matrix-org/gomatrixserverlib v0.0.0-20231123112137-2369defc080e/go.mod h1:M8m7seOroO5ePlgxA7AFZymnG90Cnh94rYQyngSrZkk= +github.com/matrix-org/gomatrixserverlib v0.0.0-20231123113708-498c48650dc9 h1:jf2D3nqdpb/AWyKPeNScYMphaf0FnmoqdulKmTz8484= +github.com/matrix-org/gomatrixserverlib v0.0.0-20231123113708-498c48650dc9/go.mod h1:M8m7seOroO5ePlgxA7AFZymnG90Cnh94rYQyngSrZkk= github.com/matrix-org/pinecone v0.11.1-0.20230810010612-ea4c33717fd7 h1:6t8kJr8i1/1I5nNttw6nn1ryQJgzVlBmSGgPiiaTdw4= github.com/matrix-org/pinecone v0.11.1-0.20230810010612-ea4c33717fd7/go.mod h1:ReWMS/LoVnOiRAdq9sNUC2NZnd1mZkMNB52QhpTRWjg= github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=