event

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package event defines the basic event type for interacting with matrix servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Type      string        `json:"type"`
	ID        string        `json:"event_id"`
	Sender    string        `json:"sender"`
	Room      string        `json:"room_id"`
	StateKey  string        `json:"state_key"`
	Timestamp int           `json:"origin_server_ts"`
	Unsigned  *UnsignedData `json:"unsigned"`
}

Metadata of an event. Depending of the event type fields may be set or not.

Reason for this is that there are multiple groups of event types in matrix. One could have created types for each of them but I do not see the benefit.

type Opaque

type Opaque struct {
	Metadata
	Content OpaqueContent `json:"content"`
}

Opaque is an event with Metadata and OpaqueContent as content. To get a more concrete type out of this check the value of the type field in the metadata and unmarshal the event into concrete types.

type OpaqueContent

type OpaqueContent []byte

OpaqueContent is the content field of an event that should not be interpreted (yet).

Normally one would give it the type interface{} when unmarshalling via json but that would result in a nested map[string]interface{} structure with I find suboptimal. It implements json.Unmarshaler and simply causes the json unmarshaller to store the content field as bytes until it gets unmarshalled into a concrete content type.

func (*OpaqueContent) UnmarshalJSON

func (o *OpaqueContent) UnmarshalJSON(b []byte) error

UnmarshalJSON tells the json unmarshaller to leave the content field as is.

type UnsignedData

type UnsignedData struct {
	Age             int           `json:"age"`
	TXID            string        `json:"transaction_id"`
	PreviousContent OpaqueContent `json:"prev_content"`
	RedactedBecause *Opaque       `json:"redacted_because"`
}

UnsignedData is the portion of Metadata that is not set by sender but servers on the way and it thus unsigned.

Jump to

Keyboard shortcuts

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