archive

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const ASPublic = "https://www.w3.org/ns/activitystreams#Public"

Variables

This section is empty.

Functions

func BlueskyImport

func BlueskyImport(
	authClient *auth.Client,
	archiveFolderPath string,
	statusMapFile string,
	attachmentMapFile string,
) error

func DownloadAttachment

func DownloadAttachment(
	ctx context.Context,
	mediaDownloadLimiter *rate.Limiter,
	mediaDownloadClient *http.Client,
	statusURI string,
	localDir string,
	url string,
) (string, string, error)

DownloadAttachment downloads an attachment to a local directory, building the full path from the remote filename. It returns the local path and the MIME type (or "application/octet-stream" if the remote server doesn't send one). It uses slog and takes the status URI for log context.

func Export

func Export(
	authClient *auth.Client,
	archiveFolderPath string,
) error

Export exports a vaguely Mastodon-compatible archive to file (actually a folder path).

func Import

func Import(
	authClient *auth.Client,
	file string,
	statusMapFile string,
	attachmentMapFile string,
	allowMissingCustomEmojis bool,
) error

func PixelfedImport

func PixelfedImport(
	authClient *auth.Client,
	file string,
	statusMapFile string,
	attachmentMapFile string,
	attachmentDirectory string,
) error

Types

type Activity

type Activity struct {
	Type      string          `json:"type"`
	RawObject json.RawMessage `json:"object"`
}

func (*Activity) Object

func (a *Activity) Object() *Object

type Actor

type Actor struct {
	Id                string `json:"id"`
	Followers         string `json:"followers"`
	Outbox            string `json:"outbox"`
	PreferredUsername string `json:"preferredUsername"`
	Url               string `json:"url"`
}

type Attachment

type Attachment struct {
	Type          string    `json:"type"`
	MediaType     string    `json:"mediaType"`
	Url           string    `json:"url"`
	Name          *string   `json:"name"`
	RawFocalPoint []float64 `json:"focalPoint,omitempty"`
	Icon          *Icon     `json:"icon,omitempty"`
}

func (*Attachment) FocalPointX

func (a *Attachment) FocalPointX() *float64

func (*Attachment) FocalPointY

func (a *Attachment) FocalPointY() *float64

type Emoji

type Emoji struct {
	Type string `json:"type"`
	Name string `json:"name"`
	Icon Icon   `json:"icon"`
}

func (*Emoji) GetType

func (e *Emoji) GetType() string

type Icon

type Icon struct {
	Type      string `json:"type"`
	MediaType string `json:"mediaType"`
	Url       string `json:"url"`
}

type MentionOrHashtag

type MentionOrHashtag struct {
	Type string `json:"type"`
	Name string `json:"name"`
	Href string `json:"href"`
}

func (*MentionOrHashtag) GetType

func (m *MentionOrHashtag) GetType() string

type Object

type Object struct {
	Id            string            `json:"id"`
	Type          string            `json:"type"`
	Summary       *string           `json:"summary,omitempty"`
	InReplyTo     *string           `json:"inReplyTo,omitempty"`
	Published     time.Time         `json:"published"`
	Url           string            `json:"url"`
	To            []string          `json:"to,omitempty"`
	Cc            []string          `json:"cc"`
	Sensitive     bool              `json:"sensitive"`
	Content       string            `json:"content"`
	ContentMap    map[string]string `json:"contentMap,omitempty"`
	DirectMessage bool              `json:"directMessage"`
	Attachments   []*Attachment     `json:"attachment,omitempty"`
	RawTags       []json.RawMessage `json:"tag,omitempty"`
}

func (*Object) Language

func (o *Object) Language() *string

func (*Object) Tags

func (o *Object) Tags() []Tag

func (*Object) TargetsSpecificUsersInToOrCc

func (o *Object) TargetsSpecificUsersInToOrCc(a *Actor) bool

TargetsSpecificUsersInToOrCc is true if the status is addressed to anything that isn't the public or followers collections or the actor that posted it.

func (*Object) Visibility

func (o *Object) Visibility() Visibility

type Outbox

type Outbox struct {
	OrderedItems []Activity `json:"orderedItems"`
}

func (*Outbox) Notes

func (o *Outbox) Notes() map[string]*Object

Notes returns a map of AP ID URIs to Note objects.

type PixelfedArchiveStatus

type PixelfedArchiveStatus struct {
	models.Status

	// ContentText is probably the Pixelfed version of `source`.
	// If this is missing, the `content` will be an empty string.
	ContentText *string `json:"content_text"`

	// Place is an optional location.
	Place *PixelfedPlace `json:"place"`

	// CommentsDisabled surfaces Pixelfed's own interaction controls.
	CommentsDisabled bool `json:"comments_disabled"`
}

PixelfedArchiveStatus is a Mastodon API status with a few extra fields.

func (*PixelfedArchiveStatus) CreateParams

func (p *PixelfedArchiveStatus) CreateParams(inReplyToID *string, mediaIDs []string) (*statuses.StatusCreateParams, error)

type PixelfedPlace

type PixelfedPlace struct {
	ID      int    `json:"id"`
	Slug    string `json:"slug"`
	Name    string `json:"name"`
	Country string `json:"country"`
}

PixelfedPlace describes a geotagged location. TODO: (Vyr) not currently used. Also, figure out the full set of fields.

type Tag

type Tag interface {
	GetType() string
}

type Visibility

type Visibility string
const (
	VisibilityPublic   Visibility = "public"
	VisibilityUnlisted Visibility = "unlisted"
	VisibilityPrivate  Visibility = "private"
	VisibilityDirect   Visibility = "direct"
)

Jump to

Keyboard shortcuts

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