submissions: Check for duplicate mapfix #219
@@ -35,7 +35,7 @@ var(
|
||||
|
||||
var (
|
||||
ErrCreationPhaseMapfixesLimit = errors.New("Active mapfixes limited to 20")
|
||||
ErrActiveMapfixSameTargetAssetID = errors.New("There is an active mapfix with the same TargetAssetID")
|
||||
ErrActiveMapfixSameTargetAssetID = errors.New("There is an active mapfix for this map already")
|
||||
ErrAcceptOwnMapfix = fmt.Errorf("%w: You cannot accept your own mapfix as the submitter", ErrPermissionDenied)
|
||||
ErrCreateMapfixRateLimit = errors.New("You must not create more than 5 mapfixes every 10 minutes")
|
||||
)
|
||||
@@ -77,6 +77,24 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a mapfix targetting the same map exists in creation phase
|
||||
{
|
||||
filter := datastore.Optional()
|
||||
filter.Add("submitter", int64(userId))
|
||||
filter.Add("target_asset_id", request.TargetAssetID)
|
||||
filter.Add("status_id", CreationPhaseMapfixStatuses)
|
||||
active_mapfixes, err := svc.DB.Mapfixes().List(ctx, filter, model.Page{
|
||||
Number: 1,
|
||||
Size: 1,
|
||||
},datastore.ListSortDisabled)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(active_mapfixes) != 0{
|
||||
return nil, ErrActiveMapfixSameTargetAssetID
|
||||
}
|
||||
}
|
||||
|
||||
// Check if TargetAssetID actually exists
|
||||
{
|
||||
_, err := svc.Maps.Get(ctx, &maps.IdMessage{
|
||||
|
||||
Reference in New Issue
Block a user