Merge pull request #13 from tloncorp/ns/send-emails-with-notification-count

Send emails with notification count
This commit is contained in:
midsum-salrux 2023-05-10 16:24:24 -04:00 committed by GitHub
commit 38625f3baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 8 deletions

View File

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

View File

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

View File

@ -65,5 +65,5 @@
?~ full-file.rep !!
=/ body=cord q.data.u.full-file.rep
%- pure:m
!> [body ~]
!> `body
--