Accept pasted images in inbox Other and Reply answers

This commit is contained in:
Ian Gulliver
2026-10-16 22:49:06 -07:00
parent a9bec7a7ea
commit ea90178fce
19 changed files with 579 additions and 469 deletions
+15 -5
View File
@@ -133,6 +133,11 @@ func (s *Store) Respond(ctx context.Context, actor string, resolutions []Resolut
return err
}
images, err := json.Marshal(resp.Images)
if err != nil {
return err
}
var options *string
if resp.Options != nil {
b, err := json.Marshal(*resp.Options)
@@ -144,9 +149,9 @@ func (s *Store) Respond(ctx context.Context, actor string, resolutions []Resolut
}
_, err = tx.ExecContext(ctx, `
INSERT INTO inbox_responses (id, item_id, user_login, type, options, text, attachments, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`, resp.Id, resp.ItemId, resp.User, string(resp.Type), options, resp.Text, string(attachments), formatTime(resp.CreatedAt))
INSERT INTO inbox_responses (id, item_id, user_login, type, options, text, images, attachments, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
`, resp.Id, resp.ItemId, resp.User, string(resp.Type), options, resp.Text, string(images), string(attachments), formatTime(resp.CreatedAt))
if err != nil {
return err
}
@@ -342,7 +347,7 @@ func getItem(ctx context.Context, q querier, id string) (api.InboxItem, error) {
func getResponses(ctx context.Context, q querier, itemID string) ([]api.InboxResponse, error) {
rows, err := q.QueryContext(ctx, `
SELECT id, item_id, user_login, type, options, text, attachments, created_at, delivered_at
SELECT id, item_id, user_login, type, options, text, images, attachments, created_at, delivered_at
FROM inbox_responses WHERE item_id = ? ORDER BY created_at
`, itemID)
if err != nil {
@@ -356,11 +361,12 @@ func getResponses(ctx context.Context, q querier, itemID string) ([]api.InboxRes
typ := ""
options := sql.NullString{}
text := sql.NullString{}
images := ""
attachments := ""
createdAt := ""
delivered := sql.NullString{}
err = rows.Scan(&r.Id, &r.ItemId, &r.User, &typ, &options, &text, &attachments, &createdAt, &delivered)
err = rows.Scan(&r.Id, &r.ItemId, &r.User, &typ, &options, &text, &images, &attachments, &createdAt, &delivered)
if err != nil {
return nil, err
}
@@ -377,6 +383,10 @@ func getResponses(ctx context.Context, q querier, itemID string) ([]api.InboxRes
if text.Valid {
r.Text = &text.String
}
err = json.Unmarshal([]byte(images), &r.Images)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(attachments), &r.Attachments)
if err != nil {
return nil, err
+2
View File
@@ -460,6 +460,8 @@ ALTER TABLE tasks ADD COLUMN finalizing_unchanged INTEGER NOT NULL DEFAULT 0;
ALTER TABLE tasks ADD COLUMN merge_after_review_by TEXT NOT NULL DEFAULT '';
ALTER TABLE tasks ADD COLUMN merge_after_review_id TEXT NOT NULL DEFAULT '';
ALTER TABLE tasks ADD COLUMN merge_after_review_target TEXT NOT NULL DEFAULT '';
`}, {"add-inbox-response-images", `
ALTER TABLE inbox_responses ADD COLUMN images TEXT NOT NULL DEFAULT '[]';
`}}
const (