Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ IOptions<ContactFormSettings> contactFormAccessor
public override async Task<ContactFormSettings> GetCurrentContactForm()
{
var form = await base.GetCurrentContactForm();
if (!string.IsNullOrWhiteSpace(_currentSite.AccountApprovalEmailCsv))

// if we require account approval and we don't have any contact form recipients in config,
// use the former recipient
if (!string.IsNullOrWhiteSpace(_currentSite.AccountApprovalEmailCsv) && string.IsNullOrWhiteSpace(form.NotificationEmailCsv))
{
var newForm = new ContactFormSettings
{
Expand All @@ -36,6 +39,5 @@ public override async Task<ContactFormSettings> GetCurrentContactForm()

return form;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Integration library for usingcloudscribe SimpleContactForm with cloudscribe.Core</Description>
<Version>6.0.0</Version>
<Version>6.0.1</Version>
<TargetFramework>net6.0</TargetFramework>
<Authors>Joe Audette</Authors>
<PackageTags>cloudscribe;contact form</PackageTags>
Expand All @@ -12,7 +12,11 @@
</PropertyGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="\"/>
<Compile Remove="SiteContactFormService.cs" />
</ItemGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
36 changes: 21 additions & 15 deletions src/cloudscribe.SimpleContactForm/Components/ContactFormService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Last Modified: 2018-03-18
//

using cloudscribe.Email;
using cloudscribe.SimpleContactForm.Models;
using cloudscribe.SimpleContactForm.ViewModels;
using cloudscribe.Web.Common.Models;
Expand All @@ -19,22 +20,25 @@ public class ContactFormService
{
public ContactFormService(
IEnumerable<IProcessContactForm> messageProcessors,
IContactFormResolver contactFormResolver,
IRecaptchaKeysProvider recaptchaKeysProvider,
ILogger<ContactFormService> logger
IContactFormResolver contactFormResolver,
IRecaptchaKeysProvider recaptchaKeysProvider,
ILogger<ContactFormService> logger,
IEmailSenderResolver emailSenderResolver
)
{
_contactFormResolver = contactFormResolver;
_recaptchaKeys = recaptchaKeysProvider;
_messageProcessors = messageProcessors;
_log = logger;
}
_recaptchaKeys = recaptchaKeysProvider;
_messageProcessors = messageProcessors;
_log = logger;
_emailSenderResolver = emailSenderResolver;
}

private IContactFormResolver _contactFormResolver;
private IRecaptchaKeysProvider _recaptchaKeys;
private ContactFormSettings _form = null;
private IContactFormResolver _contactFormResolver;
private IRecaptchaKeysProvider _recaptchaKeys;
private ContactFormSettings _form = null;
private IEnumerable<IProcessContactForm> _messageProcessors;
private ILogger _log;
private ILogger _log;
private IEmailSenderResolver _emailSenderResolver;

public async Task<ContactFormSettings> GetFormSettings()
{
Expand All @@ -46,13 +50,15 @@ public async Task<ContactFormSettings> GetFormSettings()
return _form;
}

public async Task<bool> IsConfigured()
public virtual async Task<bool> IsConfigured()
{
var form = await GetFormSettings().ConfigureAwait(false);
if(string.IsNullOrEmpty(form.NotificationEmailCsv)) { return false; }
// if(string.IsNullOrEmpty(form.NotificationEmailCsv)) { return false; }

var sender = await _emailSenderResolver.GetEmailSender();
if(sender == null) { return false; }

//var smtpSettings = await smtpOptionsProvider.GetSmtpOptions().ConfigureAwait(false);
//if (string.IsNullOrEmpty(smtpSettings.Server)) { return false; }
if (!await sender.IsConfigured()) { return false; }

return true;
}
Expand Down
24 changes: 1 addition & 23 deletions src/cloudscribe.SimpleContactForm/StartupExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@ public static IServiceCollection AddCloudscribeSimpleContactForm(
IConfiguration configuration,
bool includeDefaultMessageProcessor = true)
{


services.Configure<RecaptchaKeys>(configuration.GetSection("RecaptchaKeys"));
services.Configure<ContactFormMessageOptions>(configuration.GetSection("ContactFormMessageOptions"));
services.Configure<ContactFormSettings>(configuration.GetSection("ContactFormSettings"));



services.TryAddScoped<IRecaptchaKeysProvider, ConfigRecaptchaKeysProvider>();
services.AddScoped<ContactFormService, ContactFormService>();

services.TryAddScoped<IContactFormResolver, ConfigContactFormResolver>();
services.TryAddScoped<ITenantResolver, NullTenantResolver>();
services.TryAddScoped<IPrePopulateContactForm, NotImplementedContactFromPopulator>();

// pass in false if you want to implement custom logic for notification
// instead of the built in logic
// there can be multiple registered IProcessMessages implementations and all of them will be invoked
Expand All @@ -44,31 +43,10 @@ public static IServiceCollection AddCloudscribeSimpleContactForm(
{
services.AddScoped<IProcessContactForm, ContactFormProcessor>();
}



return services;
}

//[Obsolete("AddEmbeddedViewsForCloudscribeSimpleContactForm is deprecated, please use AddCloudscribeSimpleContactFormViews instead.")]
//public static RazorViewEngineOptions AddEmbeddedViewsForCloudscribeSimpleContactForm(this RazorViewEngineOptions options)
//{
// options.FileProviders.Add(new EmbeddedFileProvider(
// typeof(ContactFormService).GetTypeInfo().Assembly,
// "cloudscribe.SimpleContactForm"
// ));

// return options;
//}

//public static RazorViewEngineOptions AddCloudscribeSimpleContactFormViews(this RazorViewEngineOptions options)
//{
// options.FileProviders.Add(new EmbeddedFileProvider(
// typeof(ContactFormService).GetTypeInfo().Assembly,
// "cloudscribe.SimpleContactForm"
// ));

// return options;
//}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A simple contact form for ASP.NET Core</Description>
<Version>6.0.0</Version>
<Version>6.0.1</Version>
<TargetFramework>net6.0</TargetFramework>
<Authors>Joe Audette</Authors>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
Expand Down