2026-03-11 22:50:36 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-03-19 16:55:49 +00:00
|
|
|
"errors"
|
2026-03-11 22:50:36 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
2026-03-12 23:49:16 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/platform"
|
2026-03-19 16:55:49 +00:00
|
|
|
)
|
2026-03-11 22:50:36 +00:00
|
|
|
|
|
|
|
|
type createReviewPool struct {
|
2026-03-19 16:55:49 +00:00
|
|
|
Status string `json:"status"`
|
|
|
|
|
TaskID int32 `json:"task_id"`
|
|
|
|
|
Updates *platform.PoolUpdate `json:"updates"`
|
2026-03-11 22:50:36 +00:00
|
|
|
}
|
|
|
|
|
type createdReviewPool struct{}
|
|
|
|
|
|
2026-03-12 23:49:16 +00:00
|
|
|
func postReviewPool(ctx context.Context, r *http.Request, user platform.User, req createReviewPool) (*createdReviewPool, *nhttp.ErrorWithStatus) {
|
2026-03-19 16:55:49 +00:00
|
|
|
_, err := platform.ReviewPoolCreate(ctx, user, req.TaskID, req.Status, req.Updates)
|
|
|
|
|
|
2026-03-11 22:50:36 +00:00
|
|
|
if err != nil {
|
2026-03-19 16:55:49 +00:00
|
|
|
if errors.As(err, &platform.ErrorNotFound{}) {
|
|
|
|
|
return nil, nhttp.NewErrorStatus(http.StatusNotFound, "review task %d not found", req.TaskID)
|
2026-03-11 22:50:36 +00:00
|
|
|
}
|
2026-03-19 16:55:49 +00:00
|
|
|
return nil, nhttp.NewError("failed to set review: %w", err)
|
2026-03-11 22:50:36 +00:00
|
|
|
}
|
2026-03-19 16:55:49 +00:00
|
|
|
return &createdReviewPool{}, nil
|
2026-03-11 22:50:36 +00:00
|
|
|
}
|