Answer a question again by forking at its answer's snapshot
This commit is contained in:
+24
-21
@@ -38,28 +38,9 @@ func (m *Manager) Respond(ctx context.Context, user string, creates []api.InboxR
|
||||
return nil, err
|
||||
}
|
||||
|
||||
attachments := []api.Attachment{}
|
||||
if create.Attachments != nil {
|
||||
attachments = *create.Attachments
|
||||
}
|
||||
images := []string{}
|
||||
if create.Images != nil {
|
||||
images = *create.Images
|
||||
}
|
||||
|
||||
resolutions = append(resolutions, store.Resolution{
|
||||
State: state,
|
||||
Response: api.InboxResponse{
|
||||
Id: store.NewID(),
|
||||
ItemId: item.Id,
|
||||
User: user,
|
||||
Type: create.Type,
|
||||
Options: create.Options,
|
||||
Text: create.Text,
|
||||
Images: images,
|
||||
Attachments: attachments,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
},
|
||||
State: state,
|
||||
Response: newResponse(item.Id, user, create),
|
||||
})
|
||||
if !slices.Contains(sessions, item.AgentSessionId) {
|
||||
sessions = append(sessions, item.AgentSessionId)
|
||||
@@ -98,6 +79,28 @@ func (m *Manager) Respond(ctx context.Context, user string, creates []api.InboxR
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func newResponse(itemID, user string, create api.InboxResponseCreate) api.InboxResponse {
|
||||
attachments := []api.Attachment{}
|
||||
if create.Attachments != nil {
|
||||
attachments = *create.Attachments
|
||||
}
|
||||
images := []string{}
|
||||
if create.Images != nil {
|
||||
images = *create.Images
|
||||
}
|
||||
return api.InboxResponse{
|
||||
Id: store.NewID(),
|
||||
ItemId: itemID,
|
||||
User: user,
|
||||
Type: create.Type,
|
||||
Options: create.Options,
|
||||
Text: create.Text,
|
||||
Images: images,
|
||||
Attachments: attachments,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) Dismiss(ctx context.Context, user, itemID string) (api.InboxItem, error) {
|
||||
item, err := m.store.GetInboxItem(ctx, itemID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user