mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
commit
0237245dbb
2 changed files with 32 additions and 0 deletions
22
client.go
22
client.go
|
|
@ -1296,6 +1296,28 @@ func (cli *Client) Messages(roomID id.RoomID, from, to string, dir rune, limit i
|
|||
return
|
||||
}
|
||||
|
||||
// Context returns a number of events that happened just before and after the
|
||||
// specified event. It use pagination query parameters to paginate history in
|
||||
// the room.
|
||||
// See https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidcontexteventid
|
||||
func (cli *Client) Context(roomID id.RoomID, eventID id.EventID, filter *Filter, limit int) (resp *RespContext, err error) {
|
||||
query := map[string]string{}
|
||||
if filter != nil {
|
||||
filterJSON, err := json.Marshal(filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
query["filter"] = string(filterJSON)
|
||||
}
|
||||
if limit != 0 {
|
||||
query["limit"] = strconv.Itoa(limit)
|
||||
}
|
||||
|
||||
urlPath := cli.BuildURLWithQuery(URLPath{"rooms", roomID, "context", eventID}, query)
|
||||
_, err = cli.MakeRequest("GET", urlPath, nil, &resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (cli *Client) GetEvent(roomID id.RoomID, eventID id.EventID) (resp *event.Event, err error) {
|
||||
urlPath := cli.BuildURL("rooms", roomID, "event", eventID)
|
||||
_, err = cli.MakeRequest("GET", urlPath, nil, &resp)
|
||||
|
|
|
|||
10
responses.go
10
responses.go
|
|
@ -78,6 +78,16 @@ type RespMessages struct {
|
|||
End string `json:"end"`
|
||||
}
|
||||
|
||||
// RespContext is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidcontexteventid
|
||||
type RespContext struct {
|
||||
End string `json:"end"`
|
||||
Event *event.Event `json:"event"`
|
||||
EventsAfter []*event.Event `json:"events_after"`
|
||||
EventsBefore []*event.Event `json:"events_before"`
|
||||
Start string `json:"start"`
|
||||
State []*event.Event `json:"state"`
|
||||
}
|
||||
|
||||
// RespSendEvent is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid
|
||||
type RespSendEvent struct {
|
||||
EventID id.EventID `json:"event_id"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue