meta

package
v0.0.0-...-b9ff7a5 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: AGPL-3.0 Imports: 18 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveAds

func ActiveAds(repo repository.AdRepository, now time.Time) []map[string]any

ActiveAds fetches the ads active at now via repo and projects them into the Misskey-compatible shape of the `ads` field. Returns an empty slice when the repo is unwired (tests) or the fetch fails, keeping the response stable.

/api/meta と、frontend の shell に埋める meta (internal/server の buildMetaJSON) の両方がこれを使う (#3967)。射影を 1 か所にして、2 つの経路で広告の形が 食い違わないようにする。 フロントエンドが notesPerOneAd と組み合わせて timeline に差し込む前提。

func ClearBrowserCache

func ClearBrowserCache(c *echo.Context) error

ClearBrowserCache handles /api/clear-browser-cache like upstream (ApiServerService.ts, which registers it for GET and POST only since 2026.11.1): GET and POST answer 204 with Clear-Site-Data, which makes the browser drop its caches. Any other method answers 405. Upstream answers HEAD with 405 too (fastify's exposeHeadRoutes routes it to the same handler) and the rest with fastify's default 404 (docs/divergence/api.md). It needs no authentication.

frontend の「キャッシュを消す」(utility/clear-cache.ts) はこれを GET で呼び、 失敗を握り潰す。無いと 404 になっても画面には出ず、キャッシュが消えないまま になる (#3926)。

**別のサイトが起こした要求 (Sec-Fetch-Site が cross-site か same-site) には Clear-Site-Data を付けない。** frontend は自分のオリジンから呼ぶ (same-origin) ので、 この判定に当たらない。

func NoteDeliveryPluginNames

func NoteDeliveryPluginNames(f NoteDeliveryPlugins) []string

NoteDeliveryPluginNames returns the value of the additive `noteDeliveryPlugins` field: never nil, so it is written as `[]`.

**投稿フォームが、ボタンを出すかの判定に使う** (#4202)。frontend に同梱した プラグインでも、サーバーで無効にしたもの (`enabled: false`) は pluginOptions を 受け取らない。ボタンを出すと、指定した投稿が毎回 `INVALID_PARAM` になる。

func NoteSearchableScope

func NoteSearchableScope(fts *config.FulltextSearchOptions, m *config.MeilisearchOptions) string

NoteSearchableScope derives the "local"/"global" search scope flag from the search provider configuration.

upstream Misskey #17341 (= 2026.5.0 fix / triage #1008): "local" を返すのは fulltextSearch.provider が "meilisearch" かつ meilisearch.scope が "local" のときだけで、それ以外は全て "global"。旧 upstream 実装は meilisearch block の有無だけ見ていたため、provider が sqlLike / none でも meilisearch.scope 設定が誤って反映される bug があった。本関数は新 upstream semantics に合わせる。

mk-go 視点: 旧実装は default "local" を返していたが、これは sqlLike fallback でも remote note を検索できる挙動と矛盾していた (UI が local 検索 only と 解釈してしまう)。upstream 修正と同じく default "global" にすることで sqlLike / none の実挙動とも整合する。

func PackTheme

func PackTheme(raw *string) any

PackTheme converts a stored JSON5 theme into JSON for the client (#2583).

**Misskey のテーマは JSON5 で配布される。** キーが無引用符で文字列が シングルクォート。本家 MetaEntityService.pack は「クライアントの手間を減らす ためあらかじめJSONに変換しておく」として同じ変換をしており、生のまま返すと frontend の `JSON.parse(instance.defaultDarkTheme)` (boot/common.ts) が落ちて 起動しなくなる。

**読めなければ null を返す。** 本家も catch で握りつぶしている。壊れたテーマ 1 つでインスタンス全体を落とさない。

func PolicyBool

func PolicyBool(policies map[string]any, key string) bool

PolicyBool reads a boolean policy value from role.DefaultPolicies() output with a conservative default. Unknown or non-bool values fall back to false so the client never sees an undefined flag in the features block.

Types

type ChunkedUploadCapability

type ChunkedUploadCapability func() (chunkSize int64, ok bool)

ChunkedUploadCapability describes the chunked upload support advertised on /api/meta (#2313). ok=false means the instance cannot serve chunked uploads, in which case the field is omitted entirely.

type Handler

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

Handler handles meta-related API endpoints.

func NewHandler

func NewHandler(cfg *config.Config, metaRepo repository.MetaRepository) *Handler

NewHandler creates a new meta Handler.

func (*Handler) DropLocal

func (h *Handler) DropLocal()

DropLocal drops the cached /api/meta bodies of this process (#3721). It is what the cache list of internal/server calls (docs/architecture.md 4.4). No other process is told.

func (*Handler) InvalidateResponseCache

func (h *Handler) InvalidateResponseCache()

InvalidateResponseCache drops the cached /api/meta bodies. Wired by the router to the same signals that invalidate the meta row cache (the local update hook and the cross-worker `metaUpdated` event, #1740) and to ad mutations, so an admin change shows up immediately instead of after the TTL.

func (*Handler) Meta

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

Meta returns server metadata. POST /api/meta Meta handles POST /api/meta. TS互換: detail (boolean, default true)。falseの場合は簡易レスポンスを返す。

func (*Handler) Ping

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

Ping returns a simple pong response. POST /api/ping

func (*Handler) ServerInfo

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

ServerInfo returns the public subset of server machine statistics.

GET|POST /api/server-info

**公開エンドポイントは machine / cpu / mem / fs のみ** (upstream public server-info.ts)。os / node / psql / redis / net は admin 専用で、未認証には 出さない。

`enableServerMachineStats` が無効なら空の shape を返す。**フィールドごと 落とさない** — frontend の server-metric widget は各キーを直接読む。

func (*Handler) SetAdRepo

func (h *Handler) SetAdRepo(r repository.AdRepository)

SetAdRepo wires an AdRepository for the `ads` field on the /api/meta response. When unset, ads is returned as an empty array so existing tests without ad wiring keep passing.

func (*Handler) SetChunkedUploadCapability

func (h *Handler) SetChunkedUploadCapability(f ChunkedUploadCapability)

SetChunkedUploadCapability wires the capability probe for the additive `chunkedUpload` field. Unset (or reporting ok=false) omits the field, which is what clients use to fall back to the single-request upload path — pure Misskey never emits it either.

func (*Handler) SetNoteDeliveryPlugins

func (h *Handler) SetNoteDeliveryPlugins(f NoteDeliveryPlugins)

SetNoteDeliveryPlugins wires the additive `noteDeliveryPlugins` field. Unset reports an empty list.

func (*Handler) SetProxyAccountResolver

func (h *Handler) SetProxyAccountResolver(r ProxyAccountResolver)

SetProxyAccountResolver wires the resolver used to populate the `proxyAccountName` field on MetaDetailed responses. When unset (tests or pre-setup instances), the field is reported as null.

func (*Handler) SetSetupDetector

func (h *Handler) SetSetupDetector(d *SetupDetector)

SetSetupDetector wires the detector behind the `requireSetup` field. Unset judges by rootUserId alone.

type NoteDeliveryPlugins

type NoteDeliveryPlugins func() []string

NoteDeliveryPlugins lists the names of the server plugins whose options notes/create accepts in pluginOptions (#4202). 起動の後は変わらない。

type ProxyAccountResolver

type ProxyAccountResolver func() (string, bool)

ProxyAccountResolver returns the username of the "proxy" system account. 呼び出し側 (router) が SystemAccountRepository + UserRepository を使って type='proxy' の system_account から userId を辿り、username を返す。 解決できないときは "" と false を返す。

type SetupDetector

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

SetupDetector decides whether the client should show the initial setup screen. It carries the local-user counter that the server assembly wires in.

数え方はパッケージのグローバルではなく、組み立てで作った値として `/api/meta` と frontend の shell の両方へ渡す (#3782)。グローバルのときは 1 回の配線で 両方に効いたが、今は片方だけ渡し忘れることが起こり得るので、配線のテスト (`internal/server/setup_detector_wiring_test.go`) が両方を見る。

nil の `*SetupDetector` と、数え方を持たない値は「数えない」として扱う。

利用者を一度でも観測した印 (seen) も、この値が持つ (#3803)。以前はパッケージの 変数だったので、DB を戻してメンテナンスから抜け、組み立て直した後の世代にも 前の DB で観測した印が残った。組み立てるたびに NewSetupDetector で作り直すので、 新しい世代は最初のリクエストで 1 回だけ数え直す。

func NewSetupDetector

func NewSetupDetector(fn func() (int64, error)) *SetupDetector

NewSetupDetector returns a detector that counts local users with fn. A nil fn yields a detector that judges by rootUserId alone.

func (*SetupDetector) RequireSetup

func (d *SetupDetector) RequireSetup(m *model.Meta) bool

RequireSetup reports whether the client should show the initial setup screen.

**サーバー側の受け入れ条件と揃える (#3037)。** `admin/accounts/create` の 初回セットアップ窓は `rootUserId` が未設定 **かつ**ローカル利用者が 0 のとき だけ開く。フロントの判定を `rootUserId` だけにしておくと、TS から引き継いだ DB などで `rootUserId` が NULL・利用者ありの状態になったとき、**セットアップ 画面が出続けて作成ボタンが必ず `ACCESS_DENIED` を返す**。フロントの catch は 「権限がありません」しか出さないので、運営者には原因も対処も分からない。

**upstream は `rootUserId` だけを見る。** そちらはサーバー側の窓も同じ条件 なので整合している。mk-go は窓を狭めた側なので、表示条件も合わせる。

数え方が無ければ従来どおり `rootUserId` だけで判定する (テストや、 数える手段が無い経路)。

Jump to

Keyboard shortcuts

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