From f254e9c294a124f3c566afeaa3b840f661298760 Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 4 Oct 2023 10:55:20 +0200 Subject: [PATCH 1/3] growl: don't fumble the activity logging consent Previous logic for reading %settings-event facts was a little to eager in declaring explicit non-consent. It would also set the flag to false in cases where we received updates not matching what we were looking for. Now, it's not entirely certain that this was a problem, but we did observe "disabled growl" on ships that had the setting toggle on the frontend set to true, and this seemed like the only viable cause of that. We also update +on-load to re-set the flag from the current settings value, to correct any lingering mismatching states. --- desk/app/growl.hoon | 58 ++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/desk/app/growl.hoon b/desk/app/growl.hoon index 998c340e..9a328bca 100644 --- a/desk/app/growl.hoon +++ b/desk/app/growl.hoon @@ -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 | @@ -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) @@ -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 @@ -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 -- From 7bd7e4f54bdbc9796ec506e11bc161730bb76b27 Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 4 Oct 2023 11:00:33 +0200 Subject: [PATCH 2/3] bark: small tweaks to threads The json serialization logic hadn't been updated correctly. We leave a better comment for easier reference. And we want more details to look at in the case something errors out. --- desk/ted/mailchimp/update-merge-fields.hoon | 5 +++-- desk/ted/save-summary.hoon | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/desk/ted/mailchimp/update-merge-fields.hoon b/desk/ted/mailchimp/update-merge-fields.hoon index e68ab9cb..643b8513 100644 --- a/desk/ted/mailchimp/update-merge-fields.hoon +++ b/desk/ted/mailchimp/update-merge-fields.hoon @@ -5,7 +5,8 @@ :: :: > -bark!mailchimp-update-merge-fields 'apikey' 'list-id' 'sampel@example.com' 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 @@ -26,7 +27,7 @@ :: ^= body %- some - %- as-octt:mimes:html + %- as-octs:mimes:html %- en:json:html %- pairs:enjs:format ['merge_fields' o+vars]~ diff --git a/desk/ted/save-summary.hoon b/desk/ted/save-summary.hoon index 4d2022a2..675301e2 100644 --- a/desk/ted/save-summary.hoon +++ b/desk/ted/save-summary.hoon @@ -63,5 +63,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)) From 245503f5e7552c82cacd6ec685871b414ae19da5 Mon Sep 17 00:00:00 2001 From: fang Date: Thu, 5 Oct 2023 10:24:31 +0200 Subject: [PATCH 3/3] bark: clear bark data on-opt-out We shouldn't leave stale data in the mailchimp database, but rather wipe any data we've collected for users that are explicitly opting out. --- desk/app/bark.hoon | 10 ++++++++-- desk/ted/save-summary.hoon | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/desk/app/bark.hoon b/desk/app/bark.hoon index f70599fc..bdebea42 100644 --- a/desk/app/bark.hoon +++ b/desk/app/bark.hoon @@ -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) @@ -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) diff --git a/desk/ted/save-summary.hoon b/desk/ted/save-summary.hoon index 675301e2..0f569d49 100644 --- a/desk/ted/save-summary.hoon +++ b/desk/ted/save-summary.hoon @@ -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) @@ -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)]