msc1929

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

README

MSC1929 and MSC4121 go client

This library parses MSC1929 support file (including MSC4121 support), and provides a go client to interact with the admin contact API.

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(contactts.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"
)

Variables

View Source
var (
	// Client will be used to request MSC1929 support file
	Client *http.Client
)

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) 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 TODO: currently uses RoleModeratorUnstable, as MSC4121 mandates the use of RoleModeratorUnstable until it is merged into the spec,

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
	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) 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