-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FromName and ReplyTo properties to SmtpSettingsPart (#8420)
- Loading branch information
Showing
9 changed files
with
201 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
using Orchard.Data.Migration; | ||
using System.Linq; | ||
using System.Xml; | ||
using Orchard.ContentManagement; | ||
using Orchard.Data.Migration; | ||
using Orchard.Email.Models; | ||
|
||
namespace Orchard.Email { | ||
public class Migrations : DataMigrationImpl { | ||
private readonly IContentManager _contentManager; | ||
|
||
public int Create() { | ||
public Migrations(IContentManager contentManager) => _contentManager = contentManager; | ||
|
||
return 1; | ||
// The first migration without any content should not exist but it has been deployed so we need to keep it. | ||
public int Create() => 1; | ||
|
||
public int UpdateFrom1() { | ||
// Migrate existing SmtpSettingPart.Address because we rename it to FromAddress. | ||
var siteSettingsItem = _contentManager.Query(contentTypeNames: "Site") | ||
.Slice(1) | ||
.SingleOrDefault(); | ||
|
||
var siteSettingsRecord = siteSettingsItem?.Record; | ||
|
||
if (siteSettingsRecord != null) { | ||
var xmlDoc = new XmlDocument(); | ||
xmlDoc.LoadXml(siteSettingsRecord.Data); | ||
|
||
var smtpSettingNode = xmlDoc.SelectSingleNode("//SmtpSettingsPart"); | ||
if (smtpSettingNode != null) { | ||
var smtpSettingsPart = siteSettingsItem.As<SmtpSettingsPart>(); | ||
smtpSettingsPart.FromAddress = smtpSettingNode.Attributes["Address"]?.Value; | ||
} | ||
} | ||
|
||
return 2; | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 43 additions & 25 deletions
68
src/Orchard.Web/Modules/Orchard.Email/Models/SmtpSettingsPart.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.