Skip to content

Commit

Permalink
Merge pull request #224 from tloncorp/m/re-growl
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesacklin authored Oct 6, 2023
2 parents 6fc2b36 + 245503f commit 5679138
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 29 deletions.
10 changes: 8 additions & 2 deletions desk/app/bark.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@
%bark-remove-recipient
=+ !<(=ship vase)
?> =(src.bowl ship)
`this(recipients (~(del in recipients) ship))
:_ this(recipients (~(del in recipients) ship))
:_ ~
:* %pass /save-summary/(scot %p src.bowl)/(scot %da now.bowl)
%arvo %k %fard
%landscape %save-summary %noun
!>(`[tlon.api mailchimp.api src.bowl %wipe ~])
==
::
%bark-generate-summaries
?> =(src.bowl our.bowl)
Expand Down Expand Up @@ -107,7 +113,7 @@
== ==
vase
?~ result
`this(recipients (~(del in recipients) src.bowl))
$(mark %bark-remove-recipient, vase !>(src.bowl))
::TODO maybe drop the result (or re-request) if the timestamp is too old?
:_ this
:~ :* %pass /save-summary/(scot %p src.bowl)/(scot %da requested.u.result)
Expand Down
58 changes: 34 additions & 24 deletions desk/app/growl.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
::
|%
+$ card card:agent:gall
+$ versioned-state
$% state-0
==
+$ state-0 [%0 enabled=_| bark-host=_~rilfet-palsum]
+$ state-1 [%1 enabled=_| bark-host=_~rilfet-palsum]
--
::
:: This agent should eventually go into landscape
::
=| state-0
=| state-1
=* state -
%- agent:dbug
%+ verb |
Expand Down Expand Up @@ -42,6 +39,26 @@
'logActivity'
[%b |]
::
++ on-save !>(state)
++ on-load
|= old-state=vase
|^ ^- (quip card _this)
=+ !<(old=versioned-state old-state)
?- -.old
%0
=^ caz this on-init :: %0 dropped the ball, re-initialize
:_ this
:_ caz
[%pass /settings %agent [our.bowl %settings] %leave ~]
::
%1
[~ this(state old)]
==
::
+$ versioned-state $%(state-0 state-1)
+$ state-0 [%0 enabled=_| bark-host=_~rilfet-palsum]
--
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
Expand Down Expand Up @@ -91,17 +108,19 @@
%fact
?. =(%settings-event p.cage.sign) (on-agent:def wire sign)
=+ !<(=event:settings q.cage.sign)
=/ new=?
=; =val:settings
?:(?=(%b -.val) p.val |)
?+ event b+|
[%put-bucket %groups %groups *] (~(gut by bucket.event) 'logActivity' b+|)
[%del-bucket %groups %groups] b+|
[%put-entry %groups %groups %'logActivity' *] val.event
[%del-entry %groups %groups %'logActivity'] b+|
=/ new=(unit ?)
=; val=(unit val:settings)
?~ val ~
`?:(?=(%b -.u.val) p.u.val |)
?+ event ~
[%put-bucket %groups %groups *] `(~(gut by bucket.event) 'logActivity' b+|)
[%del-bucket %groups %groups] `b+|
[%put-entry %groups %groups %'logActivity' *] `val.event
[%del-entry %groups %groups %'logActivity'] `b+|
==
?: =(new enabled) [~ this]
(on-poke ?:(new %enable %disable) !>(~))
?~ new [~ this]
?: =(u.new enabled) [~ this]
(on-poke ?:(u.new %enable %disable) !>(~))
==
::
++ on-watch on-watch:def
Expand All @@ -111,15 +130,6 @@
++ on-leave
|= =path
`this
++ on-save !>(state)
++ on-load
|= old-state=vase
^- (quip card _this)
=/ old !<(versioned-state old-state)
?- -.old
%0
`this(state old)
==
++ on-arvo on-arvo:def
++ on-peek on-peek:def
--
5 changes: 3 additions & 2 deletions desk/ted/mailchimp/update-merge-fields.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
::
:: > -bark!mailchimp-update-merge-fields 'apikey' 'list-id' '[email protected]' fields
:: where fields is a (map cord json)
:: and the list-id is most easily discovered through the /lists api
:: and the list-id is most easily discovered through the /lists api:
:: curl -X GET 'https://us14.api.mailchimp.com/3.0/lists?count=99&offset=0' --user "anystring:${apikey}"
::
/- spider
/+ *strandio
Expand All @@ -26,7 +27,7 @@
::
^= body
%- some
%- as-octt:mimes:html
%- as-octs:mimes:html
%- en:json:html
%- pairs:enjs:format
['merge_fields' o+vars]~
Expand Down
6 changes: 5 additions & 1 deletion desk/ted/save-summary.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
::
$= summary
$% [%life [sen=@ud rec=@ud gro=@t] [dms=@ud etc=@ud group=@t chat=@t]]
[%wipe ~]
==
==
=/ args !<([~ arg-mold] arg)
Expand Down Expand Up @@ -45,6 +46,9 @@
=; vars=(map @t json)
!>(`[mailchimp.args u.mail vars])
%- ~(gas by *(map @t json))
=? summary.args ?=(%wipe -.summary.args)
[%life [0 0 ''] [0 0 '' '']]
?> ?=(%life -.summary.args)
=, summary.args
:~ ['MSGS_SENT' (numb:enjs:format sen)]
['MSGS_RECD' (numb:enjs:format rec)]
Expand All @@ -63,5 +67,5 @@
::
=/ [%khan %arow %.y %noun vs=vase] simp
=+ !<([gud=? msg=@t] vs)
?. gud ~|(msg !!)
?. gud ~|([ship=ship.args mail=u.mail msg] !!)
(pure:m !>(msg))

0 comments on commit 5679138

Please sign in to comment.