source

package
v3.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package source provides archive readers for different output formats.

Currently, the following formats are supported:

  • archive
  • Slack Export
  • dump

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("feature not supported")
View Source
var ErrUnknownLinkType = errors.New("unknown link type")

Functions

This section is empty.

Types

type ChunkDir

type ChunkDir struct {
	Storage
	// contains filtered or unexported fields
}

ChunkDir is the chunk directory source.

TODO: create an index of entries, otherwise it does the full scan of the directory.

func NewChunkDir

func NewChunkDir(d *chunk.Directory, fast bool) *ChunkDir

NewChunkDir creates a new ChurkDir source. It expects the attachments to be in the mattermost storage format. If the attachments are not in the mattermost storage format, it will assume they were not downloaded.

func (*ChunkDir) AllMessages

func (c *ChunkDir) AllMessages(channelID string) ([]slack.Message, error)

AllMessages returns all messages for the channel. Current restriction - it expects for all messages for the requested file to be in the file ID.json.gz. If messages for the channel are scattered across multiple file, it will not return all of them.

func (*ChunkDir) AllThreadMessages

func (c *ChunkDir) AllThreadMessages(channelID, threadID string) ([]slack.Message, error)

func (*ChunkDir) ChannelInfo

func (c *ChunkDir) ChannelInfo(_ context.Context, channelID string) (*slack.Channel, error)

func (*ChunkDir) Channels

func (c *ChunkDir) Channels(ctx context.Context) ([]slack.Channel, error)

func (*ChunkDir) Close

func (c *ChunkDir) Close() error

func (*ChunkDir) Latest

func (c *ChunkDir) Latest(ctx context.Context) (map[structures.SlackLink]time.Time, error)

func (*ChunkDir) Name

func (c *ChunkDir) Name() string

func (*ChunkDir) Type

func (c *ChunkDir) Type() string

func (*ChunkDir) Users

func (c *ChunkDir) Users() ([]slack.User, error)

func (*ChunkDir) WorkspaceInfo added in v3.0.6

func (c *ChunkDir) WorkspaceInfo() (*slack.AuthTestResponse, error)

type Dump

type Dump struct {
	Storage
	// contains filtered or unexported fields
}

func NewDump

func NewDump(ctx context.Context, fsys fs.FS, name string) (*Dump, error)

func (Dump) AllMessages

func (d Dump) AllMessages(channelID string) ([]slack.Message, error)

func (Dump) AllThreadMessages

func (d Dump) AllThreadMessages(channelID, threadID string) ([]slack.Message, error)

func (Dump) ChannelInfo

func (d Dump) ChannelInfo(_ context.Context, channelID string) (*slack.Channel, error)

func (Dump) Channels

func (d Dump) Channels(context.Context) ([]slack.Channel, error)

func (Dump) Close

func (d Dump) Close() error

func (Dump) Latest

func (d Dump) Latest(ctx context.Context) (map[structures.SlackLink]time.Time, error)

func (Dump) Name

func (d Dump) Name() string

func (Dump) Type

func (d Dump) Type() string

func (Dump) Users

func (d Dump) Users() ([]slack.User, error)

func (Dump) WorkspaceInfo added in v3.0.6

func (d Dump) WorkspaceInfo() (*slack.AuthTestResponse, error)

type Export

type Export struct {
	Storage
	// contains filtered or unexported fields
}

Export implements viewer.Sourcer for the zip file Slack export format.

func NewExport

func NewExport(fsys fs.FS, name string) (*Export, error)

func (*Export) AllMessages

func (e *Export) AllMessages(channelID string) ([]slack.Message, error)

AllMessages returns all channel messages without thread messages.

func (*Export) AllThreadMessages

func (e *Export) AllThreadMessages(channelID, threadID string) ([]slack.Message, error)

func (*Export) ChannelInfo

func (e *Export) ChannelInfo(ctx context.Context, channelID string) (*slack.Channel, error)

func (*Export) Channels

func (e *Export) Channels(context.Context) ([]slack.Channel, error)

func (*Export) Close

func (e *Export) Close() error

func (*Export) Latest

func (e *Export) Latest(ctx context.Context) (map[structures.SlackLink]time.Time, error)

func (*Export) Name

func (e *Export) Name() string

func (*Export) Type

func (e *Export) Type() string

func (*Export) Users

func (e *Export) Users() ([]slack.User, error)

func (*Export) WorkspaceInfo added in v3.0.6

func (e *Export) WorkspaceInfo() (*slack.AuthTestResponse, error)

type Flags

type Flags int16
const (
	FUnknown   Flags = 0
	FDirectory Flags = 1 << iota
	FZip
	FChunk
	FExport
	FDump
	FAvatars
	FMattermost
)

func Type

func Type(src string) (Flags, error)

func (Flags) Has added in v3.0.5

func (f Flags) Has(ff Flags) bool

func (Flags) String added in v3.0.5

func (f Flags) String() string

type STDump

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

STDump is the Storage for the dump format. Files are stored in the directories named after the channel IDs.

Directory structure:

./
  +-- <channel_id1>/
  |   +-- <file_id1>-filename.ext
  |   +-- <file_id2>-otherfile.ext
  |   +-- ...
  +-- <channel_id1>.json
  +-- <channel_id2>/
  |   +-- <file_id3>-filename.ext
  |   +-- <file_id4>-otherfile.ext
  |   +-- ...
  +-- <channel_id2>.json
  +-- ...

func NewDumpStorage

func NewDumpStorage(fsys fs.FS) (*STDump, error)

NewDumpStorage returns the file storage of the slackdumpdump format. fsys is the root of the dump.

func (*STDump) FS

func (r *STDump) FS() fs.FS

func (*STDump) File

func (r *STDump) File(id string, name string) (string, error)

type STMattermost

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

STMattermost is the Storage for the mattermost export format. Files are stored in the __uploads subdirectory, and the Storage is the filesystem of the __uploads directory.

Directory structure:

./__uploads/
  +-- <file_id1>/filename.ext
  +-- <file_id2>/otherfile.ext
  +-- ...

func NewMattermostStorage

func NewMattermostStorage(rootfs fs.FS) (*STMattermost, error)

NewMattermostStorage returns the resolver for the mattermost export format. rootfs is the root filesystem of the export.

func (*STMattermost) FS

func (r *STMattermost) FS() fs.FS

func (*STMattermost) File

func (r *STMattermost) File(id string, name string) (string, error)

type STStandard

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

STStandard is the Storage for the standard export format. Files are stored in the "attachments" subdirectories, and the Storage is the filesystem of the export.

Directory structure:

./
  +-- <channel_name>/
  |   +-- attachments/<file_id1>-filename.ext
  |   +-- attachments/<file_id2>-otherfile.ext
  |   +-- ...
  +-- ...

func NewStandardStorage

func NewStandardStorage(rootfs fs.FS, idx map[string]string) *STStandard

func (*STStandard) FS

func (r *STStandard) FS() fs.FS

func (*STStandard) File

func (r *STStandard) File(id string, _ string) (string, error)

type Sourcer

type Sourcer interface {
	// Name should return the name of the retriever underlying media, i.e.
	// directory or archive.
	Name() string
	// Type should return the type of the retriever, i.e. "chunk" or "export".
	Type() string
	// Channels should return all channels.
	Channels(ctx context.Context) ([]slack.Channel, error)
	// Users should return all users.
	Users() ([]slack.User, error)
	// AllMessages should return all messages for the given channel id.
	AllMessages(channelID string) ([]slack.Message, error)
	// AllThreadMessages should return all messages for the given tuple
	// (channelID, threadID).
	AllThreadMessages(channelID, threadID string) ([]slack.Message, error)
	// ChannelInfo should return the channel information for the given channel
	// id.
	ChannelInfo(ctx context.Context, channelID string) (*slack.Channel, error)
	// FS should return the filesystem with file attachments.
	FS() fs.FS
	// File should return the path of the file within the filesystem returned
	// by FS().
	File(fileID string, filename string) (string, error)
	// Latest should return the latest timestamp of the data.
	Latest(ctx context.Context) (map[structures.SlackLink]time.Time, error)
	// WorkspaceInfo should return the workspace information, if it is available.
	// If the call is not supported, it should return ErrNotSupported.
	WorkspaceInfo() (*slack.AuthTestResponse, error)

	io.Closer
}

Sourcer is an interface for retrieving data from different sources.

func Load

func Load(ctx context.Context, src string) (Sourcer, error)

Load loads the source from file src.

type Storage

type Storage interface {
	FS() fs.FS
	File(id string, name string) (string, error)
}

Storage is the interface for the file storage used by the source types.

Jump to

Keyboard shortcuts

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