diff --git a/desk/app/activity.hoon b/desk/app/activity.hoon index e0a4d7a9bd..17a299333b 100644 --- a/desk/app/activity.hoon +++ b/desk/app/activity.hoon @@ -6,15 +6,16 @@ |% +$ card card:agent:gall :: - +$ versioned-state - $% state-1 + +$ current-state + $: %2 + allowed=notifications-allowed:a + =indices:a + =activity:a + =volume-settings:a == - :: - +$ state-1 - [%1 =indices:a =activity:a =volume-settings:a] -- :: -=| state-1 +=| current-state =* state - :: ::NOTE setting this to true causes some parts of state & update management to @@ -90,12 +91,22 @@ :: ++ load |= =vase - ^+ cor + |^ ^+ cor ?: ?=([%0 *] q.vase) init =+ !<(old=versioned-state vase) - ?> ?=(%1 -.old) + =? old ?=(%1 -.old) (state-1-to-2 old) + ?> ?=(%2 -.old) =. state old cor + +$ versioned-state $%(state-2 state-1) + +$ state-2 current-state + +$ state-1 + [%1 =indices:a =activity:a =volume-settings:a] + ++ state-1-to-2 + |= old=state-1 + ^- state-2 + [%2 %all +.old] + -- :: ++ scry-path |= [=dude:gall =path] @@ -274,7 +285,8 @@ %noun ?+ q.vase ~|(bad-poke+mark !!) %migrate - =. state *state-1 + =. state *current-state + =. allowed %all migrate == :: @@ -285,6 +297,7 @@ %del (del +.action) %read (read +.action) %adjust (adjust +.action) + %allow-notifications (allow +.action) == == :: @@ -397,6 +410,9 @@ :: [%x %volume-settings ~] ``activity-settings+!>(volume-settings) + :: + [%x %notifications-allowed ~] + ``activity-allowed+!>(`notifications-allowed:a`allowed) == :: ++ feed @@ -512,7 +528,7 @@ =/ =source:a (determine-source inc) =? cor !importing (give %fact ~[/] activity-update+!>([%add source time-id event])) - =? cor &(!importing notify) + =? cor &(!importing notify (is-allowed inc)) (give %fact ~[/notifications] activity-event+!>([time-id event])) =. indices =/ =stream:a (put:on-event:a stream:base time-id event) @@ -541,6 +557,21 @@ (add-to-index group-src time-id event(child &)) == :: +++ is-allowed + |= =incoming-event:a + ?: ?=(%all allowed) & + ?: ?=(%none allowed) | + =/ type (determine-event-type incoming-event) + ?+ type | + %reply & + %dm-invite & + %dm-post & + %dm-reply & + %post-mention & + %reply-mention & + %dm-post-mention & + %dm-reply-mention & + == ++ del |= =source:a ^+ cor @@ -730,6 +761,11 @@ :: recalculate activity summary with new settings (refresh source) :: +++ allow + |= na=notifications-allowed:a + ^+ cor + =. allowed na + (give %fact ~[/] activity-update+!>([%allow-notifications na])) ++ get-children |= =source:a ^- (list source:a) diff --git a/desk/lib/activity-json.hoon b/desk/lib/activity-json.hoon index c642a3f135..ff7fe73198 100644 --- a/desk/lib/activity-json.hoon +++ b/desk/lib/activity-json.hoon @@ -237,6 +237,8 @@ :~ time+s+(scot %ud time.te) event+(event event.te) == + :: + ++ allowed (lead %s) +| %collections :: ++ stream @@ -297,6 +299,7 @@ %del (source +.u) %read (read +.u) %adjust (adjusted +.u) + %allow-notifications (allowed +.u) == :: ++ added @@ -374,6 +377,7 @@ del/source read/read adjust/adjust + allow-notifications/(su (perk %all %some %none ~)) == :: ++ add diff --git a/desk/lib/mark-warmer.hoon b/desk/lib/mark-warmer.hoon index c346a93806..870f65beae 100644 --- a/desk/lib/mark-warmer.hoon +++ b/desk/lib/mark-warmer.hoon @@ -35,6 +35,7 @@ /$ act-sum %activity-summary %json /$ act-vol %activity-settings %json /$ act-evt %activity-event %json +/$ act-allow %activity-allowed %json /$ act-stream %activity-stream %json /$ act-feed %activity-feed %json /$ act-fe-it %activity-feed-init %json diff --git a/desk/mar/activity/allowed.hoon b/desk/mar/activity/allowed.hoon new file mode 100644 index 0000000000..8baa02bd81 --- /dev/null +++ b/desk/mar/activity/allowed.hoon @@ -0,0 +1,14 @@ +/- a=activity +/+ aj=activity-json +|_ na=notifications-allowed:a +++ grad %noun +++ grow + |% + ++ noun na + ++ json (allowed:enjs:aj na) + -- +++ grab + |% + ++ noun notifications-allowed:a + -- +-- diff --git a/desk/sur/activity.hoon b/desk/sur/activity.hoon index 9c8d03cf04..f7d987a297 100644 --- a/desk/sur/activity.hoon +++ b/desk/sur/activity.hoon @@ -27,12 +27,14 @@ :: $del: remove a source and all its activity :: $read: mark an event as read :: $adjust: adjust the volume of an source +:: $allow-notifications: change which notifications are allowed :: +$ action $% [%add =incoming-event] [%del =source] [%read =source =read-action] [%adjust =source =(unit volume-map)] + [%allow-notifications allow=notifications-allowed] == :: :: $read-action: mark activity read @@ -55,12 +57,14 @@ :: $del: a source and its activity were removed :: $read: a source's activity state was updated :: $adjust: the volume of a source was adjusted +:: $allow-notifications: the allowed notifications were changed :: +$ update $% [%add =source time-event] [%del =source] [%read =source =activity-summary] [%adjust =source volume-map=(unit volume-map)] + [%allow-notifications allow=notifications-allowed] == :: +| %basics @@ -165,6 +169,7 @@ == +$ unread-point [message-key count=@ud notify=_|] +$ volume [unreads=? notify=?] ++$ notifications-allowed ?(%all %some %none) +$ activity-bundle $: =source latest=time