5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 16:20:26 +00:00

Rebase gomatrix vendor with upstream (#1006)

This commit is contained in:
Wim 2020-02-09 23:49:17 +01:00 committed by GitHub
parent 1985873494
commit 23083f3ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 82 additions and 13 deletions

2
go.mod
View File

@ -25,7 +25,7 @@ require (
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20190210153444-cc9d05784d5d
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91
github.com/matterbridge/gomatrix v0.0.0-20191026211822-6fc7accd00ca
github.com/matterbridge/gomatrix v0.0.0-20200209221412-326bea8d866e
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18
github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61
github.com/mattermost/mattermost-server v5.5.0+incompatible

4
go.sum
View File

@ -132,8 +132,8 @@ github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible/go.mod h1:igE6rUAn3jai2wCdsjFHfhUoekjrFthoEjFObKKwSb4=
github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91 h1:KzDEcy8eDbTx881giW8a6llsAck3e2bJvMyKvh1IK+k=
github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q=
github.com/matterbridge/gomatrix v0.0.0-20191026211822-6fc7accd00ca h1:3ypqEpFpt6vg5Sv2xxA8/v4WiSOnWMXW7DqxTxpM4XI=
github.com/matterbridge/gomatrix v0.0.0-20191026211822-6fc7accd00ca/go.mod h1:+jWeaaUtXQbBRdKYWfjW6JDDYiI2XXE+3NnTjW5kg8g=
github.com/matterbridge/gomatrix v0.0.0-20200209221412-326bea8d866e h1:i1wiGiwjRZ1Yy0JbERoDeikLzOnM6tkkQTT20b3Yy1E=
github.com/matterbridge/gomatrix v0.0.0-20200209221412-326bea8d866e/go.mod h1:+jWeaaUtXQbBRdKYWfjW6JDDYiI2XXE+3NnTjW5kg8g=
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18 h1:fLhwXtWGtfTgZVxHG1lcKjv+re7dRwyyuYFNu69xdho=
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA=
github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61 h1:R/MgM/eUyRBQx2FiH6JVmXck8PaAuKfe2M1tWIzW7nE=

View File

@ -372,6 +372,53 @@ func (cli *Client) Versions() (resp *RespVersions, err error) {
return
}
// PublicRooms returns the list of public rooms on target server. See https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-unstable-publicrooms
func (cli *Client) PublicRooms(limit int, since string, server string) (resp *RespPublicRooms, err error) {
args := map[string]string{}
if limit != 0 {
args["limit"] = strconv.Itoa(limit)
}
if since != "" {
args["since"] = since
}
if server != "" {
args["server"] = server
}
urlPath := cli.BuildURLWithQuery([]string{"publicRooms"}, args)
err = cli.MakeRequest("GET", urlPath, nil, &resp)
return
}
// PublicRoomsFiltered returns a subset of PublicRooms filtered server side.
// See https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-unstable-publicrooms
func (cli *Client) PublicRoomsFiltered(limit int, since string, server string, filter string) (resp *RespPublicRooms, err error) {
content := map[string]string{}
if limit != 0 {
content["limit"] = strconv.Itoa(limit)
}
if since != "" {
content["since"] = since
}
if filter != "" {
content["filter"] = filter
}
var urlPath string
if server == "" {
urlPath = cli.BuildURL("publicRooms")
} else {
urlPath = cli.BuildURLWithQuery([]string{"publicRooms"}, map[string]string{
"server": server,
})
}
err = cli.MakeRequest("POST", urlPath, content, &resp)
return
}
// JoinRoom joins the client to a room ID or alias. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-join-roomidoralias
//
// If serverName is specified, this will be added as a query param to instruct the homeserver to join via that server. If content is specified, it will

View File

@ -7,15 +7,16 @@ import (
// Event represents a single Matrix event.
type Event struct {
StateKey *string `json:"state_key,omitempty"` // The state key for the event. Only present on State Events.
Sender string `json:"sender"` // The user ID of the sender of the event
Type string `json:"type"` // The event type
Timestamp int64 `json:"origin_server_ts"` // The unix timestamp when this message was sent by the origin server
ID string `json:"event_id"` // The unique ID of this event
RoomID string `json:"room_id"` // The room the event was sent to. May be nil (e.g. for presence)
Content map[string]interface{} `json:"content"` // The JSON content of the event.
Redacts string `json:"redacts,omitempty"` // The event ID that was redacted if a m.room.redaction event
Unsigned map[string]interface{} `json:"unsigned"` // The unsigned portions of the event, such as age and prev_content
StateKey *string `json:"state_key,omitempty"` // The state key for the event. Only present on State Events.
Sender string `json:"sender"` // The user ID of the sender of the event
Type string `json:"type"` // The event type
Timestamp int64 `json:"origin_server_ts"` // The unix timestamp when this message was sent by the origin server
ID string `json:"event_id"` // The unique ID of this event
RoomID string `json:"room_id"` // The room the event was sent to. May be nil (e.g. for presence)
Redacts string `json:"redacts,omitempty"` // The event ID that was redacted if a m.room.redaction event
Unsigned map[string]interface{} `json:"unsigned"` // The unsigned portions of the event, such as age and prev_content
Content map[string]interface{} `json:"content"` // The JSON content of the event.
PrevContent map[string]interface{} `json:"prev_content,omitempty"` // The JSON prev_content of the event.
}
// Body returns the value of the "body" key in the event content if it is

View File

@ -22,6 +22,14 @@ type RespVersions struct {
Versions []string `json:"versions"`
}
// RespPublicRooms is the JSON response for http://matrix.org/speculator/spec/HEAD/client_server/unstable.html#get-matrix-client-unstable-publicrooms
type RespPublicRooms struct {
TotalRoomCountEstimate int `json:"total_room_count_estimate"`
PrevBatch string `json:"prev_batch"`
NextBatch string `json:"next_batch"`
Chunk []PublicRoom `json:"chunk"`
}
// RespJoinRoom is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-join
type RespJoinRoom struct {
RoomID string `json:"room_id"`

View File

@ -6,6 +6,19 @@ type Room struct {
State map[string]map[string]*Event
}
// PublicRoom represents the information about a public room obtainable from the room directory
type PublicRoom struct {
CanonicalAlias string `json:"canonical_alias"`
Name string `json:"name"`
WorldReadable bool `json:"world_readable"`
Topic string `json:"topic"`
NumJoinedMembers int `json:"num_joined_members"`
AvatarURL string `json:"avatar_url"`
RoomID string `json:"room_id"`
GuestCanJoin bool `json:"guest_can_join"`
Aliases []string `json:"aliases"`
}
// UpdateState updates the room's current state with the given Event. This will clobber events based
// on the type/state_key combination.
func (room Room) UpdateState(event *Event) {

2
vendor/modules.txt vendored
View File

@ -105,7 +105,7 @@ github.com/matterbridge/Rocket.Chat.Go.SDK/rest
github.com/matterbridge/emoji
# github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91
github.com/matterbridge/go-xmpp
# github.com/matterbridge/gomatrix v0.0.0-20191026211822-6fc7accd00ca
# github.com/matterbridge/gomatrix v0.0.0-20200209221412-326bea8d866e
github.com/matterbridge/gomatrix
# github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18
github.com/matterbridge/gozulipbot