119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
502
503
504
505
506
507
508
509
510
511
512
513
514
515
...
946
947
948
949
950
951
952
953
954
955
956
957
958
959
....
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
....
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
|
actor_enum_local = {
params = {}, sql = [[
select id, nym, handle, origin, bio,
null::text, rank, quota, key, epithet,
knownsince::bigint,
'@' || handle,
invites
from parsav_actors where origin is null
order by nullif(rank,0) nulls last, handle
]];
};
actor_enum = {
params = {}, sql = [[
................................................................................
};
artifact_disclaim = {
params = {uint64, uint64}, cmd = true, sql = [[
delete from parsav_artifact_claims where
uid = $1::bigint and
rid = $2::bigint
]];
};
artifact_excise_forget = {
-- delete the blasted thing and pretend it never existed
params = {uint64}, cmd=true, sql = [[
delete from parsav_artifacts where id = $1::bigint
]];
};
................................................................................
}) ]
a.ptr.id = r:int(uint64, row, 0);
a.ptr.rights = lib.store.rights_default();
a.ptr.rights.rank = r:int(uint16, row, 6);
a.ptr.rights.quota = r:int(uint32, row, 7);
a.ptr.rights.invites = r:int(uint32, row, 12);
a.ptr.knownsince = r:int(int64,row, 10);
if r:null(row,8) then
a.ptr.key.ct = 0 a.ptr.key.ptr = nil
else
a.ptr.key = r:bin(row,8)
end
a.ptr.origin = origin
if avia.buf ~= nil then avia:free() end
................................................................................
var r = queries.auth_enum_uid.exec(src,uid)
if r.sz == 0 then return [lib.mem.ptr(lib.mem.ptr(lib.store.auth))].null() end
var ret = lib.mem.heapa([lib.mem.ptr(lib.store.auth)], r.sz)
for i=0, r.sz do
var kind = r:_string(i, 1)
var comment = r:_string(i, 2)
var a = [ lib.str.encapsulate(lib.store.auth, {
kind = {`kind.ptr, `kind.ct};
comment = {`comment.ptr, `comment.ct};
}) ]
a.ptr.aid = r:int(uint64, i, 0)
a.ptr.netmask = r:cidr(i, 3)
a.ptr.blacklist = r:bool(i, 4)
ret.ptr[i] = a
end
return ret
end];
auth_attach_pw = [terra(
................................................................................
uid: uint64,
artifact: uint64,
desc: pstring,
folder: pstring
): {}
queries.artifact_expropriate.exec(src,uid,artifact,desc,folder, lib.osclock.time(nil))
end];
artifact_enum_uid = [terra(
src: &lib.store.source,
uid: uint64,
folder: pstring
)
var res = queries.artifact_enum_uid.exec(src,uid,folder)
|
|
>
>
>
>
>
>
>
>
|
|
>
>
|
>
>
>
>
>
>
>
>
>
>
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
...
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
....
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
....
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
|
actor_enum_local = {
params = {}, sql = [[
select id, nym, handle, origin, bio,
null::text, rank, quota, key, epithet,
knownsince::bigint,
'@' || handle,
invites, avatarid
from parsav_actors where origin is null
order by nullif(rank,0) nulls last, handle
]];
};
actor_enum = {
params = {}, sql = [[
................................................................................
};
artifact_disclaim = {
params = {uint64, uint64}, cmd = true, sql = [[
delete from parsav_artifact_claims where
uid = $1::bigint and
rid = $2::bigint
]];
};
artifact_collect_garbage = {
params = {}, cmd = true, sql = [[
delete from parsav_artifacts where
id not in (select rid from parsav_artifact_claims) and
content is not null -- avoid stepping on toes of ban mech
]];
};
artifact_excise_forget = {
-- delete the blasted thing and pretend it never existed
params = {uint64}, cmd=true, sql = [[
delete from parsav_artifacts where id = $1::bigint
]];
};
................................................................................
}) ]
a.ptr.id = r:int(uint64, row, 0);
a.ptr.rights = lib.store.rights_default();
a.ptr.rights.rank = r:int(uint16, row, 6);
a.ptr.rights.quota = r:int(uint32, row, 7);
a.ptr.rights.invites = r:int(uint32, row, 12);
a.ptr.knownsince = r:int(int64,row, 10);
a.ptr.avatarid = r:int(uint64,row, 13);
if r:null(row,8) then
a.ptr.key.ct = 0 a.ptr.key.ptr = nil
else
a.ptr.key = r:bin(row,8)
end
a.ptr.origin = origin
if avia.buf ~= nil then avia:free() end
................................................................................
var r = queries.auth_enum_uid.exec(src,uid)
if r.sz == 0 then return [lib.mem.ptr(lib.mem.ptr(lib.store.auth))].null() end
var ret = lib.mem.heapa([lib.mem.ptr(lib.store.auth)], r.sz)
for i=0, r.sz do
var kind = r:_string(i, 1)
var comment = r:_string(i, 2)
var a = [ lib.str.encapsulate(lib.store.auth, {
kind = {`kind.ptr, `kind.ct+1};
comment = {`comment.ptr, `comment.ct+1};
}) ]
a.ptr.aid = r:int(uint64, i, 0)
if r:null(i,3)
then a.ptr.netmask.pv = 0
else a.ptr.netmask = r:cidr(i, 3)
end
a.ptr.blacklist = r:bool(i, 4)
ret.ptr[i] = a
end
return ret
end];
auth_attach_pw = [terra(
................................................................................
uid: uint64,
artifact: uint64,
desc: pstring,
folder: pstring
): {}
queries.artifact_expropriate.exec(src,uid,artifact,desc,folder, lib.osclock.time(nil))
end];
artifact_disclaim = [terra(
src: &lib.store.source,
uid: uint64,
artifact: uint64
)
queries.artifact_disclaim.exec(src,uid,artifact)
queries.artifact_collect_garbage.exec(src) -- TODO add a config option to change GC strategies, instead of just always running a cycle after an artifact is disclaimed, which is not very efficient
end];
artifact_enum_uid = [terra(
src: &lib.store.source,
uid: uint64,
folder: pstring
)
var res = queries.artifact_enum_uid.exec(src,uid,folder)
|