Skip to content

Commit

Permalink
Use default redirect type when creating redirectss from suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
conorhepi committed Dec 20, 2024
1 parent b113e3e commit 5179e86
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using Geta.NotFoundHandler.Core.Redirects;
using Geta.NotFoundHandler.Data;
using Geta.NotFoundHandler.Infrastructure.Configuration;
using Microsoft.Extensions.Options;
using X.PagedList;

namespace Geta.NotFoundHandler.Core.Suggestions
Expand All @@ -12,15 +14,18 @@ public class DefaultSuggestionService : ISuggestionService
private readonly ISuggestionLoader _suggestionLoader;
private readonly IRedirectsService _redirectsService;
private readonly ISuggestionRepository _suggestionRepository;
private readonly NotFoundHandlerOptions _options;

public DefaultSuggestionService(
ISuggestionLoader suggestionLoader,
IRedirectsService redirectsService,
ISuggestionRepository suggestionRepository)
ISuggestionRepository suggestionRepository,
IOptions<NotFoundHandlerOptions> options)
{
_suggestionLoader = suggestionLoader;
_redirectsService = redirectsService;
_suggestionRepository = suggestionRepository;
_options = options.Value;
}

public IPagedList<SuggestionSummary> GetSummaries(int page, int pageSize)
Expand Down Expand Up @@ -58,7 +63,7 @@ private void SaveIgnoredRedirect(string oldUrl)

private void SaveRedirect(SuggestionRedirect suggestionRedirect)
{
var customRedirect = new CustomRedirect(suggestionRedirect.OldUrl, suggestionRedirect.NewUrl);
var customRedirect = new CustomRedirect(suggestionRedirect.OldUrl, suggestionRedirect.NewUrl, false, _options.DefaultRedirectType);
_redirectsService.AddOrUpdate(customRedirect);
}

Expand Down

0 comments on commit 5179e86

Please sign in to comment.