msc1929

package module
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2025 License: LGPL-3.0 Imports: 9 Imported by: 0

README

Matrix Server Contacts go client

This small library provides a go client to interact with /.well-known/matrix/support endpoint.

The following MSCs are supported:

Initially it was developed to be used in the Matrix Rooms Search project, but it can be used in any other project that needs to interact with the admin contact API.

Usage

package main

import (
    "fmt"
    "github.com/etkecc/go-msc1929"
)

func main() {
    contacts, err := msc1929.Get("matrix.org")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(contacts.AdminEmails())
}

Documentation

Index

Constants

View Source
const (
	// RoleAdmin is catch-all user for any queries
	RoleAdmin = "m.role.admin"
	// RoleModerator is intended for moderation requests
	// TODO: currently unused, as MSC4121 mandates the use of RoleModeratorUnstable until it is merged into the spec,
	// ref: https://github.com/FSG-Cat/matrix-spec-proposals/blob/FSG-Cat-Moderation-Role-well-known-support-record/proposals/4121-m.role.moderator.md#unstable-prefix
	RoleModerator = "m.role.moderator"
	// RoleModeratorUnstable is intended for moderation requests, used until MSC4121 is merged into the spec
	RoleModeratorUnstable = "support.feline.msc4121.role.moderator"
	// RoleSecurity is intended for sensitive requests
	RoleSecurity = "m.role.security"
	// RoleDPO is intended for data protection officer contacts
	// TODO: currently unused, as MSC4265 mandates the use of RoleDPOUnstable until it is merged into the spec,
	// ref: bitbucket.org/helloticketscode/curator/internal/services/emailnotifier
	RoleDPO = "m.role.dpo"
	// RoleDPOUnstable is intended for data protection officer contacts, used until MSC4265 is merged into the spec
	RoleDPOUnstable = "org.matrix.msc4265.role.dpo"
)

Variables

View Source
var (
	// UserAgent is the default user agent for the client
	UserAgent = "Go-MSC1929-client/1.0 (+https://github.com/etkecc/go-msc1929)"
	// Client will be used to request MSC1929 support file
	Client *http.Client
)

SupportedRoles contains all roles that are supported by the support file

Functions

This section is empty.

Types

type Contact

type Contact struct {
	Email    string `json:"email_address,omitempty" yaml:"email_address,omitempty"`
	MatrixID string `json:"matrix_id,omitempty" yaml:"matrix_id,omitempty"`
	Role     string `json:"role,omitempty" yaml:"role,omitempty"`
}

Contact details

func (*Contact) IsAdmin

func (c *Contact) IsAdmin() bool

IsAdmin checks if contact has admin role

func (*Contact) IsDPO added in v1.2.0

func (c *Contact) IsDPO() bool

IsDPO checks if contact has DPO role

func (*Contact) IsEmpty

func (c *Contact) IsEmpty() bool

IsEmpty checks if contact contains at least one contact (either email or mxid)

func (*Contact) IsModerator

func (c *Contact) IsModerator() bool

IsModerator checks if contact has moderator role

func (*Contact) IsSecurity

func (c *Contact) IsSecurity() bool

IsSecurity checks if contact has security role

type Response

type Response struct {
	Contacts    []*Contact `json:"contacts,omitempty" yaml:"contacts,omitempty"`         // Contacts list
	Admins      []*Contact `json:"admins,omitempty" yaml:"admins,omitempty"`             // Admins list, deprecated since Nov 15, 2023, but still used by some servers
	SupportPage string     `json:"support_page,omitempty" yaml:"support_page,omitempty"` // SupportPage URL
	// contains filtered or unexported fields
}

Response of the MSC1929 support file

func Get

func Get(serverName string) (*Response, error)

Get MSC1929 support file from serverName

func GetWithContext

func GetWithContext(ctx context.Context, serverName string) (*Response, error)

GetWithContext MSC1929 support file from serverName

func ParseMSC1929

func ParseMSC1929(content []byte) (*Response, error)

ParseMSC1929 parses MSC1929 support file

func (*Response) AdminEmails

func (r *Response) AdminEmails() []string

AdminEmails returns a list of admin emails

func (*Response) AdminMatrixIDs

func (r *Response) AdminMatrixIDs() []string

AdminMatrixIDs returns a list of admin matrix IDs

func (*Response) AllEmails

func (r *Response) AllEmails() []string

AllEmails returns a list of all emails

func (*Response) AllMatrixIDs

func (r *Response) AllMatrixIDs() []string

AllMatrixIDs returns a list of all matrix IDs

func (*Response) Clone

func (r *Response) Clone() *Response

Clone returns a deep copy of the response

func (*Response) DPOEmails added in v1.2.0

func (r *Response) DPOEmails() []string

DPOEmails returns a list of DPO emails

func (*Response) DPOMatrixIDs added in v1.2.0

func (r *Response) DPOMatrixIDs() []string

DPOMatrixIDs returns a list of DPO matrix IDs

func (*Response) IsEmpty

func (r *Response) IsEmpty() bool

IsEmpty checks if response contains at least one contact (either email or mxid) or SupportPage

func (*Response) ModeratorEmails

func (r *Response) ModeratorEmails() []string

ModeratorEmails returns a list of moderator emails

func (*Response) ModeratorMatrixIDs

func (r *Response) ModeratorMatrixIDs() []string

ModeratorMatrixIDs returns a list of moderator matrix IDs

func (*Response) Sanitize

func (r *Response) Sanitize()

Sanitize ensures that all fields are valid, and removes those that are not

func (*Response) SecurityEmails

func (r *Response) SecurityEmails() []string

SecurityEmails returns a list of security emails

func (*Response) SecurityMatrixIDs

func (r *Response) SecurityMatrixIDs() []string

SecurityMatrixIDs returns a list of security matrix IDs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL