This commit is contained in:
timedout 2026-03-10 20:23:51 -07:00 committed by GitHub
commit 2fba865ff9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 users 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 users 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 RespRedactUser, 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 RespRedactUserStatus, err error) {
_, err = cli.Client.MakeRequest(ctx, http.MethodGet, cli.BuildAdminURL("v1", "user", "redact_status", redactID), nil, &resp)
return
}