fix: chat accepts quotes now
This commit is contained in:
@@ -36,6 +36,8 @@ func writeChatError(w http.ResponseWriter, err error) {
|
||||
response.Error(w, http.StatusNotFound, "conversation not found")
|
||||
case errors.Is(err, service.ErrAvatarUnset):
|
||||
response.Error(w, http.StatusNotFound, err.Error())
|
||||
case errors.Is(err, service.ErrChatBadQuote):
|
||||
response.Error(w, http.StatusBadRequest, err.Error())
|
||||
case errors.Is(err, service.ErrChatBadAvatarKey):
|
||||
response.Error(w, http.StatusBadRequest, err.Error())
|
||||
case errors.Is(err, repository.ErrMessageNotHere):
|
||||
@@ -186,7 +188,10 @@ type sendReq struct {
|
||||
// when they dismissed it. Only the URL — never the card's contents.
|
||||
PreviewURL *string `json:"preview_url"`
|
||||
Attachments []mediaReq `json:"attachments"`
|
||||
ReplyToID *string `json:"reply_to_id"`
|
||||
// quote is a passage shared from the library. `path` must be app-relative;
|
||||
// the service refuses anything that could navigate off-site.
|
||||
Quote *quoteReq `json:"quote"`
|
||||
ReplyToID *string `json:"reply_to_id"`
|
||||
// forward_from_id is deliberately NOT accepted yet: forwarding lands with
|
||||
// its own "can the caller see the source?" check in a later phase, and
|
||||
// accepting an unvalidated message reference in the meantime would let a
|
||||
@@ -210,11 +215,18 @@ func (h *ChatHandler) Send(w http.ResponseWriter, r *http.Request) {
|
||||
FileName: a.FileName,
|
||||
})
|
||||
}
|
||||
var quote *service.QuoteAttachment
|
||||
if req.Quote != nil {
|
||||
quote = &service.QuoteAttachment{
|
||||
Path: req.Quote.Path, Title: req.Quote.Title, Text: req.Quote.Text,
|
||||
}
|
||||
}
|
||||
msg, err := h.svc.Send(r.Context(), userID, convID, service.SendRequest{
|
||||
Body: req.Body,
|
||||
ClientMsgID: req.ClientMsgID,
|
||||
ReplyToID: req.ReplyToID,
|
||||
PreviewURL: req.PreviewURL,
|
||||
Quote: quote,
|
||||
Attachments: media,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -554,6 +566,12 @@ func (h *ChatHandler) UpdateGroup(w http.ResponseWriter, r *http.Request) {
|
||||
response.NoContent(w)
|
||||
}
|
||||
|
||||
type quoteReq struct {
|
||||
Path string `json:"path"`
|
||||
Title string `json:"title"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type receiptReq struct {
|
||||
Seq int64 `json:"seq"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user