Small fixes

This commit is contained in:
Tulir Asokan 2018-06-14 13:36:53 +03:00
parent 3a27831112
commit feaf75b327
5 changed files with 53 additions and 29 deletions

View file

@ -57,9 +57,11 @@ type EventHandler func(*Event) bool
type MatrixClient interface {
AddEventHandler(EventType, EventHandler)
GetEvent(string, string) *Event
}
type EventFuncs interface {
MarkRead() error
Reply(string) (string, error)
ReplyContent(Content) (string, error)
SendMessage(string) (string, error)
@ -70,22 +72,22 @@ type EventFuncs interface {
type Event struct {
EventFuncs
StateKey string `json:"state_key,omitempty"` // The state key for the event. Only present on State Events.
Sender string `json:"sender"` // The user ID of the sender of the event
Type EventType `json:"type"` // The event type
Timestamp int64 `json:"origin_server_ts"` // The unix timestamp when this message was sent by the origin server
ID string `json:"event_id"` // The unique ID of this event
RoomID string `json:"room_id"` // The room the event was sent to. May be nil (e.g. for presence)
Content Content `json:"content"`
Redacts string `json:"redacts,omitempty"` // The event ID that was redacted if a m.room.redaction event
Unsigned Unsigned `json:"unsigned,omitempty"` // Unsigned content set by own homeserver.
StateKey string `json:"state_key,omitempty"` // The state key for the event. Only present on State Events.
Sender string `json:"sender"` // The user ID of the sender of the event
Type EventType `json:"type"` // The event type
Timestamp int64 `json:"origin_server_ts"` // The unix timestamp when this message was sent by the origin server
ID string `json:"event_id"` // The unique ID of this event
RoomID string `json:"room_id"` // The room the event was sent to. May be nil (e.g. for presence)
Content Content `json:"content"`
Redacts string `json:"redacts,omitempty"` // The event ID that was redacted if a m.room.redaction event
Unsigned Unsigned `json:"unsigned,omitempty"` // Unsigned content set by own homeserver.
}
type Unsigned struct {
PrevContent Content `json:"prev_content,omitempty"`
PrevSender string `json:"prev_sender,omitempty"`
ReplacesState string `json:"replaces_state,omitempty"`
Age int64 `json:"age"`
PrevContent Content `json:"prev_content,omitempty"`
PrevSender string `json:"prev_sender,omitempty"`
ReplacesState string `json:"replaces_state,omitempty"`
Age int64 `json:"age"`
}
type Content struct {
@ -93,32 +95,32 @@ type Content struct {
MsgType MessageType `json:"msgtype"`
Body string `json:"body"`
Format string `json:"format"`
FormattedBody string `json:"formatted_body"`
Format string `json:"format,omitempty"`
FormattedBody string `json:"formatted_body,omitempty"`
Info FileInfo `json:"info"`
URL string `json:"url"`
Info FileInfo `json:"info,omitempty"`
URL string `json:"url,omitempty"`
Membership string `json:"membership"`
Membership string `json:"membership,omitempty"`
RelatesTo RelatesTo `json:"m.relates_to"`
RelatesTo RelatesTo `json:"m.relates_to,omitempty"`
}
type FileInfo struct {
MimeType string `json:"mimetype"`
ThumbnailInfo *FileInfo `json:"thumbnail_info"`
ThumbnailURL string `json:"thumbnail_url"`
Height int `json:"h"`
Width int `json:"w"`
Size int `json:"size"`
MimeType string `json:"mimetype,omitempty"`
ThumbnailInfo *FileInfo `json:"thumbnail_info,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
Height int `json:"h,omitempty"`
Width int `json:"w,omitempty"`
Size int `json:"size,omitempty"`
}
type RelatesTo struct {
InReplyTo InReplyTo `json:"m.in_reply_to"`
InReplyTo InReplyTo `json:"m.in_reply_to,omitempty"`
}
type InReplyTo struct {
EventID string `json:"event_id"`
// Not required, just for future-proofing
RoomID string `json:"room_id"`
RoomID string `json:"room_id,omitempty"`
}