media

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListAttachments action.GTSAction = func(ctx context.Context) error {
	list, err := setupList(ctx)
	if err != nil {
		return err
	}

	defer func() {

		if err := list.shutdown(); err != nil {
			log.Error(ctx, err)
		}
	}()

	var (
		mediaPath = config.GetStorageLocalBasePath()
		filter    func(*gtsmodel.MediaAttachment) string
	)

	switch {
	case list.localOnly:
		filter = func(m *gtsmodel.MediaAttachment) string {
			if m.RemoteURL != "" {

				return ""
			}

			return path.Join(mediaPath, m.File.Path)
		}

	case list.remoteOnly:
		filter = func(m *gtsmodel.MediaAttachment) string {
			if m.RemoteURL == "" {

				return ""
			}

			return path.Join(mediaPath, m.File.Path)
		}

	default:
		filter = func(m *gtsmodel.MediaAttachment) string {
			return path.Join(mediaPath, m.File.Path)
		}
	}

	attachments, err := list.GetAllAttachmentPaths(ctx, filter)
	if err != nil {
		return err
	}

	for _, a := range attachments {
		_, _ = list.out.WriteString(a + "\n")
	}
	return nil
}

ListAttachments lists local, remote, or all attachment paths.

View Source
var ListEmojis action.GTSAction = func(ctx context.Context) error {
	list, err := setupList(ctx)
	if err != nil {
		return err
	}

	defer func() {

		if err := list.shutdown(); err != nil {
			log.Error(ctx, err)
		}
	}()

	var (
		mediaPath = config.GetStorageLocalBasePath()
		filter    func(*gtsmodel.Emoji) string
	)

	switch {
	case list.localOnly:
		filter = func(e *gtsmodel.Emoji) string {
			if e.ImageRemoteURL != "" {

				return ""
			}

			return path.Join(mediaPath, e.ImagePath)
		}

	case list.remoteOnly:
		filter = func(e *gtsmodel.Emoji) string {
			if e.ImageRemoteURL == "" {

				return ""
			}

			return path.Join(mediaPath, e.ImagePath)
		}

	default:
		filter = func(e *gtsmodel.Emoji) string {
			return path.Join(mediaPath, e.ImagePath)
		}
	}

	emojis, err := list.GetAllEmojisPaths(ctx, filter)
	if err != nil {
		return err
	}

	for _, e := range emojis {
		_, _ = list.out.WriteString(e + "\n")
	}
	return nil
}

ListEmojis lists local, remote, or all emoji filepaths.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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