diff --git a/desk/app/bark.hoon b/desk/app/bark.hoon index cb70887..a504de8 100644 --- a/desk/app/bark.hoon +++ b/desk/app/bark.hoon @@ -6,7 +6,7 @@ +$ versioned-state $% state-0 == -+$ state-0 [%0 mailchimp-api-key=cord hosting-api-key=cord recipients=(set ship)] ++$ state-0 [%0 tlon-api-key=tape mailchimp-api-key=tape recipients=(set ship)] -- :: =| state-0 @@ -22,8 +22,11 @@ |= [=mark =vase] ^- (quip card _this) ?+ mark (on-poke:def mark vase) - %set-api-key - `this(mailchimp-api-key !<(cord vase)) + %set-tlon-api-key + `this(tlon-api-key !<(tape vase)) + :: + %set-mailchimp-api-key + `this(mailchimp-api-key !<(tape vase)) :: %bark-add-recipient =+ !<(=ship vase) @@ -49,10 +52,13 @@ =/ result !<((unit [requested=time =carpet:hark]) vase) ?~ result `this(recipients (~(del in recipients) src.bowl)) - ~& >>> carpet.u.result - :: TODO create thread that calls the "get email address" thread (to be written) - :: and the "send email" thread and call it here - `this + :_ this + :~ :* %pass /mail-hosted-users/(scot %p src.bowl)/(scot %da requested.u.result) + %arvo %k %fard + %bark %mail-hosted-user %noun + !>(`[tlon-api-key mailchimp-api-key src.bowl carpet.u.result]) + == + == == ++ on-watch on-watch:def ++ on-agent on-agent:def diff --git a/desk/ted/mail-hosted-user.hoon b/desk/ted/mail-hosted-user.hoon new file mode 100644 index 0000000..9dfe6c8 --- /dev/null +++ b/desk/ted/mail-hosted-user.hoon @@ -0,0 +1,59 @@ +/- spider, hark +/+ *strandio +=, strand=strand:spider +=, dejs:format +|^ ted +++ template-vars + |= [=ship =carpet:hark] + ^- (map cord cord) + %- malt + :~ ['name' (scot %p ship)] + ['notifications' (crip (a-co:co ~(wyt by yarns.carpet)))] + == +++ ted + ^- thread:spider + |= arg=vase + =/ m (strand ,vase) + ^- form:m + =/ arg-mold + $: tlon-api-key=tape + mailchimp-api-key=tape + =ship + =carpet:hark + == + =/ args !<((unit arg-mold) arg) + ?~ args !! + ;< ~ bind:m + %- send-raw-card + :* %pass /check-email/(scot %p ship.u.args) + %arvo %k %fard + %bark %hosting-email %noun + !>(`[tlon-api-key.u.args ship.u.args]) + == + ;< [mire=wire mine=sign-arvo] bind:m take-sign-arvo + ?> ?=([%check-email @ *] mire) + ?> =(i.t.mire (scot %p ship.u.args)) + ?> ?=([%khan %arow %.y %noun *] mine) + :: + =/ [%khan %arow %.y %noun vs=vase] mine + =+ !<((unit cord) vs) + ?~ - !! + =/ email u.- + ;< ~ bind:m + %- send-raw-card + :* %pass /send-mailchimp-email/(scot %p ship.u.args) + %arvo %k %fard + %bark %mailchimp-send-template %noun + !>(`[mailchimp-api-key.u.args (trip email) "landscape-weekly-digest" (template-vars ship.u.args carpet.u.args)]) + == + ;< [wimp=wire simp=sign-arvo] bind:m take-sign-arvo + ?> ?=([%send-mailchimp-email @ *] wimp) + ?> =(i.t.wimp (scot %p ship.u.args)) + ?> ?=([%khan %arow %.y %noun *] simp) + :: + =/ [%khan %arow %.y %noun vs=vase] simp + =+ !<((unit cord) vs) + ?~ - !! + %- pure:m + !> u.- +-- diff --git a/desk/ted/mailchimp/send-template.hoon b/desk/ted/mailchimp/send-template.hoon index c6be3ad..94f52de 100644 --- a/desk/ted/mailchimp/send-template.hoon +++ b/desk/ted/mailchimp/send-template.hoon @@ -65,5 +65,5 @@ ?~ full-file.rep !! =/ body=cord q.data.u.full-file.rep %- pure:m - !> [body ~] + !> `body --