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

%contacts activity #4175

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
35 changes: 29 additions & 6 deletions desk/app/activity.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:: - thread
:: - dm
:: - dm-thread
:: - contact
::
:: with this structure that means that data flows upwards from the
:: leaves to the root, and that we can easily keep the read state
Expand All @@ -49,7 +50,7 @@
+$ card card:agent:gall
::
+$ current-state
$: %7
$: %8
allowed=notifications-allowed:a
=indices:a
=activity:a
Expand Down Expand Up @@ -140,22 +141,39 @@
=? cor ?=(%6 -.old)
(emit %pass /adjust-old-default %agent [our.bowl dap.bowl] %poke noun+!>(%adjust-old-default))
=? old ?=(%6 -.old) [%7 +.old]
?> ?=(%7 -.old)
=? old ?=(%7 -.old) [%8 +.old]
?> ?=(%8 -.old)
=. state old
:: insert missing volume defaults to %base
::
=/ base-volume
(~(gut by volume-settings.state) [%base ~] *volume-map:a)
=. volume-settings.state
%+ ~(put by volume-settings.state) [%base ~]
(~(uni by base-volume) *volume-map:a)
=. allowed %all
(emit %pass /fix-init-unreads %agent [our.bowl dap.bowl] %poke noun+!>(%fix-init-unreads))
+$ versioned-state
$% state-7
$% state-8
state-7
state-6
state-5
state-4
state-3
state-2
state-1
==
+$ state-7 current-state
+$ state-8 current-state
+$ state-7
$: %7
allowed=notifications-allowed:v7:old:a
=indices:v7:old:a
=activity:v7:old:a
=volume-settings:v7:old:a
==
+$ state-6 _%*(. *state-7 - %6)
+$ state-5 _%*(. *state-7 - %5)
::
++ state-5-to-6
|= old=state-5
^- state-6
Expand Down Expand Up @@ -572,6 +590,7 @@
(lth latest.src-info start)
?= $? %post %reply %dm-post %dm-reply
%flag-post %flag-reply %group-ask
%contact
==
-<.event
==
Expand Down Expand Up @@ -609,6 +628,7 @@
:- (~(put by sources.acc) source src-info(added &))
?~ top +.acc
[(sub limit.acc 1) (snoc happenings.acc [source time.i.top top]) collapsed]
::
+$ out
$: sources=(map source:a [latest=time-id:a added=?])
limit=@ud
Expand All @@ -628,6 +648,7 @@
?: child.event [~ | acc]
?. ?= $? %post %reply %dm-post %dm-reply
%flag-post %flag-reply %group-ask
%contact
==
-<.event
[~ | acc]
Expand Down Expand Up @@ -771,6 +792,7 @@
=. volume-settings (~(del by volume-settings) source)
:: TODO: send notification removals?
(give-update [%del source] [%hose ~])
::
++ del-event
|= [=source:a event=incoming-event:a]
^+ cor
Expand All @@ -793,13 +815,15 @@
(~(put by out) source (~(got by activity) source))
%- (log |.("sending activity: {<new-activity>}"))
(give-update [%activity new-activity] [%hose ~])
::
++ add-to-index
|= [=source:a =time-id:a =event:a]
^+ cor
=/ =index:a (~(gut by indices) source *index:a)
=/ new=_stream.index
(put:on-event:a stream.index time-id event)
(refresh-index source index(stream new))
::
++ refresh-index
|= [=source:a new=index:a]
%- (log |.("refeshing index: {<source>}"))
Expand Down Expand Up @@ -1180,8 +1204,7 @@
=. importing &
=. indices (~(put by indices) [%base ~] *index:a)
=. cor set-chat-reads
::REVIEW maybe need a scry api version bump here?
=+ .^(=channels:c %gx (scry-path %channels /v2/channels/full/noun))
=+ .^(=channels:c %gx (scry-path %channels /v3/channels/full/noun))
=. cor (set-volumes channels)
=. cor (set-channel-reads channels)
=. cor refresh-all-summaries
Expand Down
3 changes: 3 additions & 0 deletions desk/app/channels.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@
::
[%x %v2 %channels full=?(~ [%full ~])]
``channels-2+!>((uv-channels-2:utils v-channels ?=(^ full.pole)))
::
[%x %v3 %channels full=?(~ [%full ~])]
``channels-3+!>((uv-channels-3:utils v-channels ?=(^ full.pole)))
mikolajpp marked this conversation as resolved.
Show resolved Hide resolved
::
[%x ?(%v0 %v1) %init ~] ``noun+!>([unreads (uv-channels-1:utils v-channels)])
[%x %v2 %init ~] ``noun+!>([unreads (uv-channels-2:utils v-channels |)])
Expand Down
4 changes: 2 additions & 2 deletions desk/app/chat.hoon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/- c=chat, d=channels, g=groups, u=ui, e=epic, old=chat-2, activity
/- meta
/- ha=hark
/- contacts
/- contacts-0
/+ default-agent, verb-lib=verb, dbug, neg=negotiate
/+ pac=dm
/+ utils=channel-utils
Expand Down Expand Up @@ -1750,7 +1750,7 @@
|= =diff:dm:c
=? net.dm &(?=(%inviting net.dm) !from-self) %done
=/ =wire /contacts/(scot %p ship)
=/ =cage [act:mar:contacts !>(`action:contacts`[%heed ~[ship]])]
=/ =cage contact-action+!>(`action-0:contacts-0`[%heed ~[ship]])
=. cor (emit %pass wire %agent [our.bowl %contacts] %poke cage)
=/ old-unread di-unread
=/ had=(unit [=time =writ:c])
Expand Down
10 changes: 5 additions & 5 deletions desk/app/groups.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
:: note: all subscriptions are handled by the subscriber library so
:: we can have resubscribe loop protection.
::
/- g=groups, zero=groups-0, ha=hark, h=heap, d=channels, c=chat, tac=contacts,
activity
/- g=groups, zero=groups-0, ha=hark, h=heap, d=channels, c=chat,
tac=contacts-0, activity
/- meta
/- e=epic
/+ default-agent, verb, dbug
Expand Down Expand Up @@ -758,10 +758,10 @@
cor
::
%fact
=+ !<(=update:tac q.cage.sign)
?~ con.update cor
=+ !<(=update-0:tac q.cage.sign)
?~ con.update-0 cor
%- emil
%+ turn ~(tap in groups.con.update)
%+ turn ~(tap in groups.con.update-0)
|= =flag:g
[%pass /gangs/(scot %p p.flag)/[q.flag]/preview %agent [p.flag dap.bowl] %watch /groups/(scot %p p.flag)/[q.flag]/preview]
==
Expand Down
6 changes: 3 additions & 3 deletions desk/app/profile.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:: other apps can poke this agent with widgets of their own, and the user
:: can choose which widgets to display on their public page.
::
/- contacts
/- contacts-0
/+ dbug, verb, sigil, hutils=http-utils
/= stock-widgets /app/profile/widgets
::
Expand Down Expand Up @@ -175,8 +175,8 @@
::
++ render-page
^- manx
=/ ours=(unit contact:contacts)
(get-contact:contacts bowl our.bowl)
=/ ours=(unit contact-0:contacts-0)
(get-contact:contacts-0 bowl our.bowl)
|^ ;html
;+ head
;+ body
Expand Down
12 changes: 6 additions & 6 deletions desk/app/profile/widgets.hoon
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
:: profile: construct stock widgets
::
/- contacts
/- contacts-0
/+ sigil
::
|= =bowl:gall
=/ ours=(unit contact:contacts)
=, contacts
=/ ours=(unit contact-0:contacts-0)
=, contacts-0
::NOTE we scry for the full rolodex, because we are not guaranteed to
:: have an entry for ourselves, and contacts doesn't expose a "safe"
:: (as in crashless) endpoint for checking
=+ .^ =rolodex
/gx/(scot %p our.bowl)/contacts/(scot %da now.bowl)/all/contact-rolodex
==
=/ =foreign (~(gut by rolodex) our.bowl *foreign)
?: ?=([[@ ^] *] foreign)
`con.for.foreign
=/ =foreign-0 (~(gut by rolodex) our.bowl *foreign-0)
?: ?=([[@ ^] *] foreign-0)
`con.for.foreign-0
~
|^ %- ~(gas by *(map term [%0 @t %marl marl]))
:~ [%profile %0 'Profile Header' %marl profile-widget]
Expand Down
12 changes: 11 additions & 1 deletion desk/lib/activity-json.hoon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/- a=activity, g=groups, c=chat
/+ gj=groups-json, cj=channel-json
/+ gj=groups-json, cj=channel-json, dj=contacts-json-1
=* z ..zuse
|%
++ enjs
Expand Down Expand Up @@ -70,6 +70,9 @@
'/'
(msg-id id.key.s)
==
::
%contact
(cat 3 'contact/' (scot %p who.s))
==
::
++ source
Expand All @@ -79,6 +82,7 @@
%base ~[base/~]
%group ~[group/s/(flag:enjs:gj flag.s)]
%dm ~[dm+(whom whom.s)]
%contact ~[contact+(ship who.s)]
::
%channel
:~ :- %channel
Expand Down Expand Up @@ -242,6 +246,12 @@
ship+(ship ship.e)
roles+a+(turn ~(tap in roles.e) |=(role=sect:g s+role))
==
::
%contact
%- pairs
:~ who+(ship who.e)
update+(contact:enjs:dj [update.e ~ ~])
==
==
::
++ time-event
Expand Down
17 changes: 11 additions & 6 deletions desk/lib/activity.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
=/ parent
?- -.source
%dm [%base ~]
%contact [%base ~]
%group [%base ~]
%channel [%group group.source]
%dm-thread [%dm whom.source]
Expand All @@ -37,7 +38,7 @@
++ get-children :: direct children only
|= [=indices:a =source:a]
^- (list source:a)
?: ?=(?(%thread %dm-thread) -.source) ~
?: ?=(?(%thread %dm-thread %contact) -.source) ~
%+ skim
~(tap in ~(key by indices))
|= src=source:a
Expand All @@ -54,7 +55,8 @@
%~ got by
^~
%- my
:~ [%thread 6]
:~ [%contact 7]
[%thread 6]
[%dm-thread 5]
[%channel 4]
[%group 3]
Expand All @@ -73,6 +75,7 @@
%dm-thread (get-volumes vs %dm whom.source)
%channel (get-volumes vs %group group.source)
%thread (get-volumes vs %channel channel.source group.source)
%contact (get-volumes vs %base ~)
==
::
++ sort-sources
Expand Down Expand Up @@ -140,16 +143,17 @@
%chan-init [%channel channel.event group.event]
%post [%channel channel.event group.event]
%reply [%thread parent.event channel.event group.event]
%dm-invite [%dm whom.event]
%dm-post [%dm whom.event]
%dm-reply [%dm-thread parent.event whom.event]
%dm-invite [%dm whom.event]
%dm-post [%dm whom.event]
%dm-reply [%dm-thread parent.event whom.event]
%group-invite [%group group.event]
%group-kick [%group group.event]
%group-join [%group group.event]
%group-role [%group group.event]
%group-ask [%group group.event]
%flag-post [%group group.event]
%flag-reply [%group group.event]
%contact [%contact who.event]
==
::
++ event-type
Expand All @@ -170,6 +174,7 @@
?+ type |
%post &
%reply &
%contact &
%dm-post &
%dm-reply &
%dm-invite &
Expand Down Expand Up @@ -367,4 +372,4 @@
==
--
--
--
--
Loading