msgconv

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedMsgType  = errors.New("unsupported msgtype")
	ErrMediaDownloadFailed = errors.New("failed to download media")
	ErrMediaDecryptFailed  = errors.New("failed to decrypt media")
	ErrMediaConvertFailed  = errors.New("failed to convert")
	ErrMediaUploadFailed   = errors.New("failed to upload media")
	ErrInvalidGeoURI       = errors.New("invalid `geo:` URI in message")
)
View Source
var URLRegex = regexp.MustCompile(`https?://[^\s/_*]+(?:/\S*)?`)

Functions

func CanConvertSignal

func CanConvertSignal(dm *signalpb.DataMessage) bool

Types

type BeeperLinkPreview

type BeeperLinkPreview struct {
	mautrix.RespPreviewURL
	MatchedURL      string                   `json:"matched_url"`
	ImageEncryption *event.EncryptedFileInfo `json:"beeper:image:encryption,omitempty"`
}

type ConvertedMessage

type ConvertedMessage struct {
	Parts       []*ConvertedMessagePart
	Timestamp   uint64
	DisappearIn uint32
}

func (*ConvertedMessage) MergeCaption

func (cm *ConvertedMessage) MergeCaption()

type ConvertedMessagePart

type ConvertedMessagePart struct {
	Type    event.Type
	Content *event.MessageEventContent
	Extra   map[string]any
}

type ExtendedPortalMethods

type ExtendedPortalMethods interface {
	QueueFileTransfer(ctx context.Context, msgTS uint64, fileName string, ap *signalpb.AttachmentPointer) (id.ContentURIString, error)
}

type MessageConverter

type MessageConverter struct {
	PortalMethods

	SignalFmtParams *signalfmt.FormatParams
	MatrixFmtParams *matrixfmt.HTMLParser

	ConvertVoiceMessages bool
	ConvertGIFToAPNG     bool
	MaxFileSize          int64
	AsyncFiles           bool
}

func (*MessageConverter) ConvertDisappearingTimerChangeToMatrix

func (mc *MessageConverter) ConvertDisappearingTimerChangeToMatrix(ctx context.Context, timer uint32, updatePortal bool) *ConvertedMessagePart

func (*MessageConverter) IsPrivateChat

func (mc *MessageConverter) IsPrivateChat(ctx context.Context) bool

func (*MessageConverter) ToMatrix

func (*MessageConverter) ToSignal

func (mc *MessageConverter) ToSignal(ctx context.Context, evt *event.Event, content *event.MessageEventContent, relaybotFormatted bool) (*signalpb.DataMessage, error)

type PortalMethods

type PortalMethods interface {
	UploadMatrixMedia(ctx context.Context, data []byte, fileName, contentType string) (id.ContentURIString, error)
	DownloadMatrixMedia(ctx context.Context, uri id.ContentURIString) ([]byte, error)
	GetMatrixReply(ctx context.Context, msg *signalpb.DataMessage_Quote) (replyTo id.EventID, replyTargetSender id.UserID)
	GetSignalReply(ctx context.Context, content *event.MessageEventContent) *signalpb.DataMessage_Quote

	GetClient(ctx context.Context) *signalmeow.Client

	GetData(ctx context.Context) *database.Portal
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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