Accept pasted images in inbox Other and Reply answers
This commit is contained in:
@@ -326,7 +326,11 @@ func (m *Manager) Deliver(ctx context.Context, sessionID string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
after, err := m.turn(ctx, sess, task, pending[0].Response.User, deliveryMessage(pending), nil)
|
||||
images := []string{}
|
||||
for _, p := range pending {
|
||||
images = append(images, p.Response.Images...)
|
||||
}
|
||||
after, err := m.turn(ctx, sess, task, pending[0].Response.User, deliveryMessage(pending), images)
|
||||
if errors.Is(err, ErrConflict) {
|
||||
slog.Info("deliver held: session changed state", "session", sessionID, "err", err, "responses", ids)
|
||||
return nil
|
||||
@@ -433,6 +437,12 @@ func (m *Manager) responsesMidTurn(ctx context.Context, l *live) (string, []stri
|
||||
return "", nil
|
||||
}
|
||||
ids := responseIDs(pending)
|
||||
for _, p := range pending {
|
||||
if len(p.Response.Images) > 0 {
|
||||
slog.Info("deliver held mid-turn: response has images", "session", l.id, "responses", ids)
|
||||
return "", nil
|
||||
}
|
||||
}
|
||||
|
||||
waiting, err := m.store.AwaitingHuman(ctx, l.id)
|
||||
if err != nil {
|
||||
@@ -498,14 +508,22 @@ func deliveryMessage(pending []store.Pending) string {
|
||||
fmt.Fprintf(b, "%s chose: %s\n", r.User, (*r.Options)[0])
|
||||
}
|
||||
case api.Other:
|
||||
text := ""
|
||||
if r.Text != nil {
|
||||
text = *r.Text
|
||||
}
|
||||
if p.Item.Kind == api.Question {
|
||||
fmt.Fprintf(b, "%s answered (none of your options): %s\n", r.User, *r.Text)
|
||||
fmt.Fprintf(b, "%s answered (none of your options): %s\n", r.User, text)
|
||||
fmt.Fprintf(b, "If this asks you something back, answer by calling ask_human with thread_id %q.\n", p.Item.ThreadId)
|
||||
} else {
|
||||
fmt.Fprintf(b, "%s replied: %s\n", r.User, *r.Text)
|
||||
fmt.Fprintf(b, "%s replied: %s\n", r.User, text)
|
||||
}
|
||||
}
|
||||
|
||||
if len(r.Images) > 0 {
|
||||
fmt.Fprintf(b, "%s attached %d image(s) to this response; they come with this message.\n", r.User, len(r.Images))
|
||||
}
|
||||
|
||||
for _, a := range r.Attachments {
|
||||
j, err := json.Marshal(a)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user