Trying to send a live mass message, now

This commit is contained in:
Rick Falkvinge
2017-01-03 21:39:32 +01:00
parent 2f818dc72b
commit 44d8b772ab
3 changed files with 35 additions and 24 deletions
+9 -8
View File
@@ -37,7 +37,7 @@ namespace Swarmops.Backend
customStrings["GeographyName"] = ((IHasGeography) resolver).Geography.Name;
}
OutboundComm.CreateNotification(Organization.FromIdentity(comm.OrganizationId),
NotificationResource.OutboundComm_Resolved, notifyStrings,
NotificationResource.OutboundComm_Resolved, notifyStrings, customStrings,
People.FromSingle(Person.FromIdentity(comm.SenderPersonId)));
}
@@ -76,22 +76,23 @@ namespace Swarmops.Backend
{
ICommsResolver resolver = FindResolver(comm);
// "Your message to[GeographyName] has been sent to all scheduled recipients.Of the[RecipientCount] planned recipients, [RecipientsSuccess] succeeded
// from Swarmops' horizon. (These can fail later for a number of reasons, from broken computers to hospitalized recipients.)
// Time spent transmitting: [TransmissionTime]."
// TODO: CONTINUE HERE
// "Your message to [GeographyName] has been sent to all scheduled recipients. Of the [RecipientCount] planned recipients,
// [RecipientsSuccess] succeeded from Swarmops' horizon. (These can fail later for a number of reasons, from broken
// computers to hospitalized recipients.) Time spent transmitting: [TransmissionTime]."
NotificationStrings notifyStrings = new NotificationStrings();
NotificationCustomStrings customStrings = new NotificationCustomStrings();
notifyStrings[NotificationString.OrganizationName] = Organization.FromIdentity(comm.OrganizationId).Name;
customStrings["RecipientCount"] = comm.Recipients.Count.ToString("N0");
customStrings["RecipientsSuccess"] = comm.RecipientsSuccess.ToString("N0");
customStrings["TransmissionTime"] =
(comm.ClosedDateTime - comm.StartTransmitDateTime).ToString("m min ss.ff sec");
if (resolver is IHasGeography)
{
customStrings["Geography"] = ((IHasGeography)resolver).Geography.Name;
customStrings["GeographyName"] = ((IHasGeography)resolver).Geography.Name;
}
OutboundComm.CreateNotification(Organization.FromIdentity(comm.OrganizationId),
NotificationResource.OutboundComm_Resolved, notifyStrings,
NotificationResource.OutboundComm_Sent, notifyStrings, customStrings,
People.FromSingle(Person.FromIdentity(comm.SenderPersonId)));
}
}
+21 -15
View File
@@ -29,12 +29,16 @@
}
function onClickSend() {
alertify.alert(SwarmopsJS.unescape('<%= this.Localized_SendMessageResult %>'));
onExecute(true);
return false;
}
function onClickTest() {
onExecute(false);
return false;
}
function onExecute(live) {
var body = $('#<%=this.TextMessage.ClientID%>').val().trim();
var subject = $('#<%=this.TextSubject.ClientID%>').val().trim();
@@ -51,22 +55,20 @@
return false;
}
if (<%=this.RunningOnSandbox%> && testMessageSandboxAddress == '')
{
if (<%=this.RunningOnSandbox%> && !live && testMessageSandboxAddress == '') {
// Prompt for an address to send to
// This should preferably be in a mod on just Sandbox and not in code everywhere
alertify.prompt("You're currently using the Sandbox. Where would you like a test message sent?", // TODO: LOC
function (evt, value)
{
testMessageSandboxAddress = value; // may need sanitation
onClickTest(); // rerun with value set
},
function() {
alertify.log('Canceled.');
});
function(evt, value) {
testMessageSandboxAddress = value; // may need sanitation
onClickTest(); // rerun with value set
},
function() {
alertify.log('Canceled.');
});
return false; // do not process at this time, wait for async response
return null; // do not process at this time, wait for async response
}
var jsonData = {
@@ -82,13 +84,17 @@
SwarmopsJS.ajaxCall
("/Pages/v5/Comms/SendMassMessage.aspx/ExecuteSend",
jsonData,
function (result) {
function(result) {
if (result.Success) {
alertify.alert(SwarmopsJS.unescape('<%= this.Localized_TestMessageResult %>'));
if (live) { // race condition but won't probably ever trigger
alertify.alert(SwarmopsJS.unescape('<%= this.Localized_TestMessageResult %>'));
} else {
alertify.alert(SwarmopsJS.unescape('<%= this.Localized_SendMessageResult %>'));
}
}
});
return false;
return null;
}
function onRecipientChange(oldClassIgnored, newRecipientClass) {
+5 -1
View File
@@ -6,6 +6,7 @@ using System.Web.UI;
using System.Web.UI.WebControls;
using Resources;
using Swarmops.Logic.Communications;
using Swarmops.Logic.Communications.Resolution;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
@@ -131,7 +132,10 @@ namespace Swarmops.Frontend.Pages.Comms
}
else // Send live
{
throw new NotImplementedException(); // TODO: Write resolver
// TODO: change resolver to match selected group
OutboundComm.CreateParticipantMail(subject, body, authData.CurrentUser, authData.CurrentUser, authData.CurrentOrganization, Geography.FromIdentity(geographyId));
return new AjaxCallResult { Success = true };
}
}