Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activity: notifications setting #3615

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 46 additions & 10 deletions desk/app/activity.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -274,7 +285,8 @@
%noun
?+ q.vase ~|(bad-poke+mark !!)
%migrate
=. state *state-1
=. state *current-state
=. allowed %all
migrate
==
::
Expand All @@ -285,6 +297,7 @@
%del (del +.action)
%read (read +.action)
%adjust (adjust +.action)
%allow-notifications (allow +.action)
==
==
::
Expand Down Expand Up @@ -397,6 +410,9 @@
::
[%x %volume-settings ~]
``activity-settings+!>(volume-settings)
::
[%x %notifications-allowed ~]
``activity-allowed+!>(`notifications-allowed:a`allowed)
==
::
++ feed
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions desk/lib/activity-json.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@
:~ time+s+(scot %ud time.te)
event+(event event.te)
==
::
++ allowed (lead %s)
+| %collections
::
++ stream
Expand Down Expand Up @@ -297,6 +299,7 @@
%del (source +.u)
%read (read +.u)
%adjust (adjusted +.u)
%allow-notifications (allowed +.u)
==
::
++ added
Expand Down Expand Up @@ -374,6 +377,7 @@
del/source
read/read
adjust/adjust
allow-notifications/(su (perk %all %some %none ~))
==
::
++ add
Expand Down
1 change: 1 addition & 0 deletions desk/lib/mark-warmer.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions desk/mar/activity/allowed.hoon
Original file line number Diff line number Diff line change
@@ -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
--
--
5 changes: 5 additions & 0 deletions desk/sur/activity.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -165,6 +169,7 @@
==
+$ unread-point [message-key count=@ud notify=_|]
+$ volume [unreads=? notify=?]
+$ notifications-allowed ?(%all %some %none)
+$ activity-bundle
$: =source
latest=time
Expand Down