feat: support image search identity handoff and safe payload (#278)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user