types

package
v0.0.0-...-02cf16a Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2015 License: Apache-2.0 Imports: 7 Imported by: 8

Documentation

Index

Constants

View Source
const (
	EventTypeCreate      = "m.room.create"
	EventTypeName        = "m.room.name"
	EventTypeTopic       = "m.room.topic"
	EventTypeAliases     = "m.room.aliases"
	EventTypeJoinRules   = "m.room.join_rules"
	EventTypeMembership  = "m.room.member"
	EventTypePowerLevels = "m.room.power_levels"
	EventTypeTyping      = "m.typing"
	EventTypePresence    = "m.presence"
)

Variables

View Source
var DefaultMissingTokenError = MissingTokenError("Missing access token")
View Source
var DefaultUnknownTokenError = UnknownTokenError("Unrecognised access token")
View Source
var DefaultUnrecognizedError = UnrecognizedError("unrecognized request")

Functions

This section is empty.

Types

type AliasesEventContent

type AliasesEventContent struct {
	Aliases []ct.Alias `json:"aliases"`
}

func (*AliasesEventContent) GetEventType

func (c *AliasesEventContent) GetEventType() string

type BaseEvent

type BaseEvent struct {
	EventType string `json:"type"`
}

func (*BaseEvent) GetEventType

func (e *BaseEvent) GetEventType() string

type CreateEventContent

type CreateEventContent struct {
	Creator ct.UserId `json:"creator"`
}

func (*CreateEventContent) GetEventType

func (c *CreateEventContent) GetEventType() string

type Error

type Error interface {
	ct.Error
	Status() int
}

func BadJsonError

func BadJsonError(message string) Error

func BadParamError

func BadParamError(message string) Error

func BadQueryError

func BadQueryError(message string) Error

func ForbiddenError

func ForbiddenError(message string) Error

func InternalError

func InternalError(err ct.Error) Error

func MissingTokenError

func MissingTokenError(message string) Error

func NotFoundError

func NotFoundError(message string) Error

func NotJsonError

func NotJsonError(message string) Error

func RoomInUseError

func RoomInUseError(message string) Error

func ServerError

func ServerError(message string) Error

func UnknownTokenError

func UnknownTokenError(message string) Error

func UnkownError

func UnkownError(message string) Error

func UnrecognizedError

func UnrecognizedError(message string) Error

func UserInUseError

func UserInUseError(message string) Error

type EventStreamRange

type EventStreamRange struct {
	Events []ct.Event  `json:"chunk"`
	Start  StreamToken `json:"start"`
	End    StreamToken `json:"end"`
}

func NewEventStreamRange

func NewEventStreamRange(events []ct.Event, start StreamToken, end StreamToken) *EventStreamRange

type GenericContent

type GenericContent struct {
	Content map[string]interface{}
	// contains filtered or unexported fields
}

func NewGenericContent

func NewGenericContent(content map[string]interface{}, eventType string) *GenericContent

func (*GenericContent) GetEventType

func (c *GenericContent) GetEventType() string

func (*GenericContent) MarshalJSON

func (c *GenericContent) MarshalJSON() ([]byte, error)

type InitialSync

type InitialSync struct {
	End      StreamToken   `json:"end"`
	Presence []ct.Event    `json:"presence"`
	Rooms    []RoomSummary `json:"rooms"`
}

type JoinRule

type JoinRule int
const (
	JoinRuleNone    JoinRule = 0
	JoinRulePublic  JoinRule = 1
	JoinRuleInvite  JoinRule = 2
	JoinRulePrivate JoinRule = 3
	JoinRuleKnock   JoinRule = 4
)

func (JoinRule) MarshalJSON

func (j JoinRule) MarshalJSON() ([]byte, error)

func (JoinRule) String

func (j JoinRule) String() string

func (JoinRule) ToVisibility

func (j JoinRule) ToVisibility() Visibility

func (*JoinRule) UnmarshalJSON

func (j *JoinRule) UnmarshalJSON(bytes []byte) error

type JoinRulesEventContent

type JoinRulesEventContent struct {
	JoinRule JoinRule `json:"join_rule"`
}

func (*JoinRulesEventContent) GetEventType

func (c *JoinRulesEventContent) GetEventType() string

type LastActive

type LastActive time.Time

func (LastActive) MarshalJSON

func (l LastActive) MarshalJSON() ([]byte, error)

func (*LastActive) UnmarshalJSON

func (l *LastActive) UnmarshalJSON(data []byte) error

type Membership

type Membership int
const (
	MembershipNone     Membership = 0
	MembershipInvited  Membership = 1
	MembershipMember   Membership = 2
	MembershipKnocking Membership = 3
	MembershipLeaving  Membership = 4
	MembershipBanned   Membership = 5
)

func (Membership) MarshalJSON

func (m Membership) MarshalJSON() ([]byte, error)

func (Membership) String

func (m Membership) String() string

func (*Membership) UnmarshalJSON

func (m *Membership) UnmarshalJSON(bytes []byte) error

type MembershipEventContent

type MembershipEventContent struct {
	*UserProfile
	Membership Membership `json:"membership"`
}

func (*MembershipEventContent) GetEventType

func (c *MembershipEventContent) GetEventType() string

type Message

type Message struct {
	BaseEvent
	Content   ct.Content   `json:"content"`
	EventId   ct.EventId   `json:"event_id"`
	RoomId    ct.RoomId    `json:"room_id"`
	UserId    ct.UserId    `json:"user_id"`
	Timestamp ct.Timestamp `json:"origin_server_ts"`
}

func (*Message) GetContent

func (e *Message) GetContent() interface{}

func (*Message) GetEventId

func (e *Message) GetEventId() *ct.EventId

func (*Message) GetEventKey

func (e *Message) GetEventKey() ct.Id

func (*Message) GetRoomId

func (e *Message) GetRoomId() *ct.RoomId

func (*Message) GetUserId

func (e *Message) GetUserId() *ct.UserId

type NameEventContent

type NameEventContent struct {
	Name string `json:"name"`
}

func (*NameEventContent) GetEventType

func (c *NameEventContent) GetEventType() string

type OldState

type OldState State

func (*OldState) MarshalJSON

func (e *OldState) MarshalJSON() ([]byte, error)

type PowerLevelsEventContent

type PowerLevelsEventContent struct {
	Ban          int               `json:"ban"`
	Kick         int               `json:"kick"`
	Invite       int               `json:"invite"`
	Redact       int               `json:"redact"`
	UserDefault  int               `json:"users_default"`
	CreateState  int               `json:"state_default"`
	EventDefault int               `json:"events_default"`
	Users        UserPowerLevelMap `json:"users"`
	Events       map[string]int    `json:"events"`
}

func DefaultPowerLevels

func DefaultPowerLevels(creator ct.UserId) *PowerLevelsEventContent

func (*PowerLevelsEventContent) GetEventType

func (c *PowerLevelsEventContent) GetEventType() string

type Presence

type Presence int
const (
	PresenceOffline     Presence = 0
	PresenceOnline      Presence = 1
	PresenceAvailable   Presence = 2
	PresenceUnavailable Presence = 3
)

func (Presence) MarshalJSON

func (p Presence) MarshalJSON() ([]byte, error)

func (*Presence) UnmarshalJSON

func (p *Presence) UnmarshalJSON(bytes []byte) error

type PresenceEvent

type PresenceEvent struct {
	BaseEvent
	Content User `json:"content"`
}

func (*PresenceEvent) GetContent

func (e *PresenceEvent) GetContent() interface{}

func (*PresenceEvent) GetEventKey

func (e *PresenceEvent) GetEventKey() ct.Id

func (*PresenceEvent) GetEventType

func (e *PresenceEvent) GetEventType() string

func (*PresenceEvent) GetRoomId

func (e *PresenceEvent) GetRoomId() *ct.RoomId

func (*PresenceEvent) GetUserId

func (e *PresenceEvent) GetUserId() *ct.UserId

type RoomDescription

type RoomDescription struct {
	Visibility Visibility  `json:"visibility"`
	Alias      *string     `json:"room_alias_name"`
	Name       *string     `json:"name"`
	Topic      *string     `json:"topic"`
	Invited    []ct.UserId `json:"invite"`
}

type RoomInitialSync

type RoomInitialSync struct {
	RoomSummary
	Presence []ct.Event `json:"presence"`
}

type RoomSummary

type RoomSummary struct {
	Membership Membership        `json:"membership"`
	RoomId     ct.RoomId         `json:"room_id"`
	Messages   *EventStreamRange `json:"messages"`
	State      []*State          `json:"state"`
	Visibility Visibility        `json:"visibility"`
}

type State

type State struct {
	Message
	StateKey string    `json:"state_key"`
	OldState *OldState `json:"prev_content"`
}

type StreamToken

type StreamToken struct {
	MessageIndex  uint64
	PresenceIndex uint64
	TypingIndex   uint64
}

func NewStreamToken

func NewStreamToken(messageIndex, presenceIndex, typingIndex uint64) StreamToken

func ParseStreamToken

func ParseStreamToken(str string) (StreamToken, error)

func (StreamToken) MarshalJSON

func (t StreamToken) MarshalJSON() ([]byte, error)

func (StreamToken) String

func (t StreamToken) String() string

func (*StreamToken) UnmarshalJSON

func (t *StreamToken) UnmarshalJSON(bytes []byte) (err error)

type TestContent

type TestContent struct {
	Name string `json:"name"`
}

type TokenParseError

type TokenParseError string

func (TokenParseError) Error

func (e TokenParseError) Error() string

type TopicEventContent

type TopicEventContent struct {
	Topic string `json:"topic"`
}

func (*TopicEventContent) GetEventType

func (c *TopicEventContent) GetEventType() string

type TypingEvent

type TypingEvent struct {
	BaseEvent
	Content TypingUsers `json:"content"`
	RoomId  ct.RoomId   `json:"room_id"`
}

func (*TypingEvent) GetContent

func (e *TypingEvent) GetContent() interface{}

func (*TypingEvent) GetEventKey

func (e *TypingEvent) GetEventKey() ct.Id

func (*TypingEvent) GetEventType

func (e *TypingEvent) GetEventType() string

func (*TypingEvent) GetRoomId

func (e *TypingEvent) GetRoomId() *ct.RoomId

func (*TypingEvent) GetUserId

func (e *TypingEvent) GetUserId() *ct.UserId

type TypingUsers

type TypingUsers struct {
	UserIds []ct.UserId `json:"user_ids"`
}

type User

type User struct {
	UserProfile
	UserStatus
	UserId ct.UserId `json:"user_id"`
}

type UserPowerLevelMap

type UserPowerLevelMap map[string]int

func (*UserPowerLevelMap) UnmarshalJSON

func (m *UserPowerLevelMap) UnmarshalJSON(bytes []byte) error

type UserProfile

type UserProfile struct {
	DisplayName string `json:"displayname"`
	AvatarUrl   string `json:"avatar_url"`
}

type UserStatus

type UserStatus struct {
	Presence      Presence   `json:"presence"`
	StatusMessage string     `json:"status_msg"`
	LastActive    LastActive `json:"last_active_ago"`
}

type Visibility

type Visibility int
const (
	VisibilityPrivate Visibility = 0
	VisibilityPublic  Visibility = 1
)

func (Visibility) ToJoinRule

func (v Visibility) ToJoinRule() JoinRule

func (*Visibility) UnmarshalJSON

func (v *Visibility) UnmarshalJSON(bytes []byte) error

Jump to

Keyboard shortcuts

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