Skip to content

Instantly share code, notes, and snippets.

@windley
Last active August 29, 2015 14:13
Show Gist options
  • Save windley/1fb80cde5d08fbd9fb78 to your computer and use it in GitHub Desktop.
Save windley/1fb80cde5d08fbd9fb78 to your computer and use it in GitHub Desktop.
rule send_email_to_owner {
select when fuse email_for_owner
pre {
me = pds:get_all_me();
fleet_backchannel = CloudOS:subscriptionList(common:namespace(),"Fleet").head().pick("$.backChannel").defaultsTo("");
subj = event:attr("subj").defaultsTo("Message from Fuse");
msg = event:attr("msg").defaultsTo("This email contains no message");
html = event:attr("html").defaultsTo(msg);
recipient = me{"myProfileEmail"}.klog(">>>> email address >>>>") ;
attachment = event:attr("attachment");
filename = event:attr("filename").defaultsTo("attached_file");
mailtype = attachment.isnull() => "html"
| "attachment";
}
if( meta:eci() eq fleet_backchannel
&& not msg.isnull()
) then
choose mailtype {
html => sendgrid:sendhtml(me{"myProfileName"}, recipient, subj, msg, html);
attachment => sendgrid:sendattachment(me{"myProfileName"}, recipient, subj, msg, filename, attachment);
}
}
@rsbohn
Copy link

rsbohn commented Jan 22, 2015

Whoa, this changes everything!

@windley
Copy link
Author

windley commented Jan 22, 2015

Course the more elegant way to solve this problem is to rewrite sendgrid:send() with a nice configure statement to allow optional parameters and put all this inside the action itself.

@windley
Copy link
Author

windley commented Jan 22, 2015

No like button on Gist comments Randall, or you're get one. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment