Last active
August 29, 2015 14:13
-
-
Save windley/1fb80cde5d08fbd9fb78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
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.
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
Whoa, this changes everything!