Add default conversation title
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"code.chimeric.al/chimerical/odidere/internal/conversation"
|
||||
"code.chimeric.al/chimerical/odidere/internal/db"
|
||||
)
|
||||
|
||||
@@ -129,17 +130,12 @@ func (svc *Service) getConversationHandler(
|
||||
}
|
||||
}
|
||||
|
||||
// maxTitleLength is the most characters, counted as Unicode code
|
||||
// points, that a conversation title may hold. It keeps a title
|
||||
// short enough for the picker and small in storage.
|
||||
const maxTitleLength = 256
|
||||
|
||||
// updateConversation renames one conversation. The handler trims
|
||||
// the title, then rejects an empty title or a title longer than
|
||||
// maxTitleLength with 400. A conversation that does not exist, or
|
||||
// belongs to another user, returns 404. The rename is allowed while
|
||||
// inference runs: a title is not a message, and a concurrent
|
||||
// inference does not read or write it.
|
||||
// conversation.MaxTitleLength with 400. A conversation that does
|
||||
// not exist, or belongs to another user, returns 404. The rename
|
||||
// is allowed while inference runs: a title is not a message, and a
|
||||
// concurrent inference does not read or write it.
|
||||
func (svc *Service) updateConversation(w http.ResponseWriter, r *http.Request) {
|
||||
var (
|
||||
ctx = r.Context()
|
||||
@@ -165,7 +161,7 @@ func (svc *Service) updateConversation(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if utf8.RuneCountInString(req.Title) > maxTitleLength {
|
||||
if utf8.RuneCountInString(req.Title) > conversation.MaxTitleLength {
|
||||
http.Error(w, "invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user