signaller/internal/models/rooms/rooms.go

78 lines
3.5 KiB
Go
Raw Normal View History

2019-07-20 17:05:57 +00:00
package rooms
import (
"encoding/json"
2019-08-03 14:19:18 +00:00
"github.com/signaller-matrix/signaller/internal/models/events"
2019-07-20 17:05:57 +00:00
)
2019-07-21 11:30:14 +00:00
// Type is type of event
type Type string
const (
// https://matrix.org/docs/spec/client_server/latest#m-room-aliases
Aliases Type = "m.room.aliases"
// https://matrix.org/docs/spec/client_server/latest#m-room-canonical-alias
CanonicalAlias = "m.room.canonical_alias"
// https://matrix.org/docs/spec/client_server/latest#m-room-create
Create = "m.room.create"
// https://matrix.org/docs/spec/client_server/latest#m-room-join-rules
JoinRules = "m.room.join_rules"
// https://matrix.org/docs/spec/client_server/latest#m-room-member
Member = "m.room.member"
// https://matrix.org/docs/spec/client_server/latest#m-room-power-levels
PowerLevels = "m.room.power_levels"
// https://matrix.org/docs/spec/client_server/latest#m-room-redaction
Redaction = "m.room.redaction"
// https://matrix.org/docs/spec/client_server/latest#m-room-message
Message = "m.room.message"
// https://matrix.org/docs/spec/client_server/latest#m-room-message-feedback
MessageFeedback = "m.room.message.feedback"
// https://matrix.org/docs/spec/client_server/latest#m-room-name
Name = "m.room.name"
// https://matrix.org/docs/spec/client_server/latest#m-room-topic
Topic = "m.room.topic"
// https://matrix.org/docs/spec/client_server/latest#m-room-avatar
Avatar = "m.room.avatar"
// https://matrix.org/docs/spec/client_server/latest#m-room-pinned-events
PinnedEvents = "m.room.pinned_events"
)
2019-07-21 12:08:16 +00:00
type JoinRule string
const (
Public JoinRule = "public"
Knock = "knock"
Invite = "invite"
Private = "private"
)
2019-07-20 17:05:57 +00:00
// https://matrix.org/docs/spec/client_server/latest#room-event-fields
type Event struct {
Content json.RawMessage `json:"content"` // Required. The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body.
2019-07-21 11:30:14 +00:00
Type Type `json:"type"` // Required. The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'
2019-07-20 17:05:57 +00:00
EventID string `json:"event_id"` // Required. The globally unique event identifier.
Sender string `json:"sender"` // Required. Contains the fully-qualified ID of the user who sent this event.
2019-07-21 11:30:14 +00:00
OriginServerTS int64 `json:"origin_server_ts"` // Required. Timestamp in milliseconds on originating homeserver when this event was sent.
2019-07-20 17:05:57 +00:00
Unsigned UnsignedData `json:"unsigned,omitempty"` // Contains optional extra information about the event.
RoomID string `json:"room_id"` // Required. The ID of the room associated with this event. Will not be present on events that arrive through /sync, despite being required everywhere else.
}
type UnsignedData struct {
Age int `json:"age"` // The time in milliseconds that has elapsed since the event was sent. This field is generated by the local homeserver, and may be incorrect if the local time on at least one of the two servers is out of sync, which can cause the age to either be negative or greater than it actually is.
RedactedBecause events.Event `json:"redacted_because,omitempty"` // Optional. The event that redacted this event, if any.
TransactionID string `json:"transaction_id"` // The client-supplied transaction ID, if the client being given the event is the same one which sent it.
}