client: omit from parameter in /messages if empty
Some checks failed
Go / Lint (latest) (push) Has been cancelled
Go / Build (old, libolm) (push) Has been cancelled
Go / Build (latest, libolm) (push) Has been cancelled
Go / Build (old, goolm) (push) Has been cancelled
Go / Build (latest, goolm) (push) Has been cancelled

This commit is contained in:
Tulir Asokan 2024-10-10 20:18:58 +03:00
commit 50f4a2eec1

View file

@ -1836,11 +1836,10 @@ func (cli *Client) Hierarchy(ctx context.Context, roomID id.RoomID, req *ReqHier
// Messages returns a list of message and state events for a room. It uses
// pagination query parameters to paginate history in the room.
// See https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomidmessages
// See https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3roomsroomidmessages
func (cli *Client) Messages(ctx context.Context, roomID id.RoomID, from, to string, dir Direction, filter *FilterPart, limit int) (resp *RespMessages, err error) {
query := map[string]string{
"from": from,
"dir": string(dir),
"dir": string(dir),
}
if filter != nil {
filterJSON, err := json.Marshal(filter)
@ -1849,6 +1848,9 @@ func (cli *Client) Messages(ctx context.Context, roomID id.RoomID, from, to stri
}
query["filter"] = string(filterJSON)
}
if from != "" {
query["from"] = from
}
if to != "" {
query["to"] = to
}