simonv3/quick-survey

Email notifications of submitted surveys?

Opened this issue · 8 comments

I love Quick-Survey on Sandstorm! I am using it for my university course, and having some sort of email notification of submitted surveys would really help me make sure I am responsive to student submissions. Is this something being considered for the future?

Thanks very much,
Paul

Hah! @paulproteus literally just pinged me to implement this on IRC.

I'm going to take some time after-work this week to do some upgrades and updates to Quick Survey. As far as I'm aware sending out e-mails isn't super easy yet with Sandstorm so it might take some work, but this has always been a desired feature for me.

Thanks for the very prompt and hopeful reply🙂 I will keep my fingers crossed and see how things develop!

Thanks again,
Paul

@simonv3 This actually shouldn't be too hard now that we bundle node-capnp directly in meteor-spk.

Do this globally:

var Capnp = require("capnp");
var SandstormHttpBridge = Capnp.importSystem("sandstorm/sandstorm-http-bridge.capnp").SandstormHttpBridge;

var capnpConnection = null;
var httpBridge = null;

function getHttpBridge() {
  if (!httpBridge) {
    capnpConnection = Capnp.connect("unix:/tmp/sandstorm-api");
    httpBridge = capnpConnection.restore(null, SandstormHttpBridge);
  }
  return httpBridge;
}

Then, inside a Meteor method call (so that this.connection is available):

var sessionId = this.connection.sandstormSessionId()

var context = getHttpBridge().getSessionContext(sessionId).context;

context.send({
  date: Date.now().toString() + "000000",
  to: [ { address: "whatever@example.com" } ],
  messageId: Random.id(),
  subject: "This is the subject line"
  text: "This is the text body"
  html: "<p>This is the HTML body (optional)</p>"
}).catch(function (err) {
  console.error("Failed sending email:", err.stack);
});

DISCLAIMER: I haven't tested the above code. It may need some tweaks.

That's awesome to hear, and that does look pretty painless. I'll let you all know how I get along.

Note on this: I managed to update Meteor to the newest version, which goes a long way to implementing this.

Is there any time line for this feature? We would like to implement it for a hospital?

@ort163 unfortunately I don't have a lot of time to work on quick-survey recently because I'm so swamped with work for my day job. I can't even honestly promise that I can look at it over the weekend :(

Edit: If you know anyone who is a Meteor / JS developer this should be fairly straightforward to implement though, even if they don't have much Sandstorm experience.