Documentation ¶
Index ¶
- Constants
- func ParseAndValidateServerName(serverName ServerName) (host string, port int, valid bool)
- type Base64Bytes
- func (b64 *Base64Bytes) Decode(str string) error
- func (b64 Base64Bytes) Encode() string
- func (b64 Base64Bytes) MarshalJSON() ([]byte, error)
- func (b64 Base64Bytes) MarshalYAML() (interface{}, error)
- func (b64 *Base64Bytes) Scan(src interface{}) error
- func (b64 *Base64Bytes) UnmarshalJSON(raw []byte) (err error)
- func (b64 *Base64Bytes) UnmarshalYAML(unmarshal func(interface{}) error) (err error)
- func (b64 Base64Bytes) Value() (driver.Value, error)
- type CreateSenderID
- type ErrRoomKeysVersion
- type IncompatibleRoomVersionError
- type InternalServerError
- type LimitExceededError
- type MatrixError
- func ASExclusive(msg string) MatrixError
- func BadAlias(msg string) MatrixError
- func BadJSON(msg string) MatrixError
- func Forbidden(msg string) MatrixError
- func GuestAccessForbidden(msg string) MatrixError
- func InvalidParam(msg string) MatrixError
- func InvalidSignature(msg string) MatrixError
- func InvalidUsername(msg string) MatrixError
- func LeaveServerNoticeError() MatrixError
- func MissingParam(msg string) MatrixError
- func MissingToken(msg string) MatrixError
- func NotFound(msg string) MatrixError
- func NotJSON(msg string) MatrixError
- func NotTrusted(serverName string) MatrixError
- func RoomInUse(msg string) MatrixError
- func UnableToAuthoriseJoin(msg string) MatrixError
- func Unknown(msg string) MatrixError
- func UnknownToken(msg string) MatrixError
- func Unrecognized(msg string) MatrixError
- func UnsupportedRoomVersion(msg string) MatrixError
- func UserInUse(msg string) MatrixError
- func WeakPassword(msg string) MatrixError
- type MatrixErrorCode
- type RawJSON
- type RoomID
- type SenderID
- type SenderIDForUser
- type ServerName
- type StoreSenderIDFromPublicID
- type Timestamp
- type UserID
- type UserIDForSender
Constants ¶
const ( // Join is the string constant "join" Join = "join" // Ban is the string constant "ban" Ban = "ban" // Leave is the string constant "leave" Leave = "leave" // Invite is the string constant "invite" Invite = "invite" // Knock is the string constant "knock" Knock = "knock" // Restricted is the string constant "restricted" Restricted = "restricted" // NOTSPEC: Restricted is the string constant "knock_restricted" (MSC3787) // REVIEW: the MSC is merged though... so is this specced? Idk. KnockRestricted = "knock_restricted" // NOTSPEC: Peek is the string constant "peek" (MSC2753, used as the label in the sync block) Peek = "peek" // Public is the string constant "public" Public = "public" // WorldReadable is the string constant "world_readable" WorldReadable = "world_readable" // Room creation preset enum used to create private rooms PresetPrivateChat = "private_chat" // Room creation preset enum used to create trusted private rooms PresetTrustedPrivateChat = "trusted_private_chat" // Room creation preset enum used to create public rooms PresetPublicChat = "public_chat" // MRoomCreate https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-create MRoomCreate = "m.room.create" // MRoomJoinRules https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-join-rules MRoomJoinRules = "m.room.join_rules" // MRoomPowerLevels https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-power-levels MRoomPowerLevels = "m.room.power_levels" // MRoomName https://matrix.org/docs/spec/client_server/r0.6.0#m-room-name MRoomName = "m.room.name" // MRoomTopic https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-topic MRoomTopic = "m.room.topic" // MRoomAvatar https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-avatar MRoomAvatar = "m.room.avatar" // MRoomMember https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-member MRoomMember = "m.room.member" // MRoomThirdPartyInvite https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-third-party-invite MRoomThirdPartyInvite = "m.room.third_party_invite" // MRoomAliases https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-aliases MRoomAliases = "m.room.aliases" // MRoomCanonicalAlias https://matrix.org/docs/spec/client_server/r0.6.0#m-room-canonical-alias MRoomCanonicalAlias = "m.room.canonical_alias" // MRoomHistoryVisibility https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-history-visibility MRoomHistoryVisibility = "m.room.history_visibility" // MRoomGuestAccess https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-guest-access MRoomGuestAccess = "m.room.guest_access" // MRoomEncryption https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-encryption MRoomEncryption = "m.room.encryption" // MRoomRedaction https://matrix.org/docs/spec/client_server/r0.2.0.html#id21 MRoomRedaction = "m.room.redaction" // MTyping https://matrix.org/docs/spec/client_server/r0.3.0.html#m-typing MTyping = "m.typing" // MDirectToDevice https://matrix.org/docs/spec/server_server/r0.1.3#send-to-device-messaging MDirectToDevice = "m.direct_to_device" // MDeviceListUpdate https://matrix.org/docs/spec/server_server/latest#m-device-list-update-schema MDeviceListUpdate = "m.device_list_update" // MReceipt https://matrix.org/docs/spec/server_server/r0.1.4#receipts MReceipt = "m.receipt" // MPresence https://matrix.org/docs/spec/server_server/latest#m-presence-schema MPresence = "m.presence" // MRoomMembership https://github.com/matrix-org/matrix-doc/blob/clokep/restricted-rooms/proposals/3083-restricted-rooms.md MRoomMembership = "m.room_membership" // MSpaceChild https://spec.matrix.org/v1.7/client-server-api/#mspacechild-relationship MSpaceChild = "m.space.child" // MSpaceParent https://spec.matrix.org/v1.7/client-server-api/#mspaceparent-relationships MSpaceParent = "m.space.parent" )
const (
// MSpace https://spec.matrix.org/v1.7/client-server-api/#types
MSpace = "m.space"
)
Variables ¶
This section is empty.
Functions ¶
func ParseAndValidateServerName ¶
func ParseAndValidateServerName(serverName ServerName) (host string, port int, valid bool)
ParseAndValidateServerName splits a ServerName into a host and port part, and checks that it is a valid server name according to the spec.
if there is no explicit port, returns '-1' as the port.
Types ¶
type Base64Bytes ¶
type Base64Bytes []byte
A Base64Bytes is a string of bytes (not base64 encoded) that are base64 encoded when used in JSON.
The bytes encoded using base64 when marshalled as JSON. When the bytes are unmarshalled from JSON they are decoded from base64.
When scanning directly from a database, a string column will be decoded from base64 automatically whereas a bytes column will be copied as-is.
func (*Base64Bytes) Decode ¶
func (b64 *Base64Bytes) Decode(str string) error
Decode decodes the given input into this Base64Bytes
func (Base64Bytes) Encode ¶
func (b64 Base64Bytes) Encode() string
Encode encodes the bytes as base64
func (Base64Bytes) MarshalJSON ¶
func (b64 Base64Bytes) MarshalJSON() ([]byte, error)
MarshalJSON encodes the bytes as base64 and then encodes the base64 as a JSON string. This takes a value receiver so that maps and slices of Base64Bytes encode correctly.
func (Base64Bytes) MarshalYAML ¶
func (b64 Base64Bytes) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaller It just encodes the bytes as base64, which is a valid YAML string
func (*Base64Bytes) Scan ¶
func (b64 *Base64Bytes) Scan(src interface{}) error
Implements sql.Scanner
func (*Base64Bytes) UnmarshalJSON ¶
func (b64 *Base64Bytes) UnmarshalJSON(raw []byte) (err error)
UnmarshalJSON decodes a JSON string and then decodes the resulting base64. This takes a pointer receiver because it needs to write the result of decoding.
func (*Base64Bytes) UnmarshalYAML ¶
func (b64 *Base64Bytes) UnmarshalYAML(unmarshal func(interface{}) error) (err error)
UnmarshalYAML implements yaml.Unmarshaller it unmarshals the input as a yaml string and then base64-decodes the result
type CreateSenderID ¶
type CreateSenderID func(ctx context.Context, userID UserID, roomID RoomID, roomVersion string) (SenderID, ed25519.PrivateKey, error)
CreateSenderID is a function used to create the pseudoID private key.
type ErrRoomKeysVersion ¶
type ErrRoomKeysVersion struct { MatrixError CurrentVersion string `json:"current_version"` }
ErrRoomKeysVersion is an error returned by `PUT /room_keys/keys`
func WrongBackupVersionError ¶
func WrongBackupVersionError(currentVersion string) ErrRoomKeysVersion
WrongBackupVersionError is an error returned by `PUT /room_keys/keys`
func (ErrRoomKeysVersion) Error ¶
func (e ErrRoomKeysVersion) Error() string
func (ErrRoomKeysVersion) Unwrap ¶
func (e ErrRoomKeysVersion) Unwrap() error
type IncompatibleRoomVersionError ¶
type IncompatibleRoomVersionError struct { MatrixError RoomVersion string `json:"room_version"` }
func IncompatibleRoomVersion ¶
func IncompatibleRoomVersion(roomVersion string) IncompatibleRoomVersionError
IncompatibleRoomVersion is an error which is returned when the client requests a room with a version that is unsupported.
func (IncompatibleRoomVersionError) Error ¶
func (e IncompatibleRoomVersionError) Error() string
func (IncompatibleRoomVersionError) Unwrap ¶
func (e IncompatibleRoomVersionError) Unwrap() error
type InternalServerError ¶
type InternalServerError struct {
Err string
}
InternalServerError
func (InternalServerError) Error ¶
func (e InternalServerError) Error() string
type LimitExceededError ¶
type LimitExceededError struct { MatrixError RetryAfterMS int64 `json:"retry_after_ms,omitempty"` }
LimitExceededError is a rate-limiting error.
func LimitExceeded ¶
func LimitExceeded(msg string, retryAfterMS int64) LimitExceededError
LimitExceeded is an error when the client tries to send events too quickly.
func (LimitExceededError) Error ¶
func (e LimitExceededError) Error() string
func (LimitExceededError) Unwrap ¶
func (e LimitExceededError) Unwrap() error
type MatrixError ¶
type MatrixError struct { ErrCode MatrixErrorCode `json:"errcode"` Err string `json:"error"` }
MatrixError represents the "standard error response" in Matrix. http://matrix.org/docs/spec/client_server/r0.2.0.html#api-standards
func ASExclusive ¶
func ASExclusive(msg string) MatrixError
ASExclusive is an error returned when an application service tries to register an username that is outside of its registered namespace, or if a user attempts to register a username or room alias within an exclusive namespace.
func BadAlias ¶
func BadAlias(msg string) MatrixError
BadAlias is an error when the client supplies a bad alias.
func BadJSON ¶
func BadJSON(msg string) MatrixError
BadJSON is an error when the client supplies malformed JSON.
func Forbidden ¶
func Forbidden(msg string) MatrixError
Forbidden is an error when the client tries to access a resource they are not allowed to access.
func GuestAccessForbidden ¶
func GuestAccessForbidden(msg string) MatrixError
GuestAccessForbidden is an error which is returned when the client is forbidden from accessing a resource as a guest.
func InvalidParam ¶
func InvalidParam(msg string) MatrixError
InvalidParam is an error that is returned when a parameter has the wrong value or type.
func InvalidSignature ¶
func InvalidSignature(msg string) MatrixError
InvalidSignature is an error which is returned when the client tries to upload invalid signatures.
func InvalidUsername ¶
func InvalidUsername(msg string) MatrixError
InvalidUsername is an error returned when the client tries to register an invalid username
func LeaveServerNoticeError ¶
func LeaveServerNoticeError() MatrixError
LeaveServerNoticeError is an error returned when trying to reject an invite for a server notice room.
func MissingParam ¶
func MissingParam(msg string) MatrixError
MissingParam is an error that is returned when a parameter is missing from a request.
func MissingToken ¶
func MissingToken(msg string) MatrixError
MissingToken is an error when the client tries to access a resource which requires authentication without supplying credentials.
func NotFound ¶
func NotFound(msg string) MatrixError
NotFound is an error when the client tries to access an unknown resource.
func NotJSON ¶
func NotJSON(msg string) MatrixError
NotJSON is an error when the client supplies something that is not JSON to a JSON endpoint.
func NotTrusted ¶
func NotTrusted(serverName string) MatrixError
NotTrusted is an error which is returned when the client asks the server to proxy a request (e.g. 3PID association) to a server that isn't trusted
func RoomInUse ¶
func RoomInUse(msg string) MatrixError
RoomInUse is an error returned when the client tries to make a room that already exists
func UnableToAuthoriseJoin ¶
func UnableToAuthoriseJoin(msg string) MatrixError
UnableToAuthoriseJoin is an error that is returned when a server can't determine whether to allow a restricted join or not.
func UnknownToken ¶
func UnknownToken(msg string) MatrixError
UnknownToken is an error when the client tries to access a resource which requires authentication and supplies an unrecognised token
func Unrecognized ¶
func Unrecognized(msg string) MatrixError
Unrecognized is an error when the server received a request at an unexpected endpoint.
func UnsupportedRoomVersion ¶
func UnsupportedRoomVersion(msg string) MatrixError
UnsupportedRoomVersion is an error which is returned when the client requests a room with a version that is unsupported.
func UserInUse ¶
func UserInUse(msg string) MatrixError
UserInUse is an error returned when the client tries to register an username that already exists
func WeakPassword ¶
func WeakPassword(msg string) MatrixError
WeakPassword is an error which is returned when the client tries to register using a weak password. http://matrix.org/docs/spec/client_server/r0.2.0.html#password-based
func (MatrixError) Error ¶
func (e MatrixError) Error() string
func (MatrixError) Unwrap ¶
func (e MatrixError) Unwrap() error
type MatrixErrorCode ¶
type MatrixErrorCode string
const ( ErrorUnknown MatrixErrorCode = "M_UNKNOWN" ErrorUnrecognized MatrixErrorCode = "M_UNRECOGNIZED" ErrorForbidden MatrixErrorCode = "M_FORBIDDEN" ErrorBadJSON MatrixErrorCode = "M_BAD_JSON" ErrorBadAlias MatrixErrorCode = "M_BAD_ALIAS" ErrorNotJSON MatrixErrorCode = "M_NOT_JSON" ErrorNotFound MatrixErrorCode = "M_NOT_FOUND" ErrorMissingToken MatrixErrorCode = "M_MISSING_TOKEN" ErrorUnknownToken MatrixErrorCode = "M_UNKNOWN_TOKEN" ErrorWeakPassword MatrixErrorCode = "M_WEAK_PASSWORD" ErrorInvalidUsername MatrixErrorCode = "M_INVALID_USERNAME" ErrorUserInUse MatrixErrorCode = "M_USER_IN_USE" ErrorRoomInUse MatrixErrorCode = "M_ROOM_IN_USE" ErrorExclusive MatrixErrorCode = "M_EXCLUSIVE" ErrorGuestAccessForbidden MatrixErrorCode = "M_GUEST_ACCESS_FORBIDDEN" ErrorInvalidSignature MatrixErrorCode = "M_INVALID_SIGNATURE" ErrorInvalidParam MatrixErrorCode = "M_INVALID_PARAM" ErrorMissingParam MatrixErrorCode = "M_MISSING_PARAM" ErrorUnableToAuthoriseJoin MatrixErrorCode = "M_UNABLE_TO_AUTHORISE_JOIN" ErrorCannotLeaveServerNoticeRoom MatrixErrorCode = "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM" ErrorWrongRoomKeysVersion MatrixErrorCode = "M_WRONG_ROOM_KEYS_VERSION" ErrorIncompatibleRoomVersion MatrixErrorCode = "M_INCOMPATIBLE_ROOM_VERSION" ErrorUnsupportedRoomVersion MatrixErrorCode = "M_UNSUPPORTED_ROOM_VERSION" ErrorLimitExceeded MatrixErrorCode = "M_LIMIT_EXCEEDED" ErrorServerNotTrusted MatrixErrorCode = "M_SERVER_NOT_TRUSTED" ErrorSessionNotValidated MatrixErrorCode = "M_SESSION_NOT_VALIDATED" ErrorThreePIDInUse MatrixErrorCode = "M_THREEPID_IN_USE" ErrorThreePIDAuthFailed MatrixErrorCode = "M_THREEPID_AUTH_FAILED" )
type RawJSON ¶
type RawJSON []byte
TODO: Remove. Since Go 1.8 this has been fixed. RawJSON is a reimplementation of json.RawMessage that supports being used as a value type
For example:
jsonBytes, _ := json.Marshal(struct{ RawMessage json.RawMessage RawJSON RawJSON }{ json.RawMessage(`"Hello"`), RawJSON(`"World"`), })
Results in:
{"RawMessage":"IkhlbGxvIg==","RawJSON":"World"}
See https://play.golang.org/p/FzhKIJP8-I for a full example.
func (RawJSON) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface using a value receiver. This means that RawJSON used as an embedded value will still encode correctly.
func (*RawJSON) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaller interface using a pointer receiver.
type RoomID ¶
type RoomID struct {
// contains filtered or unexported fields
}
A RoomID identifies a matrix room as per the matrix specification https://spec.matrix.org/v1.6/appendices/#room-ids-and-event-ids
type SenderID ¶
type SenderID string
func SenderIDFromPseudoIDKey ¶
func SenderIDFromPseudoIDKey(key ed25519.PrivateKey) SenderID
Create a new sender ID from a private room key
func SenderIDFromUserID ¶
Create a new sender ID from a user ID
func (SenderID) IsPseudoID ¶
Returns true if this SenderID was made using a pseudo ID
func (SenderID) RawBytes ¶
func (s SenderID) RawBytes() (res Base64Bytes, err error)
Decodes this sender ID as base64, i.e. returns the raw bytes of the pseudo ID used to create this SenderID, assuming this SenderID was made using a pseudo ID.
func (SenderID) ToPseudoID ¶
Returns the non-nil room public key (pseudo ID) used to create this SenderID, or nil if this SenderID was not created using a pseudo ID
type ServerName ¶
type ServerName string
A ServerName is the name a matrix homeserver is identified by. It is a DNS name or IP address optionally followed by a port.
type StoreSenderIDFromPublicID ¶
type StoreSenderIDFromPublicID func(ctx context.Context, senderID SenderID, userID string, id RoomID) error
StoreSenderIDFromPublicID is a function to store the mxid_mapping after receiving a join event over federation.
type Timestamp ¶
type Timestamp uint64
A Timestamp is a millisecond posix timestamp.
func AsTimestamp ¶
AsTimestamp turns a time.Time into a millisecond posix timestamp.
type UserID ¶
type UserID struct {
// contains filtered or unexported fields
}
A UserID identifies a matrix user as per the matrix specification
func NewUserIDOrPanic ¶
Creates a new UserID, panicing if invalid
func (*UserID) Domain ¶
func (user *UserID) Domain() ServerName
Returns just the domain of the userID