clips

package
v0.0.0-...-9914b64 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clips provides /api/clips/* endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddNoteRequest

type AddNoteRequest struct {
	ClipID string `json:"clipId"`
	NoteID string `json:"noteId"`
}

AddNoteRequest is the request body for clips/add-note.

type ClipFavoriteRepository

type ClipFavoriteRepository interface {
	Create(fav *model.ClipFavorite) error
	Delete(userID, clipID string) error
	ListByUser(userID string) ([]*model.ClipFavorite, error)
	Exists(userID, clipID string) (bool, error)
	// CountByClip returns the favorite count used by the clip response's
	// favoritedCount field (#1562).
	CountByClip(clipID string) (int64, error)
}

ClipFavoriteRepository is the interface for clip favorite operations.

type CreateRequest

type CreateRequest struct {
	Name        string  `json:"name"`
	Description *string `json:"description"`
	IsPublic    bool    `json:"isPublic"`
}

CreateRequest is the request body for clips/create.

type DeleteRequest

type DeleteRequest struct {
	ClipID string `json:"clipId"`
}

DeleteRequest is the request body for clips/delete.

type Handler

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

Handler handles clip-related API endpoints.

func NewHandler

func NewHandler(
	svc *coreclip.Service,
	idGen id.Generator,
	noteHider *notehide.Hider,
	entityPacker *entity.Packer,
	metaRepo repository.MetaRepository,
	ugcVisibilityFn func() string,
	mutingRepo repository.MutingRepository,
	blockingRepo repository.BlockingRepository,
) *Handler

NewHandler creates a new clips Handler. noteHider applies the per-viewer hideNote gate to the notes this handler packs (#3786) and entityPacker is the Packer it packs entities with (#3790). metaRepo backs the clips/notes blocked-host filter (#1562). ugcVisibilityFn is a live lookup of meta.ugcVisibilityForVisitor, read on every request so that changing the setting takes effect without a restart. mutingRepo and blockingRepo back the clips/notes muted-user / blocked-user filters (#1562).

func (*Handler) AddNote

func (h *Handler) AddNote(c *echo.Context) error

AddNote handles POST /api/clips/add-note.

func (*Handler) Create

func (h *Handler) Create(c *echo.Context) error

Create handles POST /api/clips/create.

func (*Handler) Delete

func (h *Handler) Delete(c *echo.Context) error

Delete handles POST /api/clips/delete.

func (*Handler) Favorite

func (h *Handler) Favorite(c *echo.Context) error

Favorite handles POST /api/clips/favorite.

func (*Handler) List

func (h *Handler) List(c *echo.Context) error

List handles POST /api/clips/list.

frontend Paginator は cursor mode (untilId / sinceId) で叩いてくる。 offset は本家の paramDef に無いので、本家と同じく読まない (#3742)。

func (*Handler) MyFavorites

func (h *Handler) MyFavorites(c *echo.Context) error

MyFavorites handles POST /api/clips/my-favorites.

func (*Handler) Notes

func (h *Handler) Notes(c *echo.Context) error

Notes handles POST /api/clips/notes.

func (*Handler) PackForEmbed

func (h *Handler) PackForEmbed(cl *model.Clip) map[string]any

PackForEmbed packs a clip for the anonymous embed page (#2389).

viewer は nil 固定。isFavorited のような閲覧者依存フィールドは埋め込みでは 解決しない。

func (*Handler) RemoveNote

func (h *Handler) RemoveNote(c *echo.Context) error

RemoveNote handles POST /api/clips/remove-note.

func (*Handler) SetEmojiRepo

func (h *Handler) SetEmojiRepo(r repository.EmojiRepository)

SetEmojiRepo attaches an EmojiRepository so custom emoji shortcodes in note text and user displayNames get resolved to URLs.

func (*Handler) SetFavoriteRepo

func (h *Handler) SetFavoriteRepo(r ClipFavoriteRepository)

SetFavoriteRepo attaches a ClipFavoriteRepository for favorite endpoints.

func (*Handler) SetInstanceRepo

func (h *Handler) SetInstanceRepo(r repository.InstanceRepository)

SetInstanceRepo attaches an InstanceRepository so clips/notes populates UserLite.Instance for remote users (#277).

func (*Handler) SetNoteFieldResolver

func (h *Handler) SetNoteFieldResolver(r *entity.NoteFieldResolver)

SetNoteFieldResolver wires the shared resolver that fills Files / MyReaction / Channel on packed notes (#426)。

func (*Handler) SetNoteMaterializer

func (h *Handler) SetNoteMaterializer(m NoteMaterializer)

SetNoteMaterializer attaches the ephemeral-note materializer. Optional.

func (*Handler) SetNoteRepo

func (h *Handler) SetNoteRepo(r repository.NoteRepository)

SetNoteRepo wires a NoteRepository used by the clips/notes renote-nested mute/block check (#1630).

func (*Handler) SetQueryService

func (h *Handler) SetQueryService(qs *corenote.QueryService)

SetQueryService wires a note.QueryService used by AddNote to enforce note visibility (#1456). When unwired, AddNote fails closed with 404 NO_SUCH_NOTE so that a clip never ends up referencing a note whose visibility the viewer is not entitled to.

func (*Handler) SetReactionReader

func (h *Handler) SetReactionReader(r entity.BufferedReactionsReader)

SetReactionReader wires a BufferedReactionsReader so PackNote / PackNotes can merge in-flight buffered reaction deltas (#647)。

func (*Handler) SetRelationCache

func (h *Handler) SetRelationCache(rc *repository.RelationCache)

SetRelationCache wires the per-user relation cache used by the mute / block filter (#3607). nil keeps reading the repositories.

func (*Handler) SetUserRepo

func (h *Handler) SetUserRepo(r repository.UserRepository)

SetUserRepo wires a UserRepository so clips/notes filters out notes that match the viewer's hardMutedWords (#787).

func (*Handler) Show

func (h *Handler) Show(c *echo.Context) error

Show handles POST /api/clips/show.

func (*Handler) Unfavorite

func (h *Handler) Unfavorite(c *echo.Context) error

Unfavorite handles POST /api/clips/unfavorite.

func (*Handler) Update

func (h *Handler) Update(c *echo.Context) error

Update handles POST /api/clips/update.

type ListRequest

type ListRequest struct {
	Limit     *jsnum.Int `json:"limit"`
	SinceID   string     `json:"sinceId"`
	UntilID   string     `json:"untilId"`
	SinceDate *jsnum.Int `json:"sinceDate"`
	UntilDate *jsnum.Int `json:"untilDate"`
}

ListRequest is the request body for clips/list.

type NoteMaterializer

type NoteMaterializer interface {
	EnsureNote(ctx context.Context, noteID string) (*model.Note, error)
}

NoteMaterializer promotes a relay-delivered note out of the ephemeral store into a real database row (#2332)。実装は core/ephemeral.Materializer。

clip 追加は core/clip 側でも materialize するが、この handler の RequireVisible 事前チェックが先に 404 を返してしまうため、ここでも通す。

type NotesRequest

type NotesRequest struct {
	ClipID    string     `json:"clipId"`
	UntilID   string     `json:"untilId"`
	SinceID   string     `json:"sinceId"`
	SinceDate *jsnum.Int `json:"sinceDate"`
	UntilDate *jsnum.Int `json:"untilDate"`
	Limit     *jsnum.Int `json:"limit"`
	Search    *string    `json:"search"`
}

NotesRequest is the request body for clips/notes.

type RemoveNoteRequest

type RemoveNoteRequest struct {
	ClipID string `json:"clipId"`
	NoteID string `json:"noteId"`
}

RemoveNoteRequest is the request body for clips/remove-note.

type ShowRequest

type ShowRequest struct {
	ClipID string `json:"clipId"`
}

ShowRequest is the request body for clips/show.

type UpdateRequest

type UpdateRequest struct {
	ClipID string `json:"clipId"`
	// upstream paramDef の name は `{type:'string', minLength:1}` で nullable
	// ではない。`name: null` は型違反なので 400 にする必要があり、省略 (不変)
	// と区別するため RawMessage で受ける。
	Name        json.RawMessage `json:"name"`
	Description *string         `json:"description"`
	IsPublic    *bool           `json:"isPublic"`
}

UpdateRequest is the request body for clips/update.

Jump to

Keyboard shortcuts

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