Skip to content

Commit

Permalink
Merge pull request #279 from tloncorp/hm/small-reel-fixes
Browse files Browse the repository at this point in the history
reel: fixing meta and url scries, token rotation, and extra metadata
  • Loading branch information
arthyn authored Sep 9, 2024
2 parents 7e109b1 + 1144a16 commit c1751fe
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
47 changes: 33 additions & 14 deletions desk/app/reel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,27 @@
%reel-describe
?> =(our.bowl src.bowl)
=+ !<([id=cord =metadata:reel] vase)
?~ (~(has by stable-id) id) `this
:: the token here is a temporary identifier for the metadata
=/ old-token (~(get by stable-id) id)
=. fields.metadata
%- ~(gas by fields.metadata)
:~ ['bite-type' '2']
['inviter' (scot %p src.bowl)]
['group' id]
==
:: the nonce here is a temporary identifier for the metadata
:: a new one will be assigned by the bait provider and returned to us
=/ new-fields (~(put by fields.metadata) 'bite-type' '2')
=/ new-metadata metadata(fields new-fields)
=/ =nonce:reel (scot %da now.bowl)
=. our-metadata (~(put by our-metadata) nonce new-metadata)
:: delete old metadata if we have an existing token for this id
=? our-metadata ?=(^ old-token)
(~(del by our-metadata) u.old-token)
=. our-metadata (~(put by our-metadata) nonce metadata)
=. open-describes (~(put in open-describes) nonce)
=. stable-id (~(put by stable-id) id nonce)
:_ this
~[[%pass /describe %agent [civ %bait] %poke %bait-describe !>([nonce new-metadata])]]
%+ welp
?~ old-token ~
~[[%pass /undescribe %agent [civ %bait] %poke %bait-undescribe !>(u.old-token)]]
~[[%pass /describe %agent [civ %bait] %poke %bait-describe !>([nonce metadata])]]
::
%reel-confirmation
?> =(civ src.bowl)
Expand Down Expand Up @@ -229,21 +239,30 @@
=/ has (~(has in open-link-requests) [(slav %p ship.pole) name.pole])
``json+!>([%b has])
::
[%x any %metadata token=@ ~]
=/ =metadata:reel (fall (~(get by our-metadata) token.pole) *metadata:reel)
[%x %v1 %metadata ship=@ name=@ ~]
=/ id (rap 3 ship.pole '/' name.pole ~)
=/ token (~(get by stable-id) id)
?~ token [~ ~]
=/ =metadata:reel (fall (~(get by our-metadata) u.token) *metadata:reel)
``reel-metadata+!>(metadata)
::
[%x %v0 %metadata name=@ ~]
:: old style tokens are directly in metadata
=/ id (rap 3 (scot %p our.bowl) '/' name.pole ~)
=/ =metadata:reel (fall (~(get by our-metadata) id) *metadata:reel)
``reel-metadata+!>(metadata)
::
[%x any %token-url token=*]
=/ =token:reel (crip (join '/' token.pole))
=/ =token:reel (crip +:(spud token.pole))
=/ url (url-for-token vic token)
``reel-token-url+!>(url)
``json+!>(s+url)
::
[%x %v1 %id-url id=*]
=/ id (crip (join '/' id.pole))
=/ id (crip +:(spud id.pole))
?~ token=(~(get by stable-id) id)
``reel-token-url+!>('')
=/ url (cat 3 vic id)
``reel-token-url+!>(url)
``json+!>(s+'')
=/ url (cat 3 vic u.token)
``json+!>(s+url)
==
::
++ on-arvo
Expand Down
2 changes: 1 addition & 1 deletion desk/ted/reel/set-ship.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
=/ url
?: =(vic 'https://tlon.network/lure/')
"https://tlon.network/v1/lure/bait/who"
"{(trip vic)}/bait/who"
"{(trip vic)}bait/who"
;< =json bind:m (fetch-json url)
=/ =ship (slav %p (so:dejs:format json))
;< ~ bind:m (poke [our %reel] reel-command+!>([%set-ship ship]))
Expand Down
2 changes: 1 addition & 1 deletion desk/tests/app/reel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
=/ m (mare ,~)
;< * bind:m (do-init dap reel-agent)
;< * bind:m (jab-bowl |=(b=bowl b(our ~dev, src ~dev, now *@da)))
=/ =metadata:r [%test (my ['inviter' '~dev'] ~)]
=/ =metadata:r [%test (my ['inviter' '~dev'] ['group' '~bus/reel-test'] ~)]
=/ describe [token metadata]
;< caz=(list card) bind:m (do-poke %reel-describe !>(describe))
;< bw=bowl bind:m get-bowl
Expand Down

0 comments on commit c1751fe

Please sign in to comment.