Documentation
¶
Overview ¶
Package clips provides /api/clips/* endpoints.
Index ¶
- type AddNoteRequest
- type ClipFavoriteRepository
- type CreateRequest
- type DeleteRequest
- type Handler
- func (h *Handler) AddNote(c *echo.Context) error
- func (h *Handler) Create(c *echo.Context) error
- func (h *Handler) Delete(c *echo.Context) error
- func (h *Handler) Favorite(c *echo.Context) error
- func (h *Handler) List(c *echo.Context) error
- func (h *Handler) MyFavorites(c *echo.Context) error
- func (h *Handler) Notes(c *echo.Context) error
- func (h *Handler) PackForEmbed(cl *model.Clip) map[string]any
- func (h *Handler) RemoveNote(c *echo.Context) error
- func (h *Handler) SetEmojiRepo(r repository.EmojiRepository)
- func (h *Handler) SetFavoriteRepo(r ClipFavoriteRepository)
- func (h *Handler) SetInstanceRepo(r repository.InstanceRepository)
- func (h *Handler) SetNoteFieldResolver(r *entity.NoteFieldResolver)
- func (h *Handler) SetNoteMaterializer(m NoteMaterializer)
- func (h *Handler) SetNoteRepo(r repository.NoteRepository)
- func (h *Handler) SetQueryService(qs *corenote.QueryService)
- func (h *Handler) SetReactionReader(r entity.BufferedReactionsReader)
- func (h *Handler) SetRelationCache(rc *repository.RelationCache)
- func (h *Handler) SetUserRepo(r repository.UserRepository)
- func (h *Handler) Show(c *echo.Context) error
- func (h *Handler) Unfavorite(c *echo.Context) error
- func (h *Handler) Update(c *echo.Context) error
- type ListRequest
- type NoteMaterializer
- type NotesRequest
- type RemoveNoteRequest
- type ShowRequest
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddNoteRequest ¶
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) List ¶
List handles POST /api/clips/list.
frontend Paginator は cursor mode (untilId / sinceId) で叩いてくる。 offset は本家の paramDef に無いので、本家と同じく読まない (#3742)。
func (*Handler) MyFavorites ¶
MyFavorites handles POST /api/clips/my-favorites.
func (*Handler) PackForEmbed ¶
PackForEmbed packs a clip for the anonymous embed page (#2389).
viewer は nil 固定。isFavorited のような閲覧者依存フィールドは埋め込みでは 解決しない。
func (*Handler) RemoveNote ¶
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) Unfavorite ¶
Unfavorite handles POST /api/clips/unfavorite.
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 ¶
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.