7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
};
notiftype = lib.enum {
'mention', 'like', 'rt', 'react'
};
relation = lib.enum {
'follow', 'mute', 'block'
};
}
local str = lib.mem.ptr(int8)
str:complete()
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
................................................................................
struct m.actor {
id: uint64
nym: str
handle: str
origin: uint64
bio: str
rights: m.rights
key: str
source: &m.source
}
terra m.actor:free()
self.nym:free()
self.handle:free()
self.bio:free()
self.key:free()
end
struct m.range {
time: bool
union {
from_time: m.timepoint
from_idx: uint64
}
................................................................................
kind: m.notiftype.t
when: uint64
union {
post: uint64
reaction: int8[8]
}
}
-- backends only handle content on the local server
struct m.backend { id: rawstring
open: &m.source -> &opaque
close: &m.source -> {}
conf_get: {&m.source, rawstring} -> lib.mem.ptr(int8)
conf_set: {&m.source, rawstring, rawstring} -> {}
conf_reset: {&m.source, rawstring} -> {}
actor_save: {&m.source, m.actor} -> bool
actor_create: {&m.source, m.actor} -> bool
actor_fetch_xid: {&m.source, rawstring} -> lib.stat(m.actor)
actor_fetch_uid: {&m.source, uint64} -> lib.stat(m.actor)
actor_notif_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.notif)
actor_auth: {&m.source, rawstring, rawstring} -> lib.stat(m.actor)
actor_enum: {&m.source} -> lib.mem.ptr(m.actor)
actor_enum_local: {&m.source} -> lib.mem.ptr(m.actor)
actor_conf_str: cnf(rawstring, lib.mem.ptr(int8))
actor_conf_int: cnf(intptr, lib.stat(intptr))
post_save: {&m.source, &m.post} -> bool
post_create: {&m.source, &m.post} -> bool
actor_post_fetch_uid: {&m.source, uint64, m.range} -> lib.mem.ptr(m.post)
|
>
>
|
|
>
|
<
>
>
|
<
<
<
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
<
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
};
notiftype = lib.enum {
'mention', 'like', 'rt', 'react'
};
relation = lib.enum {
'follow', 'mute', 'block'
};
credset = lib.set {
'pw', 'otp', 'challenge', 'trust'
};
}
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
................................................................................
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
}
................................................................................
kind: m.notiftype.t
when: uint64
union {
post: uint64
reaction: int8[8]
}
}
struct m.inet {
pv: uint8 -- 0 = null, 4 = ipv4, 6 = ipv6
union {
v4: uint8[4]
v6: uint8[16]
}
union {
fixbits: uint8 -- for cidr
port: uint16 -- for origin
}
}
terra m.inet:cidr_str()
if self.pv == 4 then
var maxsz = 3*4 + 3 + 1
elseif self.pv == 6 then
var bits = 128
var bytes = bits / 8
var hexchs = bytes * 2
var segs = hexchs / 4
var seps = segs - 1
var maxsz = hexchs + seps + 1
else return nil end
end
struct m.auth {
aid: uint64
uid: uint64
aname: str
netmask: m.inet
restrict: lib.mem.ptr(rawstring)
blacklist: bool
}
-- backends only handle content on the local server
struct m.backend { id: rawstring
open: &m.source -> &opaque
close: &m.source -> {}
conf_get: {&m.source, rawstring} -> lib.mem.ptr(int8)
conf_set: {&m.source, rawstring, rawstring} -> {}
conf_reset: {&m.source, rawstring} -> {}
actor_save: {&m.source, m.actor} -> bool
actor_create: {&m.source, m.actor} -> bool
actor_fetch_xid: {&m.source, rawstring} -> 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
-- fingerprint: rawstring
actor_auth_api: {&m.source, m.inet, rawstring, rawstring} -> uint64
-- handles API authentication
-- origin: inet
-- handle: rawstring
-- key: rawstring (X-API-Key)
actor_auth_record_fetch: {&m.source, uint64} -> lib.mem.ptr(m.auth)
actor_conf_str: cnf(rawstring, lib.mem.ptr(int8))
actor_conf_int: cnf(intptr, lib.stat(intptr))
post_save: {&m.source, &m.post} -> bool
post_create: {&m.source, &m.post} -> bool
actor_post_fetch_uid: {&m.source, uint64, m.range} -> lib.mem.ptr(m.post)
|