From 72022a6ecf80177a28883d7016790ea41646d396 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 3 Mar 2022 17:58:24 +0000 Subject: [PATCH 1/2] Return 404 if event given to `/context` was not found (#2245) --- syncapi/routing/context.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/syncapi/routing/context.go b/syncapi/routing/context.go index 591139717..d07fc0c64 100644 --- a/syncapi/routing/context.go +++ b/syncapi/routing/context.go @@ -17,6 +17,7 @@ package routing import ( "database/sql" "encoding/json" + "fmt" "net/http" "strconv" @@ -102,6 +103,12 @@ func Context( id, requestedEvent, err := syncDB.SelectContextEvent(ctx, roomID, eventID) if err != nil { + if err == sql.ErrNoRows { + return util.JSONResponse{ + Code: http.StatusNotFound, + JSON: jsonerror.NotFound(fmt.Sprintf("Event %s not found", eventID)), + } + } logrus.WithError(err).WithField("eventID", eventID).Error("unable to find requested event") return jsonerror.InternalServerError() } From f75169c3535488ac584c4e270bc9e6b0cb69e539 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 3 Mar 2022 18:24:14 +0000 Subject: [PATCH 2/2] Send profile updates asynchronously (#2246) --- clientapi/routing/profile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clientapi/routing/profile.go b/clientapi/routing/profile.go index 717cbda75..4aab03714 100644 --- a/clientapi/routing/profile.go +++ b/clientapi/routing/profile.go @@ -286,7 +286,7 @@ func SetDisplayName( return jsonerror.InternalServerError() } - if err := api.SendEvents(req.Context(), rsAPI, api.KindNew, events, cfg.Matrix.ServerName, cfg.Matrix.ServerName, nil, false); err != nil { + if err := api.SendEvents(req.Context(), rsAPI, api.KindNew, events, cfg.Matrix.ServerName, cfg.Matrix.ServerName, nil, true); err != nil { util.GetLogger(req.Context()).WithError(err).Error("SendEvents failed") return jsonerror.InternalServerError() }