chat

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatInvitationNotifier

type ChatInvitationNotifier interface {
	OnChatRoomInvitationReceived(inviteeID, inviterID, invitationID string)
}

ChatInvitationNotifier records a 'chatRoomInvitationReceived' notification on the invitee's stream (#1559)。循環依存を避けるため interface で受け取る (実装は core/notification.Hook)。

type Handler

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

Handler handles chat/* endpoints.

func NewHandler

func NewHandler(repo repository.ChatRepository, idGen id.Generator, entityPacker *entity.Packer, fileRepo repository.DriveFileRepository, lites userpack.LiteFiller) *Handler

NewHandler creates a new chat handler.

entityPacker is the Packer this Handler packs entities with (#3794). fileRepo is the drive file repository for attached-chat-messages and the owner check of the attached file (#1218, #2708). lites is the batch resolver of instance / emojis for the UserLite values embedded in chat responses (#3438).

どれも無いと黙って劣化する (メディアの URL が生のまま / 他人の drive ファイルを 添付できる / リモートの利用者に instance と絵文字が載らない) ので、構築子の必須の 引数で受ける (#3823)。

func (*Handler) AttachedChatMessages

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

AttachedChatMessages handles POST /api/drive/files/attached-chat-messages. 指定 drive file を添付した chat message を id cursor で返す。並び順は repository の paginationOrder に従うので、sinceId 単独指定のページだけは 古い順になる (#2713)。 upstream (read:drive) と同じく file は owner-scope で引く (moderator は任意 file 可)。 連合互換: res は ChatMessage の配列 (packMessageDetailed)。

func (*Handler) History

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

History handles POST /api/chat/history.

upstream `chat/history` は `room: bool` parameter を取り、true の時は chat ルーム内の最新メッセージ、false (デフォルト) の時は 1-on-1 DM の 最新メッセージを返す。FE の MkChatHistories.vue は両方を並行に呼んで マージするため、room パラメータを正しくハンドリングしないと chat home で何も描画されない (#692)。

func (*Handler) InvitationsAccept

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

InvitationsAccept handles POST /api/chat/rooms/invitations/accept.

func (*Handler) InvitationsCreate

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

InvitationsCreate handles POST /api/chat/rooms/invitations/create.

func (*Handler) InvitationsDelete

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

InvitationsDelete handles POST /api/chat/rooms/invitations/delete. ルームオーナーが自分の送った招待を取り消す。

招待された側は reject / ignore を使う。こちらは連合の Reject を送らないので、 被招待者に開放すると remote room の招待を黙って消せてしまう。

func (*Handler) InvitationsIgnore

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

InvitationsIgnore handles POST /api/chat/rooms/invitations/ignore.

func (*Handler) InvitationsInbox

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

InvitationsInbox handles POST /api/chat/rooms/invitations/inbox.

func (*Handler) InvitationsOutbox

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

InvitationsOutbox handles POST /api/chat/rooms/invitations/outbox.

func (*Handler) InvitationsReject

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

InvitationsReject handles POST /api/chat/rooms/invitations/reject.

func (*Handler) MembersBan

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

MembersBan handles POST /api/chat/rooms/members/ban. ルームオーナーのみが他メンバーを退出させられる。

func (*Handler) MembersUpdateMembership

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

MembersUpdateMembership handles POST /api/chat/rooms/members/update-membership. ルームオーナーのみが他メンバーの設定を変更できる。

func (*Handler) Messages

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

Messages handles POST /api/chat/messages (list).

func (*Handler) MessagesCreate

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

MessagesCreate handles POST /api/chat/messages/create. service が wire されていれば streaming 配信も同時に行う。

func (*Handler) MessagesCreateToRoom

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

MessagesCreateToRoom handles POST /api/chat/messages/create-to-room.

func (*Handler) MessagesCreateToUser

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

MessagesCreateToUser handles POST /api/chat/messages/create-to-user.

func (*Handler) MessagesDelete

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

MessagesDelete handles POST /api/chat/messages/delete.

func (*Handler) MessagesRead

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

MessagesRead handles POST /api/chat/messages/read.

func (*Handler) MessagesSearch

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

MessagesSearch handles POST /api/chat/messages/search.

func (*Handler) MessagesShow

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

MessagesShow handles POST /api/chat/messages/show.

func (*Handler) MessagesUpdate

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

MessagesUpdate handles POST /api/chat/messages/update.

func (*Handler) PackInvitationByID

func (h *Handler) PackInvitationByID(invitationID, viewerID string) (map[string]any, bool)

PackInvitationByID loads an invitation by ID (with room + invitee user) and packs it for the given viewer, returning false when it no longer exists. Used as the read-time lookup for chatRoomInvitationReceived notifications (#1559)。

func (*Handler) ReactionsCreate

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

ReactionsCreate handles POST /api/chat/messages/reactions/create and POST /api/chat/messages/react. Reaction format: "userId/emoji".

func (*Handler) ReactionsDelete

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

ReactionsDelete handles POST /api/chat/messages/reactions/delete and POST /api/chat/messages/unreact.

func (*Handler) ReadAll

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

ReadAll handles POST /api/chat/read-all.

func (*Handler) RoomTimeline

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

RoomTimeline handles POST /api/chat/messages/room-timeline.

upstream の readRoomChatMessage 相当 (#692)。

func (*Handler) RoomsCreate

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

RoomsCreate handles POST /api/chat/rooms/create.

func (*Handler) RoomsDelete

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

RoomsDelete handles POST /api/chat/rooms/delete.

func (*Handler) RoomsJoin

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

RoomsJoin handles POST /api/chat/rooms/join.

func (*Handler) RoomsJoined

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

RoomsJoined handles POST /api/chat/rooms/joined.

func (*Handler) RoomsJoining

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

RoomsJoining handles POST /api/chat/rooms/joining.

upstream joining.ts は ChatRoomMembership[] (populateRoom:true, populateUser:false) を返す。旧 mk-go は RoomsJoined (= ChatRoom[]) の alias だったが、shape が異なるため membership を返すよう独立実装する。

func (*Handler) RoomsLeave

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

RoomsLeave handles POST /api/chat/rooms/leave.

func (*Handler) RoomsMembers

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

RoomsMembers handles POST /api/chat/rooms/members.

func (*Handler) RoomsMute

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

RoomsMute handles POST /api/chat/rooms/mute.

func (*Handler) RoomsOwned

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

RoomsOwned handles POST /api/chat/rooms/owned.

func (*Handler) RoomsShow

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

RoomsShow handles POST /api/chat/rooms/show.

upstream Misskey TS 2026.5.4 (`hasPermissionToViewRoomInfo`) と互換するため、 owner / member / 招待受信者 / moderator 以外は noSuchRoom (404) を返す (#1164 Phase C)。旧 mk-go は room id を知っていれば誰でも room メタ情報を 取得できる drop-in regression 状態だったため本 gate で塞ぐ。

func (*Handler) RoomsTransferOwnership

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

RoomsTransferOwnership handles POST /api/chat/rooms/transfer-ownership.

func (*Handler) RoomsUnmute

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

RoomsUnmute handles POST /api/chat/rooms/unmute.

func (*Handler) RoomsUpdate

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

RoomsUpdate handles POST /api/chat/rooms/update.

func (*Handler) SetChatAvailabilityChecker

func (h *Handler) SetChatAvailabilityChecker(c middleware.ChatAvailabilityChecker)

SetChatAvailabilityChecker wires the role-policy provider used to verify a recipient's chatAvailability(write) in create-to-user (#1796). nil skips it.

func (*Handler) SetInvitationNotifier

func (h *Handler) SetInvitationNotifier(n ChatInvitationNotifier)

SetInvitationNotifier wires the notifier used by invitations/create to send a 'chatRoomInvitationReceived' notification (upstream ChatService の招待作成)。

func (*Handler) SetModLog

func (h *Handler) SetModLog(m ModLogger)

SetModLog wires the moderation-log writer used when a moderator deletes another user's chat room (#1541)。

func (*Handler) SetModeratorChecker

func (h *Handler) SetModeratorChecker(m ModeratorChecker)

SetModeratorChecker wires a moderator checker for attached-chat-messages.

func (*Handler) SetService

func (h *Handler) SetService(svc *corechat.Service)

SetService wires a chat Service so that state-changing message endpoints (create/update/delete/read) route through it and publish streaming events. 未設定の場合は従来どおり repo 直操作にフォールバックする (既存テスト互換)。

func (*Handler) SetUserRepo

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

SetUserRepo wires the user repository for resolving invitee UserLite in the invitations/create response.

func (*Handler) UnreadCount

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

UnreadCount handles POST /api/chat/unread-count.

func (*Handler) UserTimeline

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

UserTimeline handles POST /api/chat/messages/user-timeline.

upstream の readUserChatMessage 相当: チャット画面を開いた瞬間に「相手 → 自分」の DM をすべて既読としてマークする。FE は新着メッセージにしか 'read' イベントを送らないので、initial load 時点の既読化はサーバ側で やらないと unread badge がリロードのたびに復活する (#692)。

type ModLogger

type ModLogger interface {
	Log(ctx context.Context, moderatorID string, t moderationlog.LogType, info map[string]any)
}

ModLogger records a moderation action. Satisfied by *core/moderationlog.Service. nil 配線時は記録を skip する (#1541)。

type ModeratorChecker

type ModeratorChecker interface {
	IsModerator(userID string) bool
}

ModeratorChecker reports whether a user has moderator privileges. Implemented by core/role.Service. Used to widen attached-chat-messages from owner-only to any file for moderators (upstream `userId: isModerator ? undefined : me.id`).

Jump to

Keyboard shortcuts

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