(logger slog.Logger, ps dbpubsub.Pubsub, chat database.Chat)
| 115 | } |
| 116 | |
| 117 | func publishChatTitleChange(logger slog.Logger, ps dbpubsub.Pubsub, chat database.Chat) { |
| 118 | if ps == nil { |
| 119 | return |
| 120 | } |
| 121 | event := codersdk.ChatWatchEvent{ |
| 122 | Kind: codersdk.ChatWatchEventKindTitleChange, |
| 123 | Chat: db2sdk.Chat(chat, nil, nil), |
| 124 | } |
| 125 | payload, err := json.Marshal(event) |
| 126 | if err != nil { |
| 127 | logger.Error(context.Background(), "failed to marshal chat title change event", |
| 128 | slog.F("chat_id", chat.ID), |
| 129 | slog.Error(err), |
| 130 | ) |
| 131 | return |
| 132 | } |
| 133 | if err := ps.Publish(pubsub.ChatWatchEventChannel(chat.OwnerID), payload); err != nil { |
| 134 | logger.Error(context.Background(), "failed to publish chat title change event", |
| 135 | slog.F("chat_id", chat.ID), |
| 136 | slog.Error(err), |
| 137 | ) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | func publishChatConfigEvent(logger slog.Logger, ps dbpubsub.Pubsub, kind pubsub.ChatConfigEventKind, entityID uuid.UUID) { |
| 142 | payload, err := json.Marshal(pubsub.ChatConfigEvent{ |
no test coverage detected