fix(media): failed to store the media to /data/media and add image part

This commit is contained in:
Acbox
2026-04-13 12:58:08 +08:00
parent d46269de89
commit 26b01cc463
10 changed files with 507 additions and 7 deletions
+19
View File
@@ -14,6 +14,13 @@ type RenderedContentPiece struct {
URL string `json:"url,omitempty"`
}
// ImageAttachmentRef holds the content hash and MIME type of an image
// attachment that can be inlined as a vision input via the media store.
type ImageAttachmentRef struct {
ContentHash string `json:"content_hash"`
Mime string `json:"mime,omitempty"`
}
// RenderedSegment is a single segment of rendered context, one per IC node.
type RenderedSegment struct {
ReceivedAtMs int64 `json:"received_at_ms"`
@@ -22,6 +29,7 @@ type RenderedSegment struct {
IsSelfSent bool `json:"is_self_sent,omitempty"`
MentionsMe bool `json:"mentions_me,omitempty"`
RepliesToMe bool `json:"replies_to_me,omitempty"`
ImageRefs []ImageAttachmentRef `json:"image_refs,omitempty"`
}
// RenderedContext is the output of the Rendering layer — a slice of segments.
@@ -140,6 +148,16 @@ func renderMessage(msg *ICMessage, params RenderParams) RenderedSegment {
pieces := []RenderedContentPiece{{Type: "text", Text: text}}
var imageRefs []ImageAttachmentRef
for _, att := range msg.Attachments {
if strings.EqualFold(att.Type, "image") && att.ContentHash != "" {
imageRefs = append(imageRefs, ImageAttachmentRef{
ContentHash: att.ContentHash,
Mime: att.MimeType,
})
}
}
return RenderedSegment{
ReceivedAtMs: msg.ReceivedAtMs,
Content: pieces,
@@ -147,6 +165,7 @@ func renderMessage(msg *ICMessage, params RenderParams) RenderedSegment {
IsSelfSent: msg.IsSelfSent,
MentionsMe: mentionsMe,
RepliesToMe: repliesToMe,
ImageRefs: imageRefs,
}
}