feat(phase3): forum channels + tags + card UI
This commit is contained in:
@@ -11,8 +11,9 @@ import (
|
||||
)
|
||||
|
||||
type createThreadRequest struct {
|
||||
Name string `json:"name"`
|
||||
MessageID *string `json:"message_id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
MessageID *string `json:"message_id,omitempty"`
|
||||
TagIDs []string `json:"tag_ids,omitempty"`
|
||||
}
|
||||
|
||||
type threadResponse struct {
|
||||
@@ -95,6 +96,16 @@ func (h *Handler) CreateThread(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Attach optional tags for forum posts.
|
||||
if len(req.TagIDs) > 0 {
|
||||
// ponytail: ignore tag errors; best-effort assignment
|
||||
for _, tagID := range req.TagIDs {
|
||||
_, _ = h.db.ExecContext(r.Context(), `
|
||||
INSERT INTO channel_tags (channel_id, tag_id) VALUES ($1, $2) ON CONFLICT DO NOTHING
|
||||
`, thread.ID, tagID)
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
json.NewEncoder(w).Encode(thread)
|
||||
|
||||
Reference in New Issue
Block a user