Check for maps with the exact same name on submit #325

Merged
Quaternions merged 1 commits from same-name into staging 2026-03-03 17:49:08 +00:00

View File

@@ -32,6 +32,7 @@ var (
ErrReleaseNoUploadedAssetID = errors.New("Only submissions with a UploadedAssetID can be released")
ErrAcceptOwnSubmission = fmt.Errorf("%w: You cannot accept your own submission as the submitter", ErrPermissionDenied)
ErrCreateSubmissionRateLimit = errors.New("You must not create more than 5 submissions every 10 minutes")
ErrDisplayNameNotUnique = errors.New("Cannot submit: A map exists with the same DisplayName")
)
// POST /submissions
@@ -552,6 +553,24 @@ func (svc *Service) ActionSubmissionTriggerSubmit(ctx context.Context, params ap
}
}
// check for maps with the exact same name
filter := service.NewMapFilter()
filter.SetDisplayName(submission.DisplayName)
maps_list, err := svc.inner.ListMaps(
ctx,
filter,
model.Page{
Number: 1,
Size: 1,
},
)
if err != nil {
return err
}
if len(maps_list) != 0 {
return ErrDisplayNameNotUnique
}
// transaction
target_status := model.SubmissionStatusSubmitting
update := service.NewSubmissionUpdate()