Added methods for generic mail sending (for plugins, for FWN specifically)

This commit is contained in:
Rick Falkvinge
2015-08-26 14:57:35 +02:00
parent 71abc1f1e8
commit 73204f7af4
3 changed files with 39 additions and 5 deletions
+23 -1
View File
@@ -112,7 +112,7 @@ namespace Swarmops.Logic.Communications
}
public static OutboundComm CreateMembershipLetter (ParticipantMailType mailType, Participation participation,
public static OutboundComm CreateParticipantMail (ParticipantMailType mailType, Participation participation,
Person actingPerson)
{
List<Person> recipients = People.FromSingle (participation.Person);
@@ -134,6 +134,28 @@ namespace Swarmops.Logic.Communications
}
public static OutboundComm CreateParticipantMail (string customSubject, string customBody, Participation participation,
Person actingPerson)
{
List<Person> recipients = People.FromSingle(participation.Person);
OutboundComm comm = OutboundComm.Create(null, null, participation.Organization,
CommResolverClass.Unknown, null,
CommTransmitterClass.CommsTransmitterMail,
new PayloadEnvelope(new ParticipantMailPayload(customSubject, customBody, participation, actingPerson)).ToXml(),
OutboundCommPriority.Low);
foreach (Person person in recipients)
{
comm.AddRecipient(person);
}
comm.Resolved = true;
return comm;
}
public static OutboundComm CreateNotification (Organization organization, string notificationResourceString)
{
List<Person> recipients = People.FromSingle (Person.FromIdentity (1)); // Initial Admin recipient
@@ -24,14 +24,13 @@ namespace Swarmops.Logic.Communications.Transmission
public string SubjectTemplate { get; set; }
public string BodyTemplate { get; set; }
public ParticipantMailPayload (ParticipantMailType mailType, Participation participation, Person actingPerson)
{
Strings = new SerializableDictionary<MailPayloadString, string>();
switch (mailType)
{
case ParticipantMailType.MemberAddedWelcome:
case ParticipantMailType.ParticipantAddedWelcome:
Strings[MailPayloadString.ActingPerson] = actingPerson.Name;
Strings[MailPayloadString.MembershipExpiry] = participation.Expires.ToLongDateString();
Strings[MailPayloadString.OrganizationName] = participation.Organization.Name;
@@ -52,6 +51,19 @@ namespace Swarmops.Logic.Communications.Transmission
}
}
public ParticipantMailPayload (string customSubject, string customBody, Participation participation,
Person actingPerson)
{
Strings = new SerializableDictionary<MailPayloadString, string>();
SubjectTemplate = customSubject;
BodyTemplate = customBody;
Strings[MailPayloadString.ActingPerson] = actingPerson.Name;
Strings[MailPayloadString.OrganizationName] = participation.Organization.Name;
}
public RenderedComm RenderComm (Person person)
{
string body = BodyTemplate;
@@ -105,7 +117,7 @@ namespace Swarmops.Logic.Communications.Transmission
public enum ParticipantMailType
{
Unknown = 0,
MemberAddedWelcome
ParticipantAddedWelcome
}
[Serializable]
+1 -1
View File
@@ -116,7 +116,7 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
Participation newParticipation = Participation.Create (newPerson, CurrentOrganization, DateTime.Today.AddYears (1));
OutboundComm.CreateMembershipLetter (ParticipantMailType.MemberAddedWelcome, newParticipation, CurrentUser);
OutboundComm.CreateParticipantMail (ParticipantMailType.ParticipantAddedWelcome, newParticipation, CurrentUser);
SwarmopsLogEntry logEntry = SwarmopsLog.CreateEntry (newPerson,
new Swarmops.Logic.Support.LogEntries.PersonAddedLogEntry (newParticipation, CurrentUser));