From 13f9028e7a63662759ce7c55504a9d2423058668 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 4 Jan 2022 15:47:14 +0000 Subject: [PATCH] Do the same for leave --- federationapi/routing/leave.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/federationapi/routing/leave.go b/federationapi/routing/leave.go index 38f4ca76..6312adfa 100644 --- a/federationapi/routing/leave.go +++ b/federationapi/routing/leave.go @@ -175,10 +175,16 @@ func SendLeave( } } - if event.StateKey() == nil { + if event.StateKey() == nil || event.StateKeyEquals("") { return util.JSONResponse{ Code: http.StatusBadRequest, - JSON: jsonerror.InvalidArgumentValue("missing state_key"), + JSON: jsonerror.BadJSON("No state key was provided in the leave event."), + } + } + if !event.StateKeyEquals(event.Sender()) { + return util.JSONResponse{ + Code: http.StatusBadRequest, + JSON: jsonerror.BadJSON("Event state key must match the event sender."), } }