MCPcopy Index your code
hub / github.com/coder/coder / Subscribe

Method Subscribe

coderd/x/chatd/chatd.go:4926–4953  ·  view source on GitHub ↗
(
	ctx context.Context,
	chatID uuid.UUID,
	requestHeader http.Header,
	afterMessageID int64,
)

Source from the content-addressed store, hash-verified

4924}
4925
4926func (p *Server) Subscribe(
4927 ctx context.Context,
4928 chatID uuid.UUID,
4929 requestHeader http.Header,
4930 afterMessageID int64,
4931) (
4932 []codersdk.ChatStreamEvent,
4933 <-chan codersdk.ChatStreamEvent,
4934 func(),
4935 bool,
4936) {
4937 if p == nil {
4938 return nil, nil, nil, false
4939 }
4940
4941 chat, err := p.db.GetChatByID(ctx, chatID)
4942 if err != nil {
4943 if dbauthz.IsNotAuthorizedError(err) {
4944 return nil, nil, nil, false
4945 }
4946 p.logger.Warn(ctx, "failed to load chat for stream subscription",
4947 slog.F("chat_id", chatID),
4948 slog.Error(err),
4949 )
4950 return subscribeWithInitialError(chatID, "failed to load initial snapshot")
4951 }
4952 return p.SubscribeAuthorized(ctx, chat, requestHeader, afterMessageID)
4953}
4954
4955// SubscribeAuthorized subscribes an already-authorized chat to merged stream
4956// updates. The passed chat row proves authorization, but SubscribeAuthorized

Callers

nothing calls this directly

Calls 5

SubscribeAuthorizedMethod · 0.95
IsNotAuthorizedErrorFunction · 0.92
GetChatByIDMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected