simonv3 / quick-survey

A tool for quick surveys, try it out. (No longer maintained).
https://apps.sandstorm.io/app/wupmzqk4872vgsye9t9x5dmrdw17mad97dk21jvcm2ph4jataze0
MIT License
116 stars 49 forks source link

Email notifications of submitted surveys? #41

Open paulhibbitts opened 7 years ago

paulhibbitts commented 7 years ago

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

simonv3 commented 7 years ago

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.

paulhibbitts commented 7 years ago

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

Thanks again, Paul

kentonv commented 7 years ago

@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.

simonv3 commented 7 years ago

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

paulproteus commented 7 years ago

: D

simonv3 commented 7 years ago

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

markus2120 commented 7 years ago

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

simonv3 commented 7 years ago

@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.