From 8b5b1e78fc4c041b89e73ce8576d35f70adb943d Mon Sep 17 00:00:00 2001 From: Neboer <43609792+Neboer@users.noreply.github.com> Date: Tue, 25 Oct 2022 20:16:17 +0800 Subject: [PATCH] change defer to plain function, add judgement of whether user is a normal user or an app service user before autoJoinRooms. --- clientapi/routing/register.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 925e18611..b594c0bfb 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -973,8 +973,9 @@ func completeRegistration( } sessions.addCompletedRegistration(sessionID, result) - defer func() { - // POST register behavior: add user to room specified in the configuration "auto_join_rooms" + // POST register behaviour: check if the user is a normal user. + // If the user is a normal user, add user to room specified in the configuration "auto_join_rooms". + if accType != userapi.AccountTypeAppService && appserviceID == "" { for room := range cfg.AutoJoinRooms { err := addUserToRoom(context.Background(), clientRsApi, cfg.AutoJoinRooms[room], username, userutil.MakeUserID(username, cfg.Matrix.ServerName)) @@ -982,7 +983,7 @@ func completeRegistration( log.WithError(err).Errorf("user %s failed to auto-join room %s", username, cfg.AutoJoinRooms[room]) } } - }() + } return util.JSONResponse{ Code: http.StatusOK,