Skip to content

Commit

Permalink
Merge pull request #116 from sanjiva/master
Browse files Browse the repository at this point in the history
Small changes in all 3 pieces (see individual commit messages)
  • Loading branch information
sanjiva committed Nov 16, 2019
2 parents f786b60 + f29856f commit a68ac45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions distributor/src/distributor/messenger.bal
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function sendSMS(string message, string resultId) {
log:printInfo("Sending SMS for " + resultId);
}
foreach string targetMobile in currentMobileSubscribers {
log:printInfo("Sending SMS for " + resultId + " to " + targetMobile);
var response = twilioClient->sendSms(sourceMobile, targetMobile, message);
if response is error {
log:printError("Message sending failed for \'" + targetMobile + "\' due to error:" +
Expand Down
2 changes: 1 addition & 1 deletion subscriber/src/subscriber/save.bal
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function saveImagePdf(map<json> imageJson) {
# + return - returns the base name for the file
function getFileNameBase(string electionCode, map<json> result) returns string {
// start with sequence # and type code
string name = electionCode + "-" + result.sequence_number.toString() + "-" +
string name = (wantCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" +
(result.'type.toString() == PRESIDENTIAL_RESULT ? "PE1" : "PE2") + "-";

string resultLevel = result.level.toString();
Expand Down
3 changes: 3 additions & 0 deletions subscriber/src/subscriber/subscriber.bal
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ boolean wantXml = false;
boolean wantHtml = false;
boolean sortedHtml = false;

boolean wantCode = false;

http:OutboundAuthConfig? auth = ();
http:Client? imageClient = ();

Expand All @@ -52,6 +54,7 @@ public function main (string secret, // secret to send to the hub
boolean image = false, // do I want the image?
boolean html = false, // do I want HTML?
boolean sorted = true, // do I want HTML results sorted highest to lowest
boolean wantCode = false, // do I want electionCode in the filename
string homeURL = "https://resultstest.ecdev.opensource.lk", // where do I subscribe at
int port = 1111, // port I'm going to open
string myURL = "" // how to reach me over the internet
Expand Down
6 changes: 3 additions & 3 deletions testdriver/src/testdriver/sendresults.bal
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,16 @@ function sendResult (http:Client hc, string electionCode, string resType, string
http:Response hr;

// sent alert
string params = "?level=" + <string>result.level;
string params = "/?level=" + <string>result.level;
if result.ed_name is string {
params += "&ed_name=" + check encoding:encodeUriComponent(<string>result.ed_name, "UTF-8");
if result.pd_name is string {
params += "&pd_name=" + check encoding:encodeUriComponent(<string>result.pd_name, "UTF-8");
}
}
hr = check hc->post ("/result/notification/" + electionCode + "/" + resType + "/" + resCode + "/?level=" + <string>result.level, <json>{});
hr = check hc->post ("/result/notification/" + electionCode + "/" + resType + "/" + resCode + params, <json>{});
if hr.statusCode != http:STATUS_ACCEPTED {
io:println("Error while posting result notification to: /result/notification/" + electionCode + "/" + resType + "/" + resCode);
io:println("Error while posting result notification to: /result/notification/" + electionCode + "/" + resType + "/" + resCode + params);
io:println("\tstatus=", hr.statusCode, ", contentType=", hr.getContentType(), " payload=", hr.getTextPayload());
return error ("Unable to post notification for " + resCode);
}
Expand Down

0 comments on commit a68ac45

Please sign in to comment.