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: implement activity #297

Merged
merged 2 commits into from
Nov 21, 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
42 changes: 40 additions & 2 deletions desk/app/contacts.hoon
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/- activity
/+ default-agent, dbug, verb, neg=negotiate
/+ *contacts
::
Expand Down Expand Up @@ -100,6 +101,12 @@
::
+| %operations
::
++ pass-activity
|= [who=ship field=(pair @tas value)]
^- card
=/ =cage activity-action+!>(`action:activity`[%add %contact who field])
[%pass /activity %agent [our.bowl %activity] %poke cage]
::
:: +pub: publication management
::
:: - /v1/news: local updates to our profile and rolodex
Expand Down Expand Up @@ -344,15 +351,43 @@
cor =. cor
(p-news-0:pub who (contact:to-0 con.u))
=/ page=(unit page) (~(get by book) who)
:: update peer contact page
:: update contact book and send notification
::
=? cor ?=(^ page)
?: =(con.u.page con.u) cor
=. book (~(put by book) who u.page(con con.u))
=. cor (emil (send-activity u con.u.page))
(p-response:pub %page who con.u mod.u.page)
(p-response:pub %peer who con.u)
==
::
++ send-activity
|= [u=update con=contact]
^- (list card)
?. .^(? %gu /(scot %p our.bowl)/activity/(scot %da now.bowl)/$)
~
%- ~(rep by con.u)
|= [field=(pair @tas value) cards=(list card)]
?> ?=(^ q.field)
:: do not broadcast empty changes
::
?: (is-value-empty q.field)
cards
::
=/ val=(unit value) (~(get by con) p.field)
?~ val
[(pass-activity who field) cards]
?< ?=(~ u.val)
::NOTE currently shouldn't happen in practice
?. =(-.q.field -.u.val) cards
Fang- marked this conversation as resolved.
Show resolved Hide resolved
?: =(p.q.field p.u.val) cards
?. ?=(%set -.q.field)
[(pass-activity who field) cards]
=/ diff=(set value)
(~(dif in p.q.field) ?>(?=(%set -.u.val) p.u.val))
?~ diff cards
[(pass-activity who p.field set+diff) cards]
::
++ si-meet
^+ si-cor
::
Expand Down Expand Up @@ -735,7 +770,7 @@
++ agent
|= [=wire =sign:agent:gall]
^+ cor
?+ wire ~|(evil-agent+wire !!)
?+ wire ~|(evil-agent+wire !!)
[%contact ~]
si-abet:(si-take:(sub src.bowl) wire sign)
::
Expand All @@ -744,6 +779,9 @@
?~ p.sign cor
%- (slog leaf/"{<wire>} failed" u.p.sign)
cor
::
[%activity ~]
cor
::
[%epic ~]
cor
Expand Down
10 changes: 10 additions & 0 deletions desk/lib/contacts.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
|%
::
+| %contact
:: +is-value-empty: is value considered empty
::
++ is-value-empty
|= val=value
^- ?
?+ -.val |
%text =('' p.val)
%look =('' p.val)
%set ?=(~ p.val)
==
:: +cy: contact map engine
::
++ cy
Expand Down
3 changes: 1 addition & 2 deletions desk/lib/contacts/json-1.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@
++ value
^- $-(json value:c)
|= jon=json
:: XX is there a way to do it in one go?
::
?~ jon ~
=/ [type=@tas val=json]
%. jon
(ot type+(se %tas) value+json ~)
Expand Down
Loading
Loading