Skip to content

Commit

Permalink
Merge pull request #281 from tloncorp/promote-9-11
Browse files Browse the repository at this point in the history
ops: promote 1.26
  • Loading branch information
arthyn authored Sep 11, 2024
2 parents bb25141 + 404c038 commit 1e8a1fe
Show file tree
Hide file tree
Showing 9 changed files with 955 additions and 75 deletions.
117 changes: 89 additions & 28 deletions desk/app/bait.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
+$ versioned-state
$% state-0
state-1
state-2
==
::
+$ state-0
Expand All @@ -15,6 +16,10 @@
$: %1
token-metadata=(map [inviter=ship token=cord] metadata:reel)
==
+$ state-2
$: %2
token-metadata=(map token:reel metadata:reel)
==
--
::
|%
Expand Down Expand Up @@ -53,7 +58,7 @@
==
--
::
=| state-1
=| state-2
=* state -
::
%- agent:dbug
Expand All @@ -72,10 +77,22 @@
^- (quip card _this)
=/ old !<(versioned-state old-state)
?- -.old
%1
%2
`this(state old)
::
%1
=/ new-metadata
%- ~(gas by *(map token:reel metadata:reel))
%+ turn
~(tap by token-metadata.old)
|= [[inviter=ship =token:reel] meta=metadata:reel]
=/ new-token
(rap 3 (scot %p inviter) '/' token ~)
[new-token meta]
`this(state [%2 new-metadata])
::
%0
`this(state *state-1)
`this(state *state-2)
==
::
++ on-poke
Expand All @@ -88,53 +105,97 @@
:_ this
=/ full-line=request-line:server (parse-request-line:server url.request)
=/ line
?: ?=([%lure @ @ *] site.full-line)
?: ?=([%lure @ *] site.full-line)
t.site.full-line
?: ?=([@ @ *] site.full-line)
site.full-line
!!
?+ method.request (give not-found:gen:server)
%'GET'
?: ?=([%bait %who ~] line)
(give (json-response:gen:server s+(scot %p our.bowl)))
=/ inviter (slav %p i.line)
=/ token i.t.line
=/ =metadata:reel (fall (~(get by token-metadata) [inviter token]) *metadata:reel)
?: ?=([@ @ %metadata ~] line)
(give (json-response:gen:server (enjs-metadata metadata)))
(give (manx-response:gen:server (landing-page metadata)))
%'GET' (get-request line)
::
%'POST'
=/ inviter (slav %p i.line)
=/ token i.t.line
?~ body.request
(give not-found:gen:server)
(give-not-found 'body not found')
?. =('ship=%7E' (end [3 8] q.u.body.request))
(give not-found:gen:server)
(give-not-found 'ship not found in body')
=/ joiner (slav %p (cat 3 '~' (rsh [3 8] q.u.body.request)))
:* :* %pass /bite %agent [inviter %reel]
%poke %reel-bite !>([%bite-1 token joiner inviter])
==
:* %pass /bite %agent [our.bowl %reel]
%poke %reel-bite !>([%bite-1 token joiner inviter])
==
(give (manx-response:gen:server (sent-page joiner)))
==
=; [=bite:reel inviter=(unit ship)]
?~ inviter
(give-not-found 'inviter not found')
^- (list card)
:: TODO: figure out if we need to send both pokes
:* :* %pass /bite %agent [u.inviter %reel]
%poke %reel-bite !>(bite)
==
:* %pass /bite %agent [our.bowl %reel]
%poke %reel-bite !>(bite)
==
(give (manx-response:gen:server (sent-page joiner)))
==
=/ =(pole knot) line
?: ?=([@ @ ~] line)
=/ inviter (slav %p i.line)
=/ old-token i.t.line
:_ `inviter
[%bite-1 old-token joiner inviter]
=/ token
?~ ext.full-line i.line
(crip "{(trip i.line)}.{(trip u.ext.full-line)}")
=/ =metadata:reel (~(gut by token-metadata) token *metadata:reel)
?~ type=(~(get by fields.metadata) 'bite-type')
~|("no bite type for token: {<token>}" !!)
?> =('2' u.type)
:- [%bite-2 token joiner metadata]
?~ inviter-field=(~(get by fields.metadata) 'inviter') ~
`(slav %p u.inviter-field)
==
++ get-request
|= =(pole knot)
^- (list card)
?+ pole (give not-found:gen:server)
[%bait %who ~]
(give (json-response:gen:server s+(scot %p our.bowl)))
::
[ship=@ name=@ %metadata ~]
=/ token (crip "{(trip ship.pole)}/{(trip name.pole)}")
=/ =metadata:reel
(~(gut by token-metadata) token *metadata:reel)
(give (json-response:gen:server (enjs-metadata metadata)))
::
[token=@ %metadata ~]
=/ =metadata:reel
(~(gut by token-metadata) token.pole *metadata:reel)
(give (json-response:gen:server (enjs-metadata metadata)))
::
[token=* ~]
=/ token (crip (join '/' pole))
=/ =metadata:reel
(~(gut by token-metadata) token *metadata:reel)
(give (manx-response:gen:server (landing-page metadata)))
==
::
++ give-not-found
|= body=cord
(give [[404 ~] `(as-octs:mimes:html body)])
++ give
|= =simple-payload:http
(give-simple-payload:app:server id simple-payload)
--
%bait-describe
=+ !<([token=cord =metadata:reel] vase)
`this(token-metadata (~(put by token-metadata) [src.bowl token] metadata))
=+ !<([=nonce:reel =metadata:reel] vase)
=/ =token:reel (scot %uv (end [3 16] eny.bowl))
:_ this(token-metadata (~(put by token-metadata) token metadata))
=/ =cage reel-confirmation+!>([nonce token])
~[[%pass /confirm/[nonce] %agent [src.bowl %reel] %poke cage]]
::
%bait-undescribe
=+ !<(token=cord vase)
`this(token-metadata (~(del by token-metadata) [src.bowl token]))
`this(token-metadata (~(del by token-metadata) token))
::
%bind-slash
:_ this
~[[%pass /eyre/connect %arvo %e %connect [~ /] dap.bowl]]
::
%unbind-slash
:_ this
~[[%pass /eyre/connect %arvo %e %connect [~ /] %docket]]
Expand Down
Loading

0 comments on commit 1e8a1fe

Please sign in to comment.