Check for maps with the exact same name on submit #325
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user