msgconv

package
v0.0.0-...-3bed8bd Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EffectIDField  = "com.beeper.imessage.effect"
	MessageIDField = "com.beeper.imessage.id"
)
View Source
const CanConvertHEIF = false

Variables

This section is empty.

Functions

func ConvertHEIF

func ConvertHEIF(_ []byte) ([]byte, error)

func ConvertTIFF

func ConvertTIFF(data []byte) ([]byte, error)

func GetReactionTargetContent

func GetReactionTargetContent(ctx context.Context, raw json.RawMessage) *event.MessageEventContent

Types

type BeeperLinkPreview

type BeeperLinkPreview struct {
	MatchedURL   string `json:"matched_url"`
	CanonicalURL string `json:"og:url,omitempty"`
	Title        string `json:"og:title,omitempty"`
	Type         string `json:"og:type,omitempty"`
	Description  string `json:"og:description,omitempty"`

	ImageURL        id.ContentURIString      `json:"og:image,omitempty"`
	ImageEncryption *event.EncryptedFileInfo `json:"beeper:image:encryption,omitempty"`

	ImageSize   int    `json:"matrix:image:size,omitempty"`
	ImageWidth  int    `json:"og:image:width,omitempty"`
	ImageHeight int    `json:"og:image:height,omitempty"`
	ImageType   string `json:"og:image:type,omitempty"`
}

type ConvertedMessage

type ConvertedMessage struct {
	PartInfo imessage.MessagePartInfo
	Type     event.Type
	Content  *event.MessageEventContent
	Extra    map[string]any
}

type ExtendedPortalMethods

type ExtendedPortalMethods interface {
	QueueFileTransfer(ctx context.Context, msgID uuid.UUID, partInfo imessage.MessagePartInfo, fileName string, ad *ids.AttachmentDownloader) (id.ContentURIString, error)
}

type MessageConverter

type MessageConverter struct {
	PortalMethods

	ConvertHEIF bool
	ConvertTIFF bool
	ConvertMOV  bool
	ConvertCAF  bool
	MaxFileSize int64
	AsyncFiles  bool
	Threads     bool
}

func (*MessageConverter) BuildTapback

func (mc *MessageConverter) BuildTapback(ctx context.Context, msgID uuid.UUID, partInfo imessage.MessagePartInfo, tapback imessage.TapbackType, remove bool, originalContent *event.MessageEventContent) *direct.IMessage

func (*MessageConverter) ConvertRichLinkToBeeper

func (mc *MessageConverter) ConvertRichLinkToBeeper(ctx context.Context, msgID uuid.UUID, richLink *imessage.RichLinkMetadata) (output *BeeperLinkPreview)

func (*MessageConverter) IsPrivateChat

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

func (*MessageConverter) MultipartToIMessage

func (mc *MessageConverter) MultipartToIMessage(ctx context.Context, events []*event.Event) (*direct.IMessage, error)

func (*MessageConverter) ToMatrix

func (mc *MessageConverter) ToMatrix(ctx context.Context, msg *imessage.Message) []*ConvertedMessage

func (*MessageConverter) ToSMS

func (*MessageConverter) ToiMessage

func (mc *MessageConverter) ToiMessage(ctx context.Context, evt *event.Event, content *event.MessageEventContent) (*direct.IMessage, 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 *imessage.Message) (threadRoot, replyFallback id.EventID)
	GetiMessageThreadRoot(ctx context.Context, content *event.MessageEventContent) string

	GetIM() *direct.Connector
	GetData(ctx context.Context) *database.Portal
}

Jump to

Keyboard shortcuts

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