Skip to content
Open
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
23 changes: 13 additions & 10 deletions desk/app/contacts.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@
?- -.act
%anon p-anon:pub
%self (p-self:pub p.act)
:: if we add a page for someone who is not a peer,
:: when we add a page for someone who is not a peer,
:: we meet them first
::
%page =? cor &(?=(ship p.act) !(~(has by peers) p.act))
Expand All @@ -616,23 +616,22 @@
%snub (s-many:sub p.act |=(s=_s-impl:sub si-snub:s))
==
==
:: +peek: scry
::
:: v0 scries
:: +peek: handle scry
::
:: /x/all -> $rolodex:c0
:: /x/contact/her=@ -> $@(~ contact-0:c0)
::
:: v1 scries
::
:: /x/v1/self -> $contact
::
:: /x/v1/book -> $book
:: /x/v1/book/her=@p -> $page
:: /x/v1/book/id/cid=@uv -> $page
:: /x/v1/all -> $directory
::
:: /x/v1/contact/her=@p -> $contact
:: /x/v1/peer/her=@p -> $contact
::
:: /x/v1/directory -> $directory
::
++ peek
|= pat=(pole knot)
^- (unit (unit cage))
Expand Down Expand Up @@ -695,7 +694,7 @@
(~(get by book) id+u.id)
``contact-page-0+!>(`^page`(fall page *^page))
::
[%x %v1 %all ~]
[%x %v1 %directory ~]
=| dir=directory
:: export all ship contacts
::
Expand All @@ -704,15 +703,19 @@
|= [[=kip =page] =_dir]
?^ kip
dir
(~(put by dir) kip (contact-uni page))
(~(put by dir) kip page)
:: export all peers
::
=. dir
%- ~(rep by peers)
|= [[who=ship far=foreign] =_dir]
?~ for.far dir
?: (~(has by dir) who) dir
(~(put by dir) who con.for.far)
(~(put by dir) who con.for.far ~)
:: export self
::
=. dir
(~(put by dir) our.bowl con.rof ~)
``contact-directory-0+!>(dir)
::
[%u %v1 %contact her=@p ~]
Expand Down
10 changes: 5 additions & 5 deletions desk/lib/contacts/json-1.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
=| kob=(map @ta json)
:- %o
%- ~(rep by book)
|= [[=kip:c =page:c] acc=_kob]
|= [[=kip:c =page:c] =_kob]
?^ kip
(~(put by acc) (scot %uv +.kip) (^page page))
(~(put by acc) (scot %p kip) (^page page))
(~(put by kob) (scot %uv +.kip) (^page page))
(~(put by kob) (scot %p kip) (^page page))
::
++ directory
|= =directory:c
^- json
=| dir=(map @ta json)
:- %o
%- ~(rep by directory)
|= [[who=@p con=contact:c] acc=_dir]
(~(put by acc) (scot %p who) (contact con))
|= [[who=@p =page:c] =_dir]
(~(put by dir) (scot %p who) (^page page))
::
++ response
|= n=response:c
Expand Down
4 changes: 2 additions & 2 deletions desk/sur/contacts.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
:: $book: contact book
::
+$ book (map kip page)
:: $directory: merged contacts
:: $directory: all known contacts
::
+$ directory (map ship contact)
+$ directory (map ship page)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about the name but I think we'll need something like this, because when the client parses the API response it won't know the difference between a peer or a contact that has no modifications.

Suggested change
+$ directory (map ship page)
+$ directory (map ship marked-page)
+$ marked-page [contact=? page]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the client already uses the /v1/book scry to grab contact list, and /v1/directory is not meant as a replacement? Querying the book to tell that difference would be easy, but perhaps there is some context I miss here.

Copy link
Member

@latter-bolden latter-bolden Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do use /v1/book right now to grab contacts. You're correct that that we could use that list to take these /v1/directory results and subtract the people from /v1/book to get the correct "complete set". We could do something similar with the existing /v1/all scry, so this wouldn't really unlock any benefit.

My understanding was the intention of /v1/directory was to serve as a single scry we could use to get all data we need — contacts and non-contacts (would replace /v1/book).

The issue with the current implementation is there's no way to distinguish between non-contact peers and contacts who have no overrides set. Both will serialize identically. That difference is meaningful and needs to be reflected somehow in the data.

:: $peers: network peers
::
+$ peers (map ship foreign)
Expand Down
Loading