feat: support image search identity handoff and safe payload (#278)

This commit is contained in:
QiuSW
2026-09-15 08:42:11 +08:00
parent 7b540f3163
commit 42b5312198
2 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -211,7 +211,7 @@ func (service *Service) IdentifyCurrentPage(ctx context.Context, taskID uint64,
}
return CurrentPageIdentifyResponse{}, internalError(err)
}
if existing.Source != models.CollectionTaskSourceAgentCurrentPage || existing.DeviceID == nil || *existing.DeviceID != deviceRecord.ID {
if (existing.Source != models.CollectionTaskSourceAgentCurrentPage && existing.Source != models.CollectionTaskSourceImageSearch) || existing.DeviceID == nil || *existing.DeviceID != deviceRecord.ID {
return CurrentPageIdentifyResponse{}, serviceError(CodeTaskNotFound, "任务不存在")
}
if existing.IdentifyRequestID != nil && *existing.IdentifyRequestID == request.RequestID && existing.PDDProductID != nil {
@@ -240,7 +240,7 @@ func (service *Service) IdentifyCurrentPage(ctx context.Context, taskID uint64,
}
return internalError(err)
}
if record.Source != models.CollectionTaskSourceAgentCurrentPage || record.DeviceID == nil || *record.DeviceID != deviceRecord.ID {
if (record.Source != models.CollectionTaskSourceAgentCurrentPage && record.Source != models.CollectionTaskSourceImageSearch) || record.DeviceID == nil || *record.DeviceID != deviceRecord.ID {
return serviceError(CodeTaskNotFound, "任务不存在")
}
if record.IdentifyRequestID != nil && *record.IdentifyRequestID == request.RequestID && record.PDDProductID != nil {
+5 -1
View File
@@ -290,7 +290,11 @@ func (service *Service) payload(record models.CollectionTask, replayed bool) (Ta
}
var imageSearch json.RawMessage
if record.ImageSearchSnapshot != nil && *record.ImageSearchSnapshot != "" {
imageSearch = json.RawMessage(*record.ImageSearchSnapshot)
snapshot, snapshotErr := loadImageSearchSnapshot(record)
if snapshotErr != nil {
return TaskPayload{}, snapshotErr
}
imageSearch, _ = json.Marshal(snapshot.ImageSearchImage)
if !json.Valid(imageSearch) {
return TaskPayload{}, internalError(errors.New("stored image search snapshot is invalid JSON"))
}