Skip to content

Commit

Permalink
Merge pull request #297 from tloncorp/mp/contacts-activity
Browse files Browse the repository at this point in the history
contacts: implement activity
  • Loading branch information
mikolajpp authored Nov 21, 2024
2 parents 174e24d + 0889599 commit 781d87a
Show file tree
Hide file tree
Showing 4 changed files with 433 additions and 2 deletions.
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
?: =(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
Loading

0 comments on commit 781d87a

Please sign in to comment.