From 81cecd55cd3e4dca75806551d44178b01e66b063 Mon Sep 17 00:00:00 2001 From: timedout Date: Sat, 28 Feb 2026 17:42:44 +0000 Subject: [PATCH 1/3] synapseadmin/userapi: Add RedactUser and RedactUserStatus --- synapseadmin/userapi.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/synapseadmin/userapi.go b/synapseadmin/userapi.go index b1de55b6b..fde9c678b 100644 --- a/synapseadmin/userapi.go +++ b/synapseadmin/userapi.go @@ -174,3 +174,41 @@ func (cli *Client) DeleteUserRatelimit(ctx context.Context, userID id.UserID) (e _, err = cli.Client.MakeRequest(ctx, http.MethodDelete, cli.BuildAdminURL("v1", "users", userID, "override_ratelimit"), nil, nil) return } + +type ReqRedactUser struct { + // A list of rooms to redact the user’s events in. + // If an empty list is provided all events in all rooms the user is a member of will be redacted. + Rooms []id.RoomID `json:"rooms"` + // Reason the redaction is being requested, ie “spam”, “abuse”, etc. This will be included in each redaction event. + Reason string `json:"reason,omitempty"` + // a limit on the number of the user’s events to search for ones that can be redacted (events are redacted newest to + // oldest) in each room, defaults to 1000 if not provided. + Limit int `json:"limit,omitempty"` + // If set to true, the admin user is used to issue the redactions, rather than puppeting the user + UseAdmin bool `json:"use_admin,omitempty"` +} + +type RespRedactUser struct { + RedactID string `json:"redact_id"` +} + +// RedactUser puppets the target user to redact their events. +// If the supplied room list is empty, all rooms the user is a member of are used. +// If the user is a remote user, the invoking admin user will be used to issue redactions. +func (cli *Client) RedactUser(ctx context.Context, userID id.UserID, req ReqRedactUser) (resp RespUserRatelimit, err error) { + if req.Rooms == nil { + req.Rooms = []id.RoomID{} + } + _, err = cli.Client.MakeRequest(ctx, http.MethodPost, cli.BuildAdminURL("v1", "user", userID, "redact"), &req, &resp) + return +} + +type RespRedactUserStatus struct { + Status string `json:"status"` + FailedRedactions map[id.EventID]string `json:"failed_redactions"` +} + +func (cli *Client) RedactUserStatus(ctx context.Context, redactID string) (resp RespRedactUser, err error) { + _, err = cli.Client.MakeRequest(ctx, http.MethodPost, cli.BuildAdminURL("v1", "user", "redact_status", redactID), nil, &resp) + return +} From a57361a7589293680e6cddc87796c72594e007e8 Mon Sep 17 00:00:00 2001 From: timedout Date: Sat, 28 Feb 2026 17:43:30 +0000 Subject: [PATCH 2/3] Correct method used in RedactUserStatus Copying and pasting is bad actually --- synapseadmin/userapi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapseadmin/userapi.go b/synapseadmin/userapi.go index fde9c678b..64405db5f 100644 --- a/synapseadmin/userapi.go +++ b/synapseadmin/userapi.go @@ -209,6 +209,6 @@ type RespRedactUserStatus struct { } func (cli *Client) RedactUserStatus(ctx context.Context, redactID string) (resp RespRedactUser, err error) { - _, err = cli.Client.MakeRequest(ctx, http.MethodPost, cli.BuildAdminURL("v1", "user", "redact_status", redactID), nil, &resp) + _, err = cli.Client.MakeRequest(ctx, http.MethodGet, cli.BuildAdminURL("v1", "user", "redact_status", redactID), nil, &resp) return } From e0125d54f462946bf0150aeab36f2cb8d430b9be Mon Sep 17 00:00:00 2001 From: timedout Date: Sat, 28 Feb 2026 17:57:16 +0000 Subject: [PATCH 3/3] Correct mismatched result types --- synapseadmin/userapi.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapseadmin/userapi.go b/synapseadmin/userapi.go index 64405db5f..8c5252391 100644 --- a/synapseadmin/userapi.go +++ b/synapseadmin/userapi.go @@ -195,7 +195,7 @@ type RespRedactUser struct { // RedactUser puppets the target user to redact their events. // If the supplied room list is empty, all rooms the user is a member of are used. // If the user is a remote user, the invoking admin user will be used to issue redactions. -func (cli *Client) RedactUser(ctx context.Context, userID id.UserID, req ReqRedactUser) (resp RespUserRatelimit, err error) { +func (cli *Client) RedactUser(ctx context.Context, userID id.UserID, req ReqRedactUser) (resp RespRedactUser, err error) { if req.Rooms == nil { req.Rooms = []id.RoomID{} } @@ -208,7 +208,7 @@ type RespRedactUserStatus struct { FailedRedactions map[id.EventID]string `json:"failed_redactions"` } -func (cli *Client) RedactUserStatus(ctx context.Context, redactID string) (resp RespRedactUser, err error) { +func (cli *Client) RedactUserStatus(ctx context.Context, redactID string) (resp RespRedactUserStatus, err error) { _, err = cli.Client.MakeRequest(ctx, http.MethodGet, cli.BuildAdminURL("v1", "user", "redact_status", redactID), nil, &resp) return }