rooms

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package rooms contains a representation for Matrix rooms and utilities to parse state events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Member

type Member struct {
	event.MemberEventContent

	// The user who sent the membership event
	Sender id.UserID `json:"-"`
}

type Room

type Room struct {
	// The room ID.
	ID id.RoomID

	// Whether or not the user has left the room.
	HasLeft bool
	// Whether or not the room is encrypted.
	Encrypted bool

	// The first batch of events that has been fetched for this room.
	// Used for fetching additional history.
	PrevBatch string
	// The last_batch field from the most recent sync. Used for fetching member lists.
	LastPrevBatch string
	// The MXID of the user whose session this room was created for.
	SessionUserID id.UserID
	SessionMember *Member

	// The number of unread messages that were notified about.
	UnreadMessages []UnreadMessage

	// Whether or not this room is marked as a direct chat.
	IsDirect  bool
	OtherUser id.UserID

	// List of tags given to this room.
	RawTags []RoomTag
	// Timestamp of previously received actual message.
	LastReceivedMessage time.Time

	// The lazy loading summary for this room.
	Summary mautrix.LazyLoadSummary
	// Whether or not the members for this room have been fetched from the server.
	MembersFetched bool

	// The name of the room. Calculated from the state event name,
	// canonical_alias or alias or the member cache.
	NameCache string

	// The canonical alias of the room. Directly fetched from the m.room.canonical_alias state event.
	CanonicalAliasCache id.RoomAlias
	// contains filtered or unexported fields
}

Room represents a single Matrix room.

func NewRoom

func NewRoom(roomID id.RoomID, cache *RoomCache) *Room

NewRoom creates a new Room with the given ID

func (*Room) AddUnread

func (room *Room) AddUnread(eventID id.EventID, counted, highlight bool)

func (*Room) GetCanonicalAlias

func (room *Room) GetCanonicalAlias() id.RoomAlias

func (*Room) GetMember

func (room *Room) GetMember(userID id.UserID) *Member

GetMember returns the member with the given MXID. If the member doesn't exist, nil is returned.

func (*Room) GetMemberCount

func (room *Room) GetMemberCount() int

func (*Room) GetMemberList

func (room *Room) GetMemberList() []id.UserID

func (*Room) GetMembers

func (room *Room) GetMembers() map[id.UserID]*Member

GetMembers returns the members in this room.

The members are returned from the cache. If the cache is empty, it is updated first.

func (*Room) GetOwnDisplayname

func (room *Room) GetOwnDisplayname() string

GetSessionOwner returns the ID of the user whose session this room was created for.

func (*Room) GetStateEvent

func (room *Room) GetStateEvent(eventType event.Type, stateKey string) *event.Event

GetStateEvent returns the state event for the given type/state_key combo, or nil.

func (*Room) GetTitle

func (room *Room) GetTitle() string

GetTitle returns the display name of the room.

The display name is returned from the cache. If the cache is empty, it is updated first.

func (*Room) GetTopic

func (room *Room) GetTopic() string

GetTopic returns the topic of the room.

func (*Room) HasNewMessages

func (room *Room) HasNewMessages() bool

func (*Room) Highlighted

func (room *Room) Highlighted() bool

func (*Room) IsReplaced

func (room *Room) IsReplaced() bool

func (*Room) Load

func (room *Room) Load()

func (*Room) Loaded

func (room *Room) Loaded() bool

func (*Room) MarkRead

func (room *Room) MarkRead(eventID id.EventID) bool

MarkRead clears the new message statuses on this room.

func (*Room) ReplacedBy

func (room *Room) ReplacedBy() id.RoomID

func (*Room) Save

func (room *Room) Save()

func (*Room) SetPostLoad

func (room *Room) SetPostLoad(fn func())

func (*Room) SetPostUnload

func (room *Room) SetPostUnload(fn func())

func (*Room) SetPreLoad

func (room *Room) SetPreLoad(fn func() bool)

func (*Room) SetPreUnload

func (room *Room) SetPreUnload(fn func() bool)

func (*Room) Tags

func (room *Room) Tags() []RoomTag

func (*Room) Touch

func (room *Room) Touch()

func (*Room) Unload

func (room *Room) Unload() bool

func (*Room) UnreadCount

func (room *Room) UnreadCount() int

func (*Room) UpdateState

func (room *Room) UpdateState(evt *event.Event)

UpdateState updates the room's current state with the given Event. This will clobber events based on the type/state_key combination.

func (*Room) UpdateSummary

func (room *Room) UpdateSummary(summary mautrix.LazyLoadSummary)

type RoomCache

type RoomCache struct {
	sync.Mutex

	Map map[id.RoomID]*Room
	// contains filtered or unexported fields
}

RoomCache contains room state info in a hashmap and linked list.

func NewRoomCache

func NewRoomCache(listPath, directory string, maxSize int, maxAge int64, getOwner func() id.UserID) *RoomCache

func (*RoomCache) DisableUnloading

func (cache *RoomCache) DisableUnloading()

func (*RoomCache) EnableUnloading

func (cache *RoomCache) EnableUnloading()

func (*RoomCache) FindSharedRooms

func (cache *RoomCache) FindSharedRooms(userID id.UserID) (shared []id.RoomID)

func (*RoomCache) ForceClean

func (cache *RoomCache) ForceClean()

func (*RoomCache) Get

func (cache *RoomCache) Get(roomID id.RoomID) *Room

func (*RoomCache) GetEncryptionEvent added in v0.2.0

func (cache *RoomCache) GetEncryptionEvent(roomID id.RoomID) *event.EncryptionEventContent

func (*RoomCache) GetOrCreate

func (cache *RoomCache) GetOrCreate(roomID id.RoomID) *Room

func (*RoomCache) IsEncrypted

func (cache *RoomCache) IsEncrypted(roomID id.RoomID) bool

func (*RoomCache) Load

func (cache *RoomCache) Load(roomID id.RoomID) *Room

func (*RoomCache) LoadList

func (cache *RoomCache) LoadList() error

func (*RoomCache) Put

func (cache *RoomCache) Put(room *Room)

func (*RoomCache) SaveList

func (cache *RoomCache) SaveList() error

func (*RoomCache) SaveLoadedRooms

func (cache *RoomCache) SaveLoadedRooms()

func (*RoomCache) Touch

func (cache *RoomCache) Touch(roomID id.RoomID)

func (*RoomCache) TouchNode

func (cache *RoomCache) TouchNode(node *Room)

func (*RoomCache) Unload

func (cache *RoomCache) Unload(node *Room)

type RoomNameSource

type RoomNameSource int
const (
	UnknownRoomName RoomNameSource = iota
	MemberRoomName
	CanonicalAliasRoomName
	ExplicitRoomName
)

type RoomTag

type RoomTag struct {
	// The name of the tag.
	Tag string
	// The order of the tag.
	Order json.Number
}

RoomTag is a tag given to a specific room.

type UnreadMessage

type UnreadMessage struct {
	EventID   id.EventID
	Counted   bool
	Highlight bool
}

Jump to

Keyboard shortcuts

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