diff --git a/Logic/Swarm/Person.cs b/Logic/Swarm/Person.cs index f4a0b9ac..79678046 100644 --- a/Logic/Swarm/Person.cs +++ b/Logic/Swarm/Person.cs @@ -1195,5 +1195,19 @@ namespace Swarmops.Logic.Swarm public const int OpenLedgersIdentity = -1; + + public Participation ParticipationOf(Organization organization) + { + Participations participations = GetMemberships(); + foreach (Participation participation in participations) + { + if (participation.OrganizationId == organization.Identity) + { + return participation; + } + } + + throw new InvalidOperationException("No valid participation for requested organization"); + } } } \ No newline at end of file diff --git a/Site/Pages/v5/Comms/SendMassMessage.aspx.cs b/Site/Pages/v5/Comms/SendMassMessage.aspx.cs index 33097c66..936e7530 100644 --- a/Site/Pages/v5/Comms/SendMassMessage.aspx.cs +++ b/Site/Pages/v5/Comms/SendMassMessage.aspx.cs @@ -108,9 +108,31 @@ namespace Swarmops.Frontend.Pages.Comms public static AjaxCallResult ExecuteSend(int recipientTypeId, int geographyId, string mode, string subject, string body, string dummyMail, bool live) { - OutboundComm.CreateSandboxMail(subject, body, dummyMail); + AuthenticationData authData = GetAuthenticationDataAndCulture(); - return new AjaxCallResult {Success = false}; + if (PilotInstallationIds.IsPilot(PilotInstallationIds.DevelopmentSandbox)) + { + if (authData.CurrentUser.Identity == 1) + { + OutboundComm.CreateSandboxMail(subject, body, dummyMail); + return new AjaxCallResult {Success = true}; + } + + return new AjaxCallResult {Success = false}; // wtf, this shouldn't happen + } + else if (!live) + { + // Test mail + + OutboundComm.CreateParticipantMail(subject, body, + authData.CurrentUser.ParticipationOf(authData.CurrentOrganization), authData.CurrentUser); + + return new AjaxCallResult {Success = true}; + } + else // Send live + { + throw new NotImplementedException(); // TODO: Write resolver + } } public struct ConfirmPayoutResult