federation

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: 17 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 federation provides /api/federation/* endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorResolver

type ActorResolver interface {
	ForceResolveActor(uri string) (*model.User, error)
}

ActorResolver is the narrow subset of core/federation.Resolver that federation/update-remote-user needs. Kept as an interface so unit tests can swap in a fake without pulling in HTTP transports.

type Handler

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

Handler handles federation-related API endpoints.

func NewHandler

func NewHandler(svc *coreinstance.Service, entityPacker *entity.Packer, packer userpack.ListPacker) *Handler

NewHandler creates a new federation Handler. entityPacker is the Packer this handler packs entities with (#3792); packer packs the users embedded in federation/users, federation/followers and federation/following (#1957-a, #3330).

func (*Handler) Followers

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

Followers handles POST /api/federation/followers.

指定リモートホストに属するユーザーが、このインスタンスのローカルユーザーを フォローしている関係の一覧を返す。Misskey 本家互換。

func (*Handler) Following

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

Following handles POST /api/federation/following.

このインスタンスのローカルユーザーが、指定リモートホストに属するユーザーを フォローしている関係の一覧を返す。

func (*Handler) Instances

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

Instances handles POST /api/federation/instances.

frontend Paginator (cursor mode) は untilId / sinceId を forward する (#493)。

func (*Handler) Peers

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

Peers handles GET /api/v1/instance/peers.

Mastodon-compatible peer listing: a flat JSON array of the hosts this instance knows about, excluding suspended ones. Used by fediverse crawlers and statistics sites (fediverse.observer など) to map federation topology.

upstream Misskey は endpoints/ 配下ではなく ApiServerService.ts で fastify に 直接登録している (#2245)。実装も `select: {host: true}` / `where: {suspensionState: 'none'}` の全件走査のみで、blocked / silenced や isNotResponding では絞らず limit も持たない。ここで独自のフィルタを足すと 統計サイトから見たピア一覧が TS 実装と食い違うので、同じ条件のままにする。

federation/instances (Misskey 独自 API) とは別物で、あちらは instance オブジェクトの詳細を返す。こちらは host 文字列のみ。

func (*Handler) SetFollowingRepo

func (h *Handler) SetFollowingRepo(r repository.FollowingRepository)

SetFollowingRepo attaches a FollowingRepository for followers/following lookup.

func (*Handler) SetIDGen

func (h *Handler) SetIDGen(g id.Generator)

SetIDGen wires an id.Generator so federation/followers / federation/following can derive Following.createdAt from aidx-encoded row IDs.

func (*Handler) SetModeratorChecker

func (h *Handler) SetModeratorChecker(m ModeratorChecker)

SetModeratorChecker attaches a ModeratorChecker so moderationNote is only surfaced to moderators on the public instance-listing endpoints.

func (*Handler) SetResolver

func (h *Handler) SetResolver(r ActorResolver)

SetResolver attaches an ActorResolver for update-remote-user.

func (*Handler) SetSelfPacker

func (h *Handler) SetSelfPacker(p *meself.Packer)

SetSelfPacker wires the Packer that promotes the viewer's own entry into MeDetailed. Unset promotes without the handler-only fields.

func (*Handler) SetSignatureCapabilityLookup

func (h *Handler) SetSignatureCapabilityLookup(l SignatureCapabilityLookup)

SetSignatureCapabilityLookup wires the store that reports which signature scheme each remote host uses (#2393).

func (*Handler) SetUserRepo

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

SetUserRepo attaches a UserRepository for the users-per-host listing.

func (*Handler) ShowInstance

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

ShowInstance handles POST /api/federation/show-instance.

func (*Handler) Stats

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

Stats handles POST /api/federation/stats.

連合統計: followers / following がもっとも多いリモートインスタンス上位 N 件と、そのほかのインスタンスをまとめた残り総計を返す。

func (*Handler) UpdateRemoteUser

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

UpdateRemoteUser handles POST /api/federation/update-remote-user.

対象のリモートユーザーを ActivityPub actor fetch で強制更新する。管理者用。

func (*Handler) Users

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

Users handles POST /api/federation/users.

指定リモートホストに属するユーザーの一覧を返す。

type InstancesRequest

type InstancesRequest struct {
	Host          string     `json:"host" query:"host"`
	Suspended     *bool      `json:"suspended" query:"suspended"`
	NotResponding *bool      `json:"notResponding" query:"notResponding"`
	Blocked       *bool      `json:"blocked" query:"blocked"`
	Silenced      *bool      `json:"silenced" query:"silenced"`
	Federating    *bool      `json:"federating" query:"federating"`
	Subscribing   *bool      `json:"subscribing" query:"subscribing"`
	Publishing    *bool      `json:"publishing" query:"publishing"`
	Sort          string     `json:"sort" query:"sort"`
	Limit         *jsnum.Int `json:"limit" query:"limit"`
	Offset        *jsnum.Int `json:"offset" query:"offset"`
	SinceID       string     `json:"sinceId" query:"sinceId"`
	UntilID       string     `json:"untilId" query:"untilId"`
	SinceDate     *jsnum.Int `json:"sinceDate" query:"sinceDate"`
	UntilDate     *jsnum.Int `json:"untilDate" query:"untilDate"`
}

InstancesRequest is the request body for federation/instances.

query タグは upstream instances.ts の allowGet:true 経路用 (#2106 N9)。echo の DefaultBinder は GET で BindQueryParams を呼ぶが、explicit query タグの無い field は 束縛しない。frontend welcome.entrance.classic.vue は misskeyApiGet で sort/limit/blocked 等を渡すため、これらが無いと表示順・件数・block 除外が全て効かなくなる。

type ModeratorChecker

type ModeratorChecker interface {
	IsModerator(userID string) bool
}

ModeratorChecker reports whether a user has moderator privileges. Used to gate moderator-only fields (moderationNote) on the otherwise-public federation/instances and federation/show-instance responses. nil disables the gate (moderationNote is never exposed).

type ShowInstanceRequest

type ShowInstanceRequest struct {
	Host *string `json:"host"`
}

ShowInstanceRequest is the request body for federation/show-instance.

type SignatureCapabilityLookup

type SignatureCapabilityLookup interface {
	FindByHost(host string) (*model.InstanceSignatureCapability, error)
	FindManyByHosts(hosts []string) ([]*model.InstanceSignatureCapability, error)
}

SignatureCapabilityLookup is the read-only subset of repository.InstanceSignatureCapabilityRepository needed to decorate instance responses with the observed signature scheme (#2393). 未配線なら signatureCapability は常に null になる。

Jump to

Keyboard shortcuts

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