PublishDiffStatusChange broadcasts a diff_status_change event for the given chat so that watching clients know to re-fetch the diff status. This is called from the HTTP layer after the diff status is updated in the database.
(ctx context.Context, chatID uuid.UUID)
| 5598 | // status. This is called from the HTTP layer after the diff status |
| 5599 | // is updated in the database. |
| 5600 | func (p *Server) PublishDiffStatusChange(ctx context.Context, chatID uuid.UUID) error { |
| 5601 | if p.pubsub == nil { |
| 5602 | return nil |
| 5603 | } |
| 5604 | |
| 5605 | chat, err := p.db.GetChatByID(ctx, chatID) |
| 5606 | if err != nil { |
| 5607 | return xerrors.Errorf("get chat: %w", err) |
| 5608 | } |
| 5609 | |
| 5610 | dbStatus, err := p.db.GetChatDiffStatusByChatID(ctx, chatID) |
| 5611 | if err != nil { |
| 5612 | return xerrors.Errorf("get chat diff status: %w", err) |
| 5613 | } |
| 5614 | |
| 5615 | sdkStatus := db2sdk.ChatDiffStatus(chatID, &dbStatus) |
| 5616 | p.publishChatPubsubEvent(chat, codersdk.ChatWatchEventKindDiffStatusChange, &sdkStatus) |
| 5617 | return nil |
| 5618 | } |
| 5619 | |
| 5620 | func (p *Server) publishRetry(chatID uuid.UUID, payload *codersdk.ChatStreamRetry) { |
| 5621 | if payload == nil { |
nothing calls this directly
no test coverage detected