Questions tab, question bubbles, answer snapshots; errors to transcript
This commit is contained in:
@@ -108,16 +108,12 @@ func CheckResponse(item api.InboxItem, c api.InboxResponseCreate) (api.InboxStat
|
||||
text = strings.TrimSpace(*c.Text)
|
||||
}
|
||||
images := c.Images != nil && len(*c.Images) > 0
|
||||
question := item.Kind == api.Question
|
||||
bad := func(format string, args ...any) (api.InboxState, error) {
|
||||
return "", fmt.Errorf("%w: item %s: "+format, append([]any{ErrInvalid, item.Id}, args...)...)
|
||||
}
|
||||
|
||||
switch c.Type {
|
||||
case api.Option:
|
||||
if !question {
|
||||
return bad("only questions have options")
|
||||
}
|
||||
if c.Options == nil || len(*c.Options) == 0 {
|
||||
return bad("option needs the chosen options")
|
||||
}
|
||||
@@ -144,15 +140,6 @@ func CheckResponse(item api.InboxItem, c api.InboxResponseCreate) (api.InboxStat
|
||||
return bad("other needs text or images")
|
||||
}
|
||||
return api.Answered, nil
|
||||
|
||||
case api.Dismiss:
|
||||
if question {
|
||||
return bad("questions need an option or other, not a dismissal")
|
||||
}
|
||||
if images {
|
||||
return bad("a dismissal takes no images")
|
||||
}
|
||||
return api.Dismissed, nil
|
||||
}
|
||||
|
||||
return bad("unknown response type %q", c.Type)
|
||||
|
||||
Reference in New Issue
Block a user