simplevent

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MPL-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatDelete

type ChatDelete struct {
	EventMeta
	OnlyForMe bool
}

ChatDelete is a simple implementation of bridgev2.RemoteChatDelete.

func (*ChatDelete) DeleteOnlyForMe

func (evt *ChatDelete) DeleteOnlyForMe() bool

type ChatInfoChange

type ChatInfoChange struct {
	EventMeta

	ChatInfoChange *bridgev2.ChatInfoChange
}

ChatInfoChange is a simple implementation of bridgev2.RemoteChatInfoChange.

func (*ChatInfoChange) GetChatInfoChange

func (evt *ChatInfoChange) GetChatInfoChange(ctx context.Context) (*bridgev2.ChatInfoChange, error)

type ChatResync

type ChatResync struct {
	EventMeta

	ChatInfo        *bridgev2.ChatInfo
	GetChatInfoFunc func(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error)

	LatestMessageTS        time.Time
	CheckNeedsBackfillFunc func(ctx context.Context, latestMessage *database.Message) (bool, error)
	BundledBackfillData    any
}

ChatResync is a simple implementation of bridgev2.RemoteChatResync.

If GetChatInfoFunc is set, it will be used to get the chat info. Otherwise, ChatInfo will be used.

If CheckNeedsBackfillFunc is set, it will be used to determine if backfill is required. Otherwise, the latest database message timestamp is compared to LatestMessageTS.

All four fields are optional.

func (*ChatResync) CheckNeedsBackfill

func (evt *ChatResync) CheckNeedsBackfill(ctx context.Context, latestMessage *database.Message) (bool, error)

func (*ChatResync) GetBundledBackfillData

func (evt *ChatResync) GetBundledBackfillData() any

func (*ChatResync) GetChatInfo

func (evt *ChatResync) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error)

type EventMeta

type EventMeta struct {
	Type              bridgev2.RemoteEventType
	LogContext        func(c zerolog.Context) zerolog.Context
	PortalKey         networkid.PortalKey
	UncertainReceiver bool
	Sender            bridgev2.EventSender
	CreatePortal      bool
	Timestamp         time.Time
	StreamOrder       int64
}

EventMeta is a struct containing metadata fields used by most event types.

func (*EventMeta) AddLogContext

func (evt *EventMeta) AddLogContext(c zerolog.Context) zerolog.Context

func (*EventMeta) GetPortalKey

func (evt *EventMeta) GetPortalKey() networkid.PortalKey

func (*EventMeta) GetSender

func (evt *EventMeta) GetSender() bridgev2.EventSender

func (*EventMeta) GetStreamOrder

func (evt *EventMeta) GetStreamOrder() int64

func (*EventMeta) GetTimestamp

func (evt *EventMeta) GetTimestamp() time.Time

func (*EventMeta) GetType

func (evt *EventMeta) GetType() bridgev2.RemoteEventType

func (*EventMeta) PortalReceiverIsUncertain

func (evt *EventMeta) PortalReceiverIsUncertain() bool

func (*EventMeta) ShouldCreatePortal

func (evt *EventMeta) ShouldCreatePortal() bool

type MarkUnread

type MarkUnread struct {
	EventMeta
	Unread bool
}

func (*MarkUnread) GetUnread

func (evt *MarkUnread) GetUnread() bool

type Message

type Message[T any] struct {
	EventMeta
	Data T

	ID            networkid.MessageID
	TransactionID networkid.TransactionID
	TargetMessage networkid.MessageID

	ConvertMessageFunc func(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, data T) (*bridgev2.ConvertedMessage, error)
	ConvertEditFunc    func(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, existing []*database.Message, data T) (*bridgev2.ConvertedEdit, error)
	HandleExistingFunc func(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, existing []*database.Message, data T) (bridgev2.UpsertResult, error)
}

Message is a simple implementation of bridgev2.RemoteMessage, bridgev2.RemoteEdit and bridgev2.RemoteMessageUpsert.

func (*Message[T]) ConvertEdit

func (evt *Message[T]) ConvertEdit(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, existing []*database.Message) (*bridgev2.ConvertedEdit, error)

func (*Message[T]) ConvertMessage

func (evt *Message[T]) ConvertMessage(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI) (*bridgev2.ConvertedMessage, error)

func (*Message[T]) GetID

func (evt *Message[T]) GetID() networkid.MessageID

func (*Message[T]) GetTargetMessage

func (evt *Message[T]) GetTargetMessage() networkid.MessageID

func (*Message[T]) GetTransactionID added in v0.21.0

func (evt *Message[T]) GetTransactionID() networkid.TransactionID

func (*Message[T]) HandleExisting

func (evt *Message[T]) HandleExisting(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, existing []*database.Message) (bridgev2.UpsertResult, error)

type MessageRemove

type MessageRemove struct {
	EventMeta

	TargetMessage networkid.MessageID
}

func (*MessageRemove) GetTargetMessage

func (evt *MessageRemove) GetTargetMessage() networkid.MessageID

type Reaction

type Reaction struct {
	EventMeta
	TargetMessage  networkid.MessageID
	EmojiID        networkid.EmojiID
	Emoji          string
	ExtraContent   map[string]any
	ReactionDBMeta any
}

Reaction is a simple implementation of bridgev2.RemoteReaction and bridgev2.RemoteReactionRemove.

func (*Reaction) GetReactionDBMetadata

func (evt *Reaction) GetReactionDBMetadata() any

func (*Reaction) GetReactionEmoji

func (evt *Reaction) GetReactionEmoji() (string, networkid.EmojiID)

func (*Reaction) GetReactionExtraContent

func (evt *Reaction) GetReactionExtraContent() map[string]any

func (*Reaction) GetRemovedEmojiID

func (evt *Reaction) GetRemovedEmojiID() networkid.EmojiID

func (*Reaction) GetTargetMessage

func (evt *Reaction) GetTargetMessage() networkid.MessageID

type ReactionSync

type ReactionSync struct {
	EventMeta
	TargetMessage networkid.MessageID
	Reactions     *bridgev2.ReactionSyncData
}

func (*ReactionSync) GetReactions

func (evt *ReactionSync) GetReactions() *bridgev2.ReactionSyncData

func (*ReactionSync) GetTargetMessage

func (evt *ReactionSync) GetTargetMessage() networkid.MessageID

type Receipt

type Receipt struct {
	EventMeta

	LastTarget networkid.MessageID
	Targets    []networkid.MessageID
	ReadUpTo   time.Time
}

func (*Receipt) GetLastReceiptTarget

func (evt *Receipt) GetLastReceiptTarget() networkid.MessageID

func (*Receipt) GetReadUpTo

func (evt *Receipt) GetReadUpTo() time.Time

func (*Receipt) GetReceiptTargets

func (evt *Receipt) GetReceiptTargets() []networkid.MessageID

type Typing

type Typing struct {
	EventMeta
	Timeout time.Duration
	Type    bridgev2.TypingType
}

func (*Typing) GetTimeout

func (evt *Typing) GetTimeout() time.Duration

func (*Typing) GetTypingType

func (evt *Typing) GetTypingType() bridgev2.TypingType

Jump to

Keyboard shortcuts

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