Documentation ¶
Index ¶
- Constants
- func ReverseEventsCopy(events []gomatrix.Event) []gomatrix.Event
- func ShouldHideEvent(ev gomatrix.Event) bool
- func TextForRespError(respErr gomatrix.RespError) string
- func UnwrapRespError(err error) (respErr gomatrix.RespError, respErrOk bool)
- type Client
- func (m *Client) GetRoomDirectoryAlias(roomAlias string) (resp *RespRoomDirectoryAlias, err error)
- func (m *Client) NewRoom(roomID string) (*Room, error)
- func (m *Client) NewWorldReadableRooms() *WorldReadableRooms
- func (m *Client) RoomInitialSync(roomID string, limit int) (resp *RespInitialSync, err error)
- type Config
- type MXCURL
- type MemberInfo
- type MemberList
- type PowerLevel
- type PowerLevels
- type RespInitialSync
- type RespRoomDirectoryAlias
- type Room
- type RoomAliases
- type RoomInfo
- type RoomServerAliases
- type RoomState
- func (rs RoomState) CalculateName() string
- func (rs *RoomState) GetNumMemberEvents() int
- func (rs RoomState) Members() []*MemberInfo
- func (rs RoomState) NumMembers() int
- func (rs *RoomState) RecalculateMemberListAndServers()
- func (rs RoomState) Servers() []ServerUserCount
- func (rs *RoomState) UpdateOnEvent(event *gomatrix.Event, usePrevContent bool)
- type ServerUserCount
- type ServerUserCounts
- type WorldReadableRooms
Constants ¶
const RoomInitialSyncLimit = 256
Variables ¶
This section is empty.
Functions ¶
func ReverseEventsCopy ¶
ReverseEventsCopy returns a copy of the input slice with all elements in reverse order.
func ShouldHideEvent ¶
ShouldHideEvent returns a bool the event should be ignored in the timeline view, mimicking riot-web
func TextForRespError ¶
TextForRespError returns a string representation of the RespError if known, defaulting to the Err field of the RespError.
Types ¶
type Client ¶
Our Client extension adds some methods and a field expanding an MXC URL
func NewClient ¶
NewClient returns a Client configured by the config file found at configPath or an error if encountered.
func NewRawClient ¶
NewRawClient returns a wrapped client with http client timeouts applied.
func (*Client) GetRoomDirectoryAlias ¶
func (m *Client) GetRoomDirectoryAlias(roomAlias string) (resp *RespRoomDirectoryAlias, err error)
func (*Client) NewRoom ¶
NewRoom fetches :roomId/initialSync for a room and instantiates a room to represent it.
func (*Client) NewWorldReadableRooms ¶
func (m *Client) NewWorldReadableRooms() *WorldReadableRooms
NewWorldReadableRooms instantiates a WorldReadableRooms Collection
func (*Client) RoomInitialSync ¶
func (m *Client) RoomInitialSync(roomID string, limit int) (resp *RespInitialSync, err error)
Register makes an HTTP request according to http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-initialsync
type Config ¶
type Config struct { AccessToken string `json:"access_token"` DeviceID string `json:"device_id"` HomeServer string `json:"home_server"` RefreshToken string `json:"refresh_token"` UserID string `json:"user_id"` MediaBaseUrl string `json:"media_base_url"` }
The struct representing the json config file format.
type MXCURL ¶
type MXCURL struct {
// contains filtered or unexported fields
}
func NewMXCURL ¶
NewMXCURL constructs an MXCURL based on the mxc and the baseUrl to any Homeserver which can access the MXCURL.
func (*MXCURL) ToThumbURL ¶
ToThumbUrl returns a http/s URL string representation of the MXCURL at the width&height specified.
type MemberInfo ¶
type MemberInfo struct { MXID string Membership string DisplayName string AvatarURL MXCURL PowerLevel PowerLevel }
func NewMemberInfo ¶
func NewMemberInfo(mxid string) *MemberInfo
NewMemberInfo returns a new MemberInfo with defaults (membership=leave) applied.
func (MemberInfo) GetName ¶
func (memberInfo MemberInfo) GetName() string
GetName returns either the user's DisplayName, or if empty, their MXID. TODO make this disambiguate users if their DisplayName is not unique, implementation tips say to make a map of DisplayNames (or Set?) -> MXID?
type MemberList ¶
type MemberList []*MemberInfo
implements sort.Interface
func (MemberList) Len ¶
func (ml MemberList) Len() int
func (MemberList) Less ¶
func (ml MemberList) Less(i, j int) bool
func (MemberList) Swap ¶
func (ml MemberList) Swap(i, j int)
type PowerLevel ¶
type PowerLevel int
func (PowerLevel) Int ¶
func (powerLevel PowerLevel) Int() int
Int allows a quick denature of PowerLevel to an int
func (PowerLevel) String ¶
func (powerLevel PowerLevel) String() string
String is the Stringer implementation for PowerLevel
type PowerLevels ¶
type PowerLevels struct { Ban PowerLevel `json:"ban"` Events map[string]PowerLevel `json:"events"` EventsDefault PowerLevel `json:"events_default"` Invite PowerLevel `json:"invite"` Kick PowerLevel `json:"kick"` Redact PowerLevel `json:"redact"` StateDefault PowerLevel `json:"state_default"` Users map[string]PowerLevel `json:"users"` UsersDefault PowerLevel `json:"users_default"` }
type RespInitialSync ¶
type RespInitialSync struct { Messages gomatrix.RespMessages `json:"messages"` // Membership string `json:"membership"` State []gomatrix.Event `json:"state"` }
This is a Truncated RespInitialSync as we only need SOME information from it.
type RespRoomDirectoryAlias ¶
type Room ¶
type Room struct { // each room has a Client that is responsible for its state being up to date Client *Client ID string HasReachedHistoricEndOfTimeline bool LastAccess time.Time // contains filtered or unexported fields }
func (*Room) ForwardPaginateRoom ¶
func (r *Room) ForwardPaginateRoom()
ForwardPaginateRoom queries the API for any events newer than the latest one currently in the timeline and appends them.
func (*Room) GetEventPage ¶
func (r *Room) GetEventPage(anchor string, offset int, pageSize int) (events []gomatrix.Event, atTopEnd, atBottomEnd bool, err error)
GetEventPage returns a paginated slice of events, as well as whether this slice rests at either/both ends of the timeline.
type RoomAliases ¶
type RoomAliases []RoomServerAliases
implements sort.Interface
func (RoomAliases) Len ¶
func (p RoomAliases) Len() int
func (RoomAliases) Less ¶
func (p RoomAliases) Less(i, j int) bool
func (RoomAliases) Swap ¶
func (p RoomAliases) Swap(i, j int)
type RoomServerAliases ¶
type RoomState ¶
type RoomState struct { Creator string Topic string Name string AvatarURL MXCURL Aliases RoomAliases PowerLevels PowerLevels MemberMap map[string]*MemberInfo // contains filtered or unexported fields }
func NewRoomState ¶
NewRoomState creates a RoomState with defaults applied.
func (RoomState) CalculateName ¶
Partial implementation of http://matrix.org/docs/spec/client_server/r0.2.0.html#calculating-the-display-name-for-a-room Does not handle based on members if there is no Name/Alias (yet)
func (*RoomState) GetNumMemberEvents ¶
GetNumMemberEvents returns the total number of member events found in room state (i.e total number of unique users)
func (RoomState) Members ¶
func (rs RoomState) Members() []*MemberInfo
Members is an accessor for RoomState.memberList
func (RoomState) NumMembers ¶
NumMembers returns the number of members with membership=join
func (*RoomState) RecalculateMemberListAndServers ¶
func (rs *RoomState) RecalculateMemberListAndServers()
RecalculateMemberListAndServers does member list calculation, sorting and server calculations. ideally called at the end of concatenating so that its done as infrequently as possible whilst still never causing outdated information.
func (RoomState) Servers ¶
func (rs RoomState) Servers() []ServerUserCount
Servers iterates over the Member List (membership=join), splits each MXID and counts the number of each homeserver url.
type ServerUserCount ¶
type ServerUserCounts ¶
type ServerUserCounts []ServerUserCount
implements sort.Interface
func (ServerUserCounts) Len ¶
func (p ServerUserCounts) Len() int
func (ServerUserCounts) Less ¶
func (p ServerUserCounts) Less(i, j int) bool
func (ServerUserCounts) Swap ¶
func (p ServerUserCounts) Swap(i, j int)
type WorldReadableRooms ¶
type WorldReadableRooms struct {
// contains filtered or unexported fields
}
func (*WorldReadableRooms) GetFilteredPage ¶
func (r *WorldReadableRooms) GetFilteredPage(page, pageSize int, query string) []gomatrix.PublicRoom
GetFilteredPage returns a filtered & paginated slice of the WorldReadableRooms Collection
func (*WorldReadableRooms) GetPage ¶
func (r *WorldReadableRooms) GetPage(page, pageSize int) []gomatrix.PublicRoom
GetPage returns a paginated slice of the WorldReadableRooms Collection
func (*WorldReadableRooms) Update ¶
func (r *WorldReadableRooms) Update() error
Update updates the state of the WorldReadableRooms Collection by doing an API Call.