From 642e17f2aecb48fcbc93ee21d2e6575c3e46f025 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 29 Jan 2025 21:52:05 +0200 Subject: [PATCH] client: add request body for user redact --- client.go | 15 ++++++++++----- requests.go | 5 +++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 039fc6da..ae37798e 100644 --- a/client.go +++ b/client.go @@ -1277,11 +1277,16 @@ func (cli *Client) RedactEvent(ctx context.Context, roomID id.RoomID, eventID id return } -func (cli *Client) UnstableRedactUserEvents(ctx context.Context, roomID id.RoomID, userID id.UserID, limit int) (resp *RespRedactUserEvents, err error) { - urlPath := cli.BuildURLWithQuery(ClientURLPath{"unstable", "org.matrix.msc4194", "rooms", roomID, "redact", "user", userID}, map[string]string{ - "limit": strconv.Itoa(limit), - }) - _, err = cli.MakeRequest(ctx, http.MethodGet, urlPath, nil, &resp) +func (cli *Client) UnstableRedactUserEvents(ctx context.Context, roomID id.RoomID, userID id.UserID, req *ReqRedactUser) (resp *RespRedactUserEvents, err error) { + if req == nil { + req = &ReqRedactUser{} + } + query := map[string]string{} + if req.Limit > 0 { + query["limit"] = strconv.Itoa(req.Limit) + } + urlPath := cli.BuildURLWithQuery(ClientURLPath{"unstable", "org.matrix.msc4194", "rooms", roomID, "redact", "user", userID}, query) + _, err = cli.MakeRequest(ctx, http.MethodPost, urlPath, req, &resp) return } diff --git a/requests.go b/requests.go index a796e653..9788aec7 100644 --- a/requests.go +++ b/requests.go @@ -138,6 +138,11 @@ type ReqRedact struct { Extra map[string]interface{} } +type ReqRedactUser struct { + Reason string `json:"reason"` + Limit int `json:"-"` +} + type ReqMembers struct { At string `json:"at"` Membership event.Membership `json:"membership,omitempty"`