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
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
...
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
|
-- note that valid ids should always > 0, as 0 is reserved for null
-- on the client side, vastly simplifying code
drop table if exists parsav_servers cascade;
create table parsav_servers (
id bigint primary key default (1+random()*(2^63-1))::bigint,
domain text not null,
key bytea,
parsav boolean -- whether to use parsav protocol extensions
);
drop table if exists parsav_actors cascade;
create table parsav_actors (
id bigint primary key default (1+random()*(2^63-1))::bigint,
nym text,
handle text not null, -- nym [@handle@origin]
origin bigint references parsav_servers(id)
on delete cascade, -- null origin = local actor
bio text,
avataruri text, -- null if local
rank smallint not null default 0,
quota integer not null default 1000,
key bytea, -- private if localactor; public if remote
title text
unique (handle,origin)
);
drop table if exists parsav_rights cascade;
create table parsav_rights (
key text,
................................................................................
author bigint references parsav_actors(id)
on delete cascade,
subject text,
acl text not null default 'all', -- just store the script raw 🤷
body text,
posted timestamp not null,
discovered timestamp not null,
scope smallint not null,
convo bigint,
parent bigint,
circles bigint[],
mentions bigint[]
);
drop table if exists parsav_conversations cascade;
create table parsav_conversations (
id bigint primary key default (1+random()*(2^63-1))::bigint,
uri text not null,
discovered timestamp not null,
head bigint references parsav_posts(id)
);
drop table if exists parsav_rels cascade;
create table parsav_rels (
relator bigint references parsav_actors(id)
on delete cascade, -- e.g. follower
relatee bigint references parsav_actors(id)
on delete cascade, -- e.g. followed
................................................................................
);
drop table if exists parsav_circles cascade;
create table parsav_circles (
id bigint primary key default (1+random()*(2^63-1))::bigint,
owner bigint not null references parsav_actors(id),
name text not null,
members bigint[] not null default array[],
unique (owner,name)
);
drop table if exists parsav_rooms cascade;
create table parsav_rooms (
id bigint primary key default (1+random()*(2^63-1))::bigint,
................................................................................
drop table if exists parsav_room_members cascade;
create table parsav_room_members (
room bigint references parsav_rooms(id),
member bigint references parsav_actors(id),
rank smallint not null default 0,
admin boolean not null default false, -- non-admins with rank can only moderate + invite
title text -- admin-granted title like reddit flair
);
drop table if exists parsav_invites cascade;
create table parsav_invites (
id bigint primary key default (1+random()*(2^63-1))::bigint,
-- when a user is created from an invite, the invite is deleted and the invite
-- ID becomes the user ID. privileges granted on the invite ID during the invite
-- process are thus inherited by the user
handle text, -- admin can lock invite to specific handle
rank smallint not null default 0,
quota integer not null default 1000
};
drop table if exists parsav_interventions cascade;
create table parsav_interventions (
id bigint primary key default (1+random()*(2^63-1))::bigint,
issuer bigint references parsav_actors(id) not null,
scope bigint, -- can be null or room for local actions
nature smallint not null, -- silence, suspend, disemvowel, etc
victim bigint not null, -- could potentially target group as well
expire timestamp -- auto-expires if set
);
end;
|
>
>
|
<
<
|
|
|
>
>
>
>
>
<
<
<
<
<
<
|
|
>
>
|
|
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
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
...
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
|
-- note that valid ids should always > 0, as 0 is reserved for null
-- on the client side, vastly simplifying code
drop table if exists parsav_servers cascade;
create table parsav_servers (
id bigint primary key default (1+random()*(2^63-1))::bigint,
domain text not null,
key bytea,
knownsince timestamp,
parsav boolean -- whether to use parsav protocol extensions
);
drop table if exists parsav_actors cascade;
create table parsav_actors (
id bigint primary key default (1+random()*(2^63-1))::bigint,
nym text,
handle text not null, -- nym [@handle@origin]
origin bigint references parsav_servers(id)
on delete cascade, -- null origin = local actor
knownsince timestamp,
bio text,
avataruri text, -- null if local
rank smallint not null default 0,
quota integer not null default 1000,
key bytea, -- private if localactor; public if remote
title text,
unique (handle,origin)
);
drop table if exists parsav_rights cascade;
create table parsav_rights (
key text,
................................................................................
author bigint references parsav_actors(id)
on delete cascade,
subject text,
acl text not null default 'all', -- just store the script raw 🤷
body text,
posted timestamp not null,
discovered timestamp not null,
parent bigint not null default 0,
circles bigint[], -- TODO at edit or creation, iterate through each circle
mentions bigint[], -- a user has, check if it can see her post, and if so add
convoheaduri text
-- only used for tracking foreign conversations and tying them to post heads;
-- local conversations are tracked directly and mapped to URIs based on the
-- head's ID. null if native tweet or not the first tweet in convo
);
drop table if exists parsav_conversations cascade;
drop table if exists parsav_rels cascade;
create table parsav_rels (
relator bigint references parsav_actors(id)
on delete cascade, -- e.g. follower
relatee bigint references parsav_actors(id)
on delete cascade, -- e.g. followed
................................................................................
);
drop table if exists parsav_circles cascade;
create table parsav_circles (
id bigint primary key default (1+random()*(2^63-1))::bigint,
owner bigint not null references parsav_actors(id),
name text not null,
members bigint[] not null default array[]::bigint[],
unique (owner,name)
);
drop table if exists parsav_rooms cascade;
create table parsav_rooms (
id bigint primary key default (1+random()*(2^63-1))::bigint,
................................................................................
drop table if exists parsav_room_members cascade;
create table parsav_room_members (
room bigint references parsav_rooms(id),
member bigint references parsav_actors(id),
rank smallint not null default 0,
admin boolean not null default false, -- non-admins with rank can only moderate + invite
title text, -- admin-granted title like reddit flair
vouchedby bigint references parsav_actors(id)
);
drop table if exists parsav_invites cascade;
create table parsav_invites (
id bigint primary key default (1+random()*(2^63-1))::bigint,
-- when a user is created from an invite, the invite is deleted and the invite
-- ID becomes the user ID. privileges granted on the invite ID during the invite
-- process are thus inherited by the user
issuer bigint references parsav_actors(id),
handle text, -- admin can lock invite to specific handle
rank smallint not null default 0,
quota integer not null default 1000
);
drop table if exists parsav_interventions cascade;
create table parsav_interventions (
id bigint primary key default (1+random()*(2^63-1))::bigint,
issuer bigint references parsav_actors(id) not null,
scope bigint, -- can be null or room for local actions
nature smallint not null, -- silence, suspend, disemvowel, etc
victim bigint not null, -- could potentially target group as well
expire timestamp -- auto-expires if set
);
end;
|