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
...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
...
219
220
221
222
223
224
225
226
227
228
229
|
'follow', 'mute', 'block'
};
credset = lib.set {
'pw', 'otp', 'challenge', 'trust'
};
privset = lib.set {
'post', 'edit', 'acct', 'upload', 'censor', 'admin'
}
}
local str = rawstring --lib.mem.ptr(int8)
struct m.source
struct m.rights {
rank: uint16 -- lower = more powerful except 0 = regular user
-- creating staff automatically assigns rank immediately below you
quota: uint32 -- # of allowed tweets per day; 0 = no limit
-- user powers -- default on
login: bool
visible: bool
post: bool
shout: bool
propagate: bool
upload: bool
acct: bool
edit: bool
-- admin powers -- default off
ban: bool
config: bool
censor: bool
suspend: bool
rebrand: bool -- modify site's brand identity
}
terra m.rights_default()
return m.rights {
rank = 0, quota = 1000;
login = true, visible = true, post = true;
shout = true, propagate = true, upload = true;
ban = false, config = false, censor = false;
suspend = false, rebrand = false;
}
end
struct m.actor {
id: uint64
nym: str
handle: str
origin: uint64
bio: str
rights: m.rights
key: lib.mem.ptr(uint8)
xid: str
source: &m.source
}
struct m.range {
time: bool
union {
from_time: m.timepoint
from_idx: uint64
}
................................................................................
actor_save: {&m.source, m.actor} -> bool
actor_create: {&m.source, m.actor} -> bool
actor_fetch_xid: {&m.source, lib.mem.ptr(int8)} -> lib.mem.ptr(m.actor)
actor_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.actor)
actor_notif_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.notif)
actor_enum: {&m.source} -> lib.mem.ptr(&m.actor)
actor_enum_local: {&m.source} -> lib.mem.ptr(&m.actor)
actor_auth_how: {&m.source, m.inet, rawstring} -> m.credset
-- returns a set of auth method categories that are available for a
-- given user from a certain origin
-- origin: inet
-- handle: rawstring
actor_auth_otp: {&m.source, m.inet, rawstring, rawstring} -> uint64
actor_auth_pw: {&m.source, m.inet, rawstring, rawstring} -> uint64
-- handles password-based logins against hashed passwords
-- origin: inet
-- handle: rawstring
-- token: rawstring
actor_auth_tls: {&m.source, m.inet, rawstring} -> uint64
-- handles implicit authentication performed as part of an TLS connection
-- origin: inet
................................................................................
terra m.source:free()
self.id:free()
self.string:free()
end
m.source.metamethods.__methodmissing = macro(function(meth, obj, ...)
local q = {...}
-- syntax sugar to forward unrecognized calls onto the backend
return `obj.backend.[meth](&obj, [q])
end)
return m
|
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
|
<
<
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<
<
<
>
>
>
<
>
>
>
>
>
>
>
>
|
|
|
|
|
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
...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
...
230
231
232
233
234
235
236
237
238
239
240
|
'follow', 'mute', 'block'
};
credset = lib.set {
'pw', 'otp', 'challenge', 'trust'
};
privset = lib.set {
'post', 'edit', 'acct', 'upload', 'censor', 'admin'
};
powerset = lib.set {
-- user powers -- default on
'login', 'visible', 'post', 'shout',
'propagate', 'upload', 'acct', 'edit';
-- admin powers -- default off
'purge', 'config', 'censor', 'suspend',
'cred', 'elevate', 'demote', 'rebrand' -- modify site's brand identity
}
}
terra m.powerset:affect_users()
return self.purge() or self.censor() or self.suspend() or
self.elevate() or self.demote() or self.rebrand() or
self.cred()
end
local str = rawstring --lib.mem.ptr(int8)
struct m.source
struct m.rights {
rank: uint16 -- lower = more powerful except 0 = regular user
-- creating staff automatically assigns rank immediately below you
quota: uint32 -- # of allowed tweets per day; 0 = no limit
powers: m.powerset
}
terra m.rights_default()
var pow: m.powerset pow:fill()
(pow.purge << false)
(pow.config << false)
(pow.censor << false)
(pow.suspend << false)
(pow.elevate << false)
(pow.demote << false)
(pow.cred << false)
(pow.rebrand << false)
return m.rights { rank = 0, quota = 1000, powers = pow; }
end
struct m.actor {
id: uint64
nym: str
handle: str
origin: uint64
bio: str
avatar: str
knownsince: int64
rights: m.rights
key: lib.mem.ptr(uint8)
-- ephemera
xid: str
source: &m.source
}
struct m.actor_stats {
posts: intptr
follows: intptr
followers: intptr
mutuals: intptr
}
struct m.range {
time: bool
union {
from_time: m.timepoint
from_idx: uint64
}
................................................................................
actor_save: {&m.source, m.actor} -> bool
actor_create: {&m.source, m.actor} -> bool
actor_fetch_xid: {&m.source, lib.mem.ptr(int8)} -> lib.mem.ptr(m.actor)
actor_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.actor)
actor_notif_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.notif)
actor_enum: {&m.source} -> lib.mem.ptr(&m.actor)
actor_enum_local: {&m.source} -> lib.mem.ptr(&m.actor)
actor_stats: {&m.source, uint64} -> m.actor_stats
actor_auth_how: {&m.source, m.inet, rawstring} -> {m.credset, bool}
-- returns a set of auth method categories that are available for a
-- given user from a certain origin
-- origin: inet
-- username: rawstring
actor_auth_otp: {&m.source, m.inet, rawstring, rawstring} -> uint64
actor_auth_pw: {&m.source, m.inet, lib.mem.ptr(int8), lib.mem.ptr(int8) } -> uint64
-- handles password-based logins against hashed passwords
-- origin: inet
-- handle: rawstring
-- token: rawstring
actor_auth_tls: {&m.source, m.inet, rawstring} -> uint64
-- handles implicit authentication performed as part of an TLS connection
-- origin: inet
................................................................................
terra m.source:free()
self.id:free()
self.string:free()
end
m.source.metamethods.__methodmissing = macro(function(meth, obj, ...)
local q = {...}
-- syntax sugar to forward unrecognized calls onto the backend
return quote var r = obj.backend.[meth](&obj, [q]) in r end
end)
return m
|