blob: 833c07d96400d7370ee5ae562b5eb3a725c8ecd8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/- sur=nostrill, nsur=nostr, comms=nostrill-comms, feed=trill-feed
/+ js=json-nostr, sr=sortug, nlib=nostr, constants, gatelib=trill-gate, feedlib=trill-feed, jsonlib=json-nostrill
|_ [=state:sur =bowl:gall]
++ cast-poke
|= raw=* ^- poke:comms
;; poke:comms raw
:: Req
++ handle-req |= =req:comms
?- -.req
%feed handle-feed
%thread (handle-thread +.req)
%prof handle-prof
==
++ handle-feed
=/ can (can-access:gatelib src.bowl lock.feed-perms.state bowl)
?. can
:: TODO keep track of the requests at the feed-perms struct
=/ crd (res-poke [%ng 'not allowed'])
:_ state :~(crd)
::
=/ lp latest-page:feedlib
=/ lp2 lp(count backlog.feed-perms.state)
=/ =fc:feed (lp2 feed.state)
=/ crd (res-poke [%ok %feed fc])
:_ state :~(crd)
++ give-feed
~& give-feed=src.bowl
=/ can (can-access:gatelib src.bowl lock.feed-perms.state bowl)
?. can
:: TODO keep track of the requests at the feed-perms struct
(res-fact [%ng 'not allowed'])
::
=/ lp latest-page:feedlib
=/ lp2 lp(count backlog.feed-perms.state)
=/ =fc:feed (lp2 feed.state)
(res-fact [%ok %feed fc])
++ give-ted |= id=@
=/ ted (get:orm:feed feed.state id)
?~ ted
(res-fact [%ng 'no such thread'])
=/ can (can-access:gatelib src.bowl read.u.ted bowl)
?. can
(res-fact [%ng 'not allowed'])
::
=/ fn (node-to-full:feedlib u.ted feed.state)
(res-fact [%ok %thread fn])
::
++ handle-prof
=/ can (can-access:gatelib src.bowl lock.feed-perms.state bowl)
?. can
:: TODO keep track of the requests at the feed-perms struct
=/ crd (res-poke [%ng 'not allowed'])
:_ state :~(crd)
::
:: TODO @p or keys... wat do
:: =/ up (~(get by profiles.state) our.bowl)
=/ up (~(get by profiles.state) pub.i.keys.state)
?~ up
=/ crd (res-poke [%ng 'dont have one'])
:_ state :~(crd)
=/ crd (res-poke [%ok %prof u.up])
:_ state :~(crd)
++ handle-thread |= id=@da
=/ ted (get:orm:feed feed.state id)
?~ ted
=/ crd (res-poke [%ng 'no such thread'])
:_ state :~(crd)
=/ can (can-access:gatelib src.bowl read.u.ted bowl)
?. can
=/ crd (res-poke [%ng 'not allowed'])
:_ state :~(crd)
::
=/ fn (node-to-full:feedlib u.ted feed.state)
=/ crd (res-poke [%ok %thread fn])
:_ state :~(crd)
:: res
++ handle-res |= =res:comms
`state
::
++ res-poke |= =res:comms ^- card:agent:gall
=/ =poke:comms [%res res]
=/ cage [%noun !>(poke)]
[%pass /poke %agent [src.bowl dap.bowl] %poke cage]
++ res-fact |= =res:comms ^- (list card:agent:gall)
=/ paths ~[/beg/feed]
=/ =poke:comms [%res res]
~& > giving-res-fact=res
=/ jon (beg-res:en:jsonlib res)
=/ cage [%json !>(jon)]
:~
[%give %fact paths cage]
[%give %kick paths ~]
==
--
|