convert

package
v3.1.13 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package convert implements conversions to different Slackdump formats. It is a layer on top of the transformer.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyChunk    = errors.New("missing chunk")
	ErrNoLocFunction = errors.New("missing location function")
)

Functions

This section is empty.

Types

type DumpConverter added in v3.1.0

type DumpConverter struct {
	// contains filtered or unexported fields
}

func NewToDump added in v3.1.0

func NewToDump(src source.Sourcer, trg fsadapter.FS, opts ...DumpOption) *DumpConverter

NewToDump creates a new dump converter.

func (*DumpConverter) Convert added in v3.1.0

func (d *DumpConverter) Convert(ctx context.Context) error

type DumpOption added in v3.1.0

type DumpOption func(*DumpConverter)

func DumpWithIncludeFiles added in v3.1.0

func DumpWithIncludeFiles(b bool) DumpOption

func DumpWithLogger added in v3.1.0

func DumpWithLogger(log *slog.Logger) DumpOption

type FileCopier added in v3.1.0

type FileCopier struct {
	// contains filtered or unexported fields
}

func NewFileCopier added in v3.1.0

func NewFileCopier(src source.Sourcer, trg fsadapter.FS, trgLoc func(*slack.Channel, *slack.File) string, enabled bool) *FileCopier

func (*FileCopier) Copy added in v3.1.0

func (c *FileCopier) Copy(ch *slack.Channel, msg *slack.Message) error

Copy iterates through the files in the message and copies them to the target directory. Source file location is determined by calling the srcFileLoc function, joined with the chunk directory name. target file location — by calling trgFileLoc function, and is relative to the target fsadapter root.

type Option added in v3.1.0

type Option func(*options)

func WithIgnoreCopyErrors added in v3.1.1

func WithIgnoreCopyErrors(b bool) Option

func WithIncludeAvatars added in v3.0.4

func WithIncludeAvatars(b bool) Option

WithIncludeAvatars sets the IncludeAvatars option.

func WithIncludeFiles

func WithIncludeFiles(b bool) Option

WithIncludeFiles sets the IncludeFiles option.

func WithLogger

func WithLogger(lg *slog.Logger) Option

WithLogger sets the logger.

func WithTrgFileLoc

func WithTrgFileLoc(fn func(*slack.Channel, *slack.File) string) Option

WithTrgFileLoc sets the TrgFileLoc function.

type SourceEncoder added in v3.1.0

type SourceEncoder struct {
	// contains filtered or unexported fields
}

SourceEncoder allows to convert any source to a chunked format.

func NewSourceEncoder added in v3.1.0

func NewSourceEncoder(src source.Sourcer, fsa fsadapter.FS, enc chunk.Encoder, opts ...Option) *SourceEncoder

func (*SourceEncoder) Convert added in v3.1.0

func (s *SourceEncoder) Convert(ctx context.Context) error

type Target added in v3.1.0

type Target interface {
	// Convert should convert the data for the single channel and save it to
	// the target format.
	transform.Converter
	// Users should convert and write users.
	Users(ctx context.Context, uu []slack.User) error
	// Channels should converts and write channels.
	Channels(ctx context.Context, uu []slack.Channel) error
	// WorkspaceInfo writes workspace info.
	WorkspaceInfo(ctx context.Context, wi *slack.AuthTestResponse) error
}

Target is the interface for writing the target format.

type ToExport added in v3.1.0

type ToExport struct {
	// contains filtered or unexported fields
}

ToExport is a converter between Chunk and Export formats. Zero value is not usable.

func NewToExport added in v3.1.0

func NewToExport(src source.Sourcer, trg fsadapter.FS, opt ...Option) *ToExport

NewToExport returns the converter from any source to export format. src is the Source to be converted (e.g. chunk or database), trgfs is the target FS adapter where files and data will be written. By default, the converter does not include files and avatars. The default storage format for both source and destination is Mattermost, use functional options to configure this behaviour.

func (*ToExport) Convert added in v3.1.0

func (c *ToExport) Convert(ctx context.Context) error

Convert converts the chunk directory contents to the export format. It validates the input parameters.

func (*ToExport) Validate added in v3.1.0

func (c *ToExport) Validate() error

Validate validates the input parameters.

Directories

Path Synopsis
Package mock_convert is a generated GoMock package.
Package mock_convert is a generated GoMock package.
fileproc
Package fileproc is the file processor that can be used in conjunction with the transformer.
Package fileproc is the file processor that can be used in conjunction with the transformer.

Jump to

Keyboard shortcuts

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