internal

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(msg string, expr bool)

Assert that the expression is true, similar to assert() in C. If expr is false, print or panic.

If expr is false and SYNCV3_DEBUG=1 then the program panics. If expr is false and SYNCV3_DEBUG is unset or not '1' then the program logs an error along with a field which contains the file/line number of the caller/assertion of Assert. Assert should be used to verify invariants which should never be broken during normal functioning of the program, and shouldn't be used to log a normal error e.g network errors. Developers can make use of this function by setting SYNCV3_DEBUG=1 when running the server, which will fail-fast whenever a programming or logic error occurs.

The msg provided should be the expectation of the assert e.g:

Assert("list is not empty", len(list) > 0)

Which then produces:

assertion failed: list is not empty

func CalculateRoomName

func CalculateRoomName(heroInfo *RoomMetadata, maxNumNamesPerRoom int) string

func DeviceIDFromRequest

func DeviceIDFromRequest(req *http.Request) (string, error)

func IsMembershipChange

func IsMembershipChange(eventJSON gjson.Result) bool

Types

type HandlerError

type HandlerError struct {
	StatusCode int
	Err        error
}

func (*HandlerError) Error

func (e *HandlerError) Error() string

func (HandlerError) JSON

func (e HandlerError) JSON() []byte

type Hero

type Hero struct {
	ID   string
	Name string
}

type RoomMetadata

type RoomMetadata struct {
	RoomID               string
	Heroes               []Hero
	NameEvent            string // the content of m.room.name, NOT the calculated name
	CanonicalAlias       string
	JoinCount            int
	InviteCount          int
	LastMessageTimestamp uint64
	Encrypted            bool
	Tombstoned           bool
}

Metadata about a room that is consistent between all users in the room.

func (*RoomMetadata) RemoveHero

func (m *RoomMetadata) RemoveHero(userID string)

Jump to

Keyboard shortcuts

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