interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / social / 60json.om

223 lines · 3893 bytes Raw Blame History
1note social/60json.om: the machine form (JSON, docs/API.md) of the public social pages:
2note forge/stargazers/1, forge/watchers/1, forge/user/1 (account profiles, every tab) and forge/stars/1
3note (the signed-in user's own lists). Same facts as the HTML handler in 55pages.om, same order, same
4note validation before; never a session, key, IP or CSRF token. Strings go through fjtb/fjtc/fjstr.
5note sojid: string id s from offset a as a JSON string
6fn sojid s ulong a ulong to void
7fjtb
8o = get gsso s
9l = get gssl s
10if lt a l
11for i ulong sub l a bound 4096
12fjtc get gsstr add add o a i
13end
14end
15fjstr
16end
17note sojsegb d: append the account's URL segment (display name, else z... key) to fjt (as sonmout)
18fn sojsegb d ulong to void
19s = get gsnm d
20a = ulong 0
21if eq s 0
22s = d
23a = len tsdidp
24end
25o = get gsso s
26l = get gssl s
27if ge a l
28ret
29end
30for i ulong sub l a bound 4096
31fjtc get gsstr add add o a i
32end
33end
34fn sojseg d ulong to void
35fjtb
36sojsegb d
37fjstr
38end
39note sojpath d: "<base><segment>", the href of the account's profile (souser, sonmout)
40fn sojpath d ulong to void
41fjtb
42for i ulong get fbasel 0 bound 64
43fjtc get fbase i
44end
45sojsegb d
46fjstr
47end
48fn sojq t view uchar * to void
49fputc 34
50fput t
51fputc 34
52end
53note sojuhd t d: {"schema":"<t>","base":"<base>","user":"<segment of d>"
54fn sojuhd t view uchar * d ulong to void
55fjstart
56fput tsjh1
57fput t
58fput tsjh2
59fputb
60fput tsjh3
61sojseg d
62end
63note sojuser d: {"name":"<segment>","path":"<base><segment>"}
64fn sojuser d ulong to void
65fputc 123
66fyk0 tsjname
67sojseg d
68fyk tsjpath
69sojpath d
70fputc 125
71end
72note sojusers: the JSON array of sousers (same table walk, same order)
73fn sojusers kind ulong x ulong side ulong to void
74fputc 91
75c = ulong 0
76for s ulong 262144
77k = get gsrk s
78if and ne k 0 ne get gsrv s 0
79if eq shr k 48 kind
80a = and shr k 24 16777215
81b = and k 16777215
82d = b
83y = a
84if eq side 1
85d = a
86y = b
87end
88if eq y x
89if gt c 0
90fputc 44
91end
92c = add c 1
93sojuser d
94end
95end
96end
97end
98fputc 93
99end
100note sojrepo i t: {"name":..,"rid":"rad:..","path":"<base><owner>/<name>","stars":n} (sorepoli)
101fn sojrepo i ulong t ulong to void
102fput tsjr1
103fjtname i
104fjstr
105fput tsjr2
106fputid i
107fput tsjr3
108fjpath i
109fput tsjr4
110fnum get gscst t
111fputc 125
112end
113note sojrepos: the JSON array of sorepol (same walk of the allow-list, same order)
114fn sojrepos kind ulong a ulong to void
115fputc 91
116c = ulong 0
117for i ulong get fan 0 bound 4096
118t = sorepoid i
119if and ne t 0 soron kind a t
120if gt c 0
121fputc 44
122end
123c = add c 1
124sojrepo i t
125end
126end
127fputc 93
128end
129note sojstars: the repos the user in fown starred, as a JSON array (sostarsof; the server's owner profile)
130fn sojstars to void
131d = soownid
132if eq d 0
133fputc 91
134fputc 93
135ret
136end
137sojrepos 1 d
138end
139note sojlist: /<o>/<r>/stargazers (kind 1) and /watchers (kind 3) of repo id t (sorlist)
140fn sojlist kind ulong t ulong to long
141if eq kind 1
142fyrhead tsjsg
143else
144fyrhead tsjwr
145end
146fyk tsjcnt
147if eq kind 1
148fnum get gscst t
149else
150fnum get gscwt t
151end
152fyk tsjusrs
153if eq t 0
154fputc 91
155fputc 93
156else
157sojusers kind t 1
158end
159fyend
160ret 200
161end
162note sojprof: forge/user/1 of account d (soprof); tab as soprof: 4 followers, 5 following, else stars
163fn sojprof d ulong tab ulong to long
164sojuhd tsjuser d
165fyk tsjdid
166sojid d 0
167fyk tsqfls
168fnum get gscfl d
169fyk tsqflg
170fnum get gscfg d
171fyk tsqtab
172if eq tab 4
173sojq tsqfls
174end
175if eq tab 5
176sojq tsqflg
177end
178if and ne tab 4 ne tab 5
179sojq tsqstar
180end
181fyk tsjrepos
182fynull
183fyk tsjsrcv
184fynull
185fyk tsjfrcv
186fynull
187fyk tsjstrd
188if and ne tab 4 ne tab 5
189sojrepos 1 d
190else
191fynull
192end
193fyk tsjusrs
194if eq tab 4
195sojusers 4 d 1
196end
197if eq tab 5
198sojusers 4 d 0
199end
200if and ne tab 4 ne tab 5
201fynull
202end
203fyend
204ret 200
205end
206note sojstarp: forge/stars/1 of the signed-in account u, list kind 1 stars, 2 favorites, 3 watching
207fn sojstarp u ulong kind ulong to long
208sojuhd tsjstar u
209fyk tsqtab
210if eq kind 1
211sojq tsqstar
212end
213if eq kind 2
214sojq tsqfav
215end
216if eq kind 3
217sojq tsqwat
218end
219fyk tsjrepos
220sojrepos kind u
221fyend
222ret 200
223end