mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Some checks failed
Includes transparent migration from deprecated MSC fields still used in Synapse to later revision.
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
package event
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"go.mau.fi/util/jsontime"
|
|
|
|
"maunium.net/go/mautrix/id"
|
|
)
|
|
|
|
type ScheduledDelayedEvent struct {
|
|
DelayID id.DelayID `json:"delay_id"`
|
|
RoomID id.RoomID `json:"room_id"`
|
|
Type Type `json:"type"`
|
|
StateKey *string `json:"state_key,omitempty"`
|
|
Delay int64 `json:"delay"`
|
|
RunningSince jsontime.UnixMilli `json:"running_since"`
|
|
Content Content `json:"content"`
|
|
}
|
|
|
|
func (e ScheduledDelayedEvent) AsEvent(eventID id.EventID, ts jsontime.UnixMilli) (*Event, error) {
|
|
evt := &Event{
|
|
ID: eventID,
|
|
RoomID: e.RoomID,
|
|
Type: e.Type,
|
|
StateKey: e.StateKey,
|
|
Content: e.Content,
|
|
Timestamp: ts.UnixMilli(),
|
|
}
|
|
return evt, evt.Content.ParseRaw(evt.Type)
|
|
}
|
|
|
|
type FinalisedDelayedEvent struct {
|
|
DelayedEvent *ScheduledDelayedEvent `json:"scheduled_event"`
|
|
Outcome DelayOutcome `json:"outcome"`
|
|
Reason DelayReason `json:"reason"`
|
|
Error json.RawMessage `json:"error,omitempty"`
|
|
EventID id.EventID `json:"event_id,omitempty"`
|
|
Timestamp jsontime.UnixMilli `json:"origin_server_ts"`
|
|
}
|
|
|
|
type DelayStatus string
|
|
|
|
var (
|
|
DelayStatusScheduled DelayStatus = "scheduled"
|
|
DelayStatusFinalised DelayStatus = "finalised"
|
|
)
|
|
|
|
type DelayAction string
|
|
|
|
var (
|
|
DelayActionSend DelayAction = "send"
|
|
DelayActionCancel DelayAction = "cancel"
|
|
DelayActionRestart DelayAction = "restart"
|
|
)
|
|
|
|
type DelayOutcome string
|
|
|
|
var (
|
|
DelayOutcomeSend DelayOutcome = "send"
|
|
DelayOutcomeCancel DelayOutcome = "cancel"
|
|
)
|
|
|
|
type DelayReason string
|
|
|
|
var (
|
|
DelayReasonAction DelayReason = "action"
|
|
DelayReasonError DelayReason = "error"
|
|
DelayReasonDelay DelayReason = "delay"
|
|
)
|