diff options
author | hanemile <mail@emile.space> | 2020-07-10 16:37:52 +0200 |
---|---|---|
committer | hanemile <mail@emile.space> | 2020-07-10 16:37:52 +0200 |
commit | 6c242710d7b1e4ba7c7d9b76437529d1d00c7c67 (patch) | |
tree | 028706a516365e365dd9807ee6d0ab57433b4807 /structs.go | |
parent | 162f9164fdd95281e8e559b5963a02a7a16d25b7 (diff) |
the functions handling almost everything I need
Diffstat (limited to 'structs.go')
-rw-r--r-- | structs.go | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/structs.go b/structs.go new file mode 100644 index 0000000..d07b103 --- /dev/null +++ b/structs.go @@ -0,0 +1,72 @@ +package matrix + +// Authinfo defines the fields returned after logging in +type Authinfo struct { + UserID string `json:"user_id"` + HomeServer string `json:"home_server"` + DeviceID string `json:"device_id"` + AccessToken string `json:"access_token"` +} + +// RespSync defines the response from the sync +type RespSync struct { + NextBatch string `json:"next_batch"` + AccountData struct { + Events []Event `json:"events"` + } `json:"account_data"` + Presence struct { + Events []Event `json:"events"` + } `json:"presence"` + Rooms struct { + Leave map[string]struct { + State struct { + Events []Event `json:"events"` + } `json:"state"` + Timeline struct { + Events []Event `json:"events"` + Limited bool `json:"limited"` + PrevBatch string `json:"prev_batch"` + } `json:"timeline"` + } `json:"leave"` + Join map[string]struct { + State struct { + Events []Event `json:"events"` + } `json:"state"` + Timeline struct { + Events []Event `json:"events"` + Limited bool `json:"limited"` + PrevBatch string `json:"prev_batch"` + } `json:"timeline"` + } `json:"join"` + Invite map[string]struct { + State struct { + Events []Event + } `json:"invite_state"` + } `json:"invite"` + } `json:"rooms"` +} + +// Event defines an event +type Event struct { + 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 string `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) + Redacts string `json:"redacts,omitempty"` // The event ID that was redacted if a m.room.redaction event + Unsigned map[string]interface{} `json:"unsigned"` // The unsigned portions of the event, such as age and prev_content + Content map[string]interface{} `json:"content"` // The JSON content of the event. + PrevContent map[string]interface{} `json:"prev_content,omitempty"` // The JSON prev_content of the event. +} + +// PackagedEvent bundles an event with more information regarding it, such as the roomname in which the event was produced. +type PackagedEvent struct { + RoomName string + Event Event +} + +// UploadResponse is the responce recieved from the upload +type UploadResponse struct { + ContentURI string `json:"content_uri,omitempty"` +} |