userutil

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeUserID

func MakeUserID(localpart string, server spec.ServerName) string

MakeUserID generates user ID from localpart & server name

func ParseUsernameParam

func ParseUsernameParam(usernameParam string, cfg *config.Global) (string, spec.ServerName, error)

ParseUsernameParam extracts localpart from usernameParam. usernameParam can either be a user ID or just the localpart/username. If serverName is passed, it is verified against the domain obtained from usernameParam (if present) Returns error in case of invalid usernameParam.

Types

type AnyIdentifier added in v0.2.1

type AnyIdentifier struct {
	Identifier
}

AnyIdentifier is a wrapper that allows marshalling and unmarshalling the various types of identifiers to/from JSON. Always use this in data types that will be used in JSON manipulation.

func (AnyIdentifier) MarshalJSON added in v0.2.1

func (i AnyIdentifier) MarshalJSON() ([]byte, error)

func (*AnyIdentifier) UnmarshalJSON added in v0.2.1

func (i *AnyIdentifier) UnmarshalJSON(bs []byte) error

type Identifier added in v0.2.1

type Identifier interface {
	// IdentifierType returns the identifier type, like "m.id.user".
	IdentifierType() IdentifierType

	// String returns a debug-output string representation. The format
	// is not specified.
	String() string
}

An Identifier identifies a user. There are many kinds, and this is the common interface for them.

If you need to handle an identifier as JSON, use the AnyIdentifier wrapper. Passing around identifiers in code, the raw Identifier is enough.

See https://matrix.org/docs/spec/client_server/r0.6.1#identifier-types

type IdentifierType added in v0.2.1

type IdentifierType string

IdentifierType describes the type of identifier.

const (
	IdentifierUser       IdentifierType = "m.id.user"
	IdentifierThirdParty IdentifierType = "m.id.thirdparty"
	IdentifierPhone      IdentifierType = "m.id.phone"
)

type Medium added in v0.2.1

type Medium string

Medium describes the interpretation of a third-party identifier.

const (
	// MediumEmail signifies that the address is an email address.
	MediumEmail Medium = "email"
)

type PhoneIdentifier added in v0.2.1

type PhoneIdentifier struct {
	// Country is a ISO-3166-1 alpha-2 country code.
	Country string `json:"country"`

	// PhoneNumber is a country-specific phone number, as it would be dialled from.
	PhoneNumber string `json:"phone"`
}

A PhoneIdentifier references a phone number.

func (*PhoneIdentifier) IdentifierType added in v0.2.1

func (i *PhoneIdentifier) IdentifierType() IdentifierType

func (*PhoneIdentifier) String added in v0.2.1

func (i *PhoneIdentifier) String() string

type ThirdPartyIdentifier added in v0.2.1

type ThirdPartyIdentifier struct {
	// Medium is normally MediumEmail.
	Medium Medium `json:"medium"`

	// Address is the medium-specific identifier.
	Address string `json:"address"`
}

A ThirdPartyIdentifier references an identifier in another system.

func (*ThirdPartyIdentifier) IdentifierType added in v0.2.1

func (i *ThirdPartyIdentifier) IdentifierType() IdentifierType

func (*ThirdPartyIdentifier) String added in v0.2.1

func (i *ThirdPartyIdentifier) String() string

type UnknownIdentifier added in v0.2.1

type UnknownIdentifier struct {
	json.RawMessage
	Type IdentifierType
}

UnknownIdentifier is the catch-all for identifiers this code doesn't know about. It simply stores raw JSON.

func (*UnknownIdentifier) IdentifierType added in v0.2.1

func (i *UnknownIdentifier) IdentifierType() IdentifierType

func (*UnknownIdentifier) String added in v0.2.1

func (i *UnknownIdentifier) String() string

type UserIdentifier added in v0.2.1

type UserIdentifier struct {
	UserID string `json:"user"`
}

A UserIdentifier contains an MXID. It may be only the local part.

func (*UserIdentifier) IdentifierType added in v0.2.1

func (i *UserIdentifier) IdentifierType() IdentifierType

func (*UserIdentifier) String added in v0.2.1

func (i *UserIdentifier) String() string

Jump to

Keyboard shortcuts

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