( ctx context.Context, chatID uuid.UUID, requestHeader http.Header, afterMessageID int64, )
| 4924 | } |
| 4925 | |
| 4926 | func (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 |
nothing calls this directly
no test coverage detected