mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
client: add support for MSC2666
This commit is contained in:
parent
9593f72d1b
commit
bfa32f375f
4 changed files with 26 additions and 0 deletions
16
client.go
16
client.go
|
|
@ -978,6 +978,22 @@ func (cli *Client) GetProfile(ctx context.Context, mxid id.UserID) (resp *RespUs
|
|||
return
|
||||
}
|
||||
|
||||
func (cli *Client) GetMutualRooms(ctx context.Context, otherUserID id.UserID, extras ...ReqMutualRooms) (resp *RespMutualRooms, err error) {
|
||||
if cli.SpecVersions != nil && !cli.SpecVersions.Supports(FeatureMutualRooms) {
|
||||
err = fmt.Errorf("server does not support fetching mutual rooms")
|
||||
return
|
||||
}
|
||||
query := map[string]string{
|
||||
"user_id": otherUserID.String(),
|
||||
}
|
||||
if len(extras) > 0 {
|
||||
query["from"] = extras[0].From
|
||||
}
|
||||
urlPath := cli.BuildURLWithQuery(ClientURLPath{"unstable", "uk.half-shot.msc2666", "user", "mutual_rooms"}, query)
|
||||
_, err = cli.MakeRequest(ctx, http.MethodGet, urlPath, nil, &resp)
|
||||
return
|
||||
}
|
||||
|
||||
// GetDisplayName returns the display name of the user with the specified MXID. See https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3profileuseriddisplayname
|
||||
func (cli *Client) GetDisplayName(ctx context.Context, mxid id.UserID) (resp *RespUserDisplayName, err error) {
|
||||
urlPath := cli.BuildClientURL("v3", "profile", mxid, "displayname")
|
||||
|
|
|
|||
|
|
@ -140,6 +140,10 @@ type ReqMembers struct {
|
|||
NotMembership event.Membership `json:"not_membership,omitempty"`
|
||||
}
|
||||
|
||||
type ReqMutualRooms struct {
|
||||
From string `json:"-"`
|
||||
}
|
||||
|
||||
// ReqInvite3PID is the JSON request for https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3roomsroomidinvite-1
|
||||
// It is also a JSON object used in https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3createroom
|
||||
type ReqInvite3PID struct {
|
||||
|
|
|
|||
|
|
@ -159,6 +159,11 @@ type RespUserProfile struct {
|
|||
AvatarURL id.ContentURI `json:"avatar_url"`
|
||||
}
|
||||
|
||||
type RespMutualRooms struct {
|
||||
Joined []id.RoomID `json:"joined"`
|
||||
NextBatch string `json:"next_batch,omitempty"`
|
||||
}
|
||||
|
||||
// RespRegisterAvailable is the JSON response for https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3registeravailable
|
||||
type RespRegisterAvailable struct {
|
||||
Available bool `json:"available"`
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ var (
|
|||
FeatureAsyncUploads = UnstableFeature{UnstableFlag: "fi.mau.msc2246.stable", SpecVersion: SpecV17}
|
||||
FeatureAppservicePing = UnstableFeature{UnstableFlag: "fi.mau.msc2659.stable", SpecVersion: SpecV17}
|
||||
FeatureAuthenticatedMedia = UnstableFeature{UnstableFlag: "org.matrix.msc3916.stable", SpecVersion: SpecV111}
|
||||
FeatureMutualRooms = UnstableFeature{UnstableFlag: "uk.half-shot.msc2666.query_mutual_rooms"}
|
||||
|
||||
BeeperFeatureHungry = UnstableFeature{UnstableFlag: "com.beeper.hungry"}
|
||||
BeeperFeatureBatchSending = UnstableFeature{UnstableFlag: "com.beeper.batch_sending"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue