parsav  Check-in [60040f3ca3]

Overview
Comment:implement some sanctions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 60040f3ca37326faf450c1c33fefac37b9a979fc583730e0b42dc211a0c109dd
User & Date: lexi on 2021-01-13 13:57:54
Other Links: manifest | tags
Context
2021-01-13
15:01
begin work on circles check-in: a4b4af5ca4 user: lexi tags: trunk
13:57
implement some sanctions check-in: 60040f3ca3 user: lexi tags: trunk
00:04
add full relationship control screen, more timelines, minor fixes and cleanups check-in: d3fe1d11af user: lexi tags: trunk
Changes

Modified render/profile.t from [446c5d468d] to [0e11aad870].

95
96
97
98
99
100
101

102
103
104
105
106
107
108
	relationship: &lib.store.relationship
): pstr
	var aux = co:stra(128)
	var followed = false -- FIXME
	if co.aid ~= 0 and co.who.id == actor.id then
		aux:lpush('<a accesskey="a" class="button" href="/conf/profile?go=/@'):push(actor.handle,0):lpush('">alter</a>')
	elseif co.aid ~= 0 then

		if co.who.rights.powers:affect_users() and co.who:overpowers(actor) then
			aux:lpush(' <a accesskey="n" class="button" href="/conf/users/'):shpush(actor.id):lpush('">control</a>')
		end
	else
		aux:lpush(' <a accesskey="f" class="button" href="/'):push(actor.xid,0):lpush('/follow">remote follow</a>')
	end
	var auxp = aux:finalize()







>







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
	relationship: &lib.store.relationship
): pstr
	var aux = co:stra(128)
	var followed = false -- FIXME
	if co.aid ~= 0 and co.who.id == actor.id then
		aux:lpush('<a accesskey="a" class="button" href="/conf/profile?go=/@'):push(actor.handle,0):lpush('">alter</a>')
	elseif co.aid ~= 0 then
		aux:lpush('<a class="button" href="#rel">options</a>')
		if co.who.rights.powers:affect_users() and co.who:overpowers(actor) then
			aux:lpush(' <a accesskey="n" class="button" href="/conf/users/'):shpush(actor.id):lpush('">control</a>')
		end
	else
		aux:lpush(' <a accesskey="f" class="button" href="/'):push(actor.xid,0):lpush('/follow">remote follow</a>')
	end
	var auxp = aux:finalize()

Modified render/timeline.t from [91a054f52e] to [dac341c838].

52
53
54
55
56
57
58
59
60

61
62



63
64
65
66
67
68
69
			end
		end
	end
	acc:lpush('</em></div>')
	acc:lpush('<div id="tl" data-live="10">')
	var newest: lib.store.timepoint = 0
	for i = 0, posts.sz do
		if mode == modes.mutual and posts(i).ptr.author ~= co.who.id then
			var author = co:uid2actor(posts(i).ptr.author)

			if not author.relationship.recip.follow() then goto skip end
		end



		lib.render.tweet(co, posts(i).ptr, &acc)
		var t = lib.math.biggest(lib.math.biggest(posts(i).ptr.posted, posts(i).ptr.discovered),posts(i).ptr.edited)
		if t > newest then newest = t end
		::skip:: posts(i):free()
	end
	if posts.run > 0 then posts:free() end
	acc:lpush('</div>')







<
|
>


>
>
>







52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
67
68
69
70
71
72
			end
		end
	end
	acc:lpush('</em></div>')
	acc:lpush('<div id="tl" data-live="10">')
	var newest: lib.store.timepoint = 0
	for i = 0, posts.sz do

		var author = co:uid2actor(posts(i).ptr.author)
		if mode == modes.mutual and posts(i).ptr.author ~= co.who.id then
			if not author.relationship.recip.follow() then goto skip end
		end
		if author.relationship.rel.mute() or 
		   author.relationship.rel.avoid() or 
		   author.relationship.recip.exclude() then goto skip end
		lib.render.tweet(co, posts(i).ptr, &acc)
		var t = lib.math.biggest(lib.math.biggest(posts(i).ptr.posted, posts(i).ptr.discovered),posts(i).ptr.edited)
		if t > newest then newest = t end
		::skip:: posts(i):free()
	end
	if posts.run > 0 then posts:free() end
	acc:lpush('</div>')

Modified render/tweet.t from [fad3f537df] to [63ff346749].

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
31
32
33
34
35
36
37



38
39
40




41
42
43
44
45
46
47
48
	acc:lpush('</a> retweeted</div>')
	if co.aid ~= 0 and co.who.id == rter.id then
		acc:lpush('<a href="/post/'):shpush(rid):lpush('/del" class="del">✖</a>')
	end
end
			
local terra 
render_tweet(co: &lib.srv.convo, p: &lib.store.post, acc: &lib.str.acc)
	var author: &lib.store.actor = nil
	var retweeter: &lib.store.actor = nil
	for j = 0, co.actorcache.top do
		if p.author == co.actorcache(j).ptr.id then author    = co.actorcache(j).ptr end
		if p.rtdby  == co.actorcache(j).ptr.id then retweeter = co.actorcache(j).ptr end
		if author ~= nil and (p.rtdby == 0 or retweeter ~= nil) then
			goto foundauth
................................................................................
		author = co.actorcache:insert(co:uid2actor_live(p.author)).ptr
	end
	if p.rtdby ~= 0 and retweeter == nil then
		retweeter = co.actorcache:insert(co:uid2actor_live(p.rtdby)).ptr
	end

	::foundauth::



	var timestr: int8[26] lib.osclock.ctime_r(&p.posted, &timestr[0])
	for i=0,26 do if timestr[i] == @'\n' then timestr[i] = 0 break end end -- 🙄





	var bhtml = lib.smackdown.html(&co.srv.pool, [lib.mem.ptr(int8)] {ptr=p.body,ct=0},false)
	--defer bhtml:free()

	var idbuf: int8[lib.math.shorthand.maxlen]
	var idlen = lib.math.shorthand.gen(p.id, idbuf)
	var permalink: lib.str.acc permalink:pool(&co.srv.pool, 7+idlen):lpush('/post/'):push(idbuf,idlen)
	var fullname = lib.render.nym(author,0,nil, false) defer fullname:free()
	var tpl = data.view.tweet {







|







 







>
>
>


<
>
>
>
>
|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
	acc:lpush('</a> retweeted</div>')
	if co.aid ~= 0 and co.who.id == rter.id then
		acc:lpush('<a href="/post/'):shpush(rid):lpush('/del" class="del">✖</a>')
	end
end
			
local terra 
render_tweet(co: &lib.srv.convo, p: &lib.store.post, acc: &lib.str.acc): pstr
	var author: &lib.store.actor = nil
	var retweeter: &lib.store.actor = nil
	for j = 0, co.actorcache.top do
		if p.author == co.actorcache(j).ptr.id then author    = co.actorcache(j).ptr end
		if p.rtdby  == co.actorcache(j).ptr.id then retweeter = co.actorcache(j).ptr end
		if author ~= nil and (p.rtdby == 0 or retweeter ~= nil) then
			goto foundauth
................................................................................
		author = co.actorcache:insert(co:uid2actor_live(p.author)).ptr
	end
	if p.rtdby ~= 0 and retweeter == nil then
		retweeter = co.actorcache:insert(co:uid2actor_live(p.rtdby)).ptr
	end

	::foundauth::
	if author.relationship.rel.mute() or
	   author.relationship.recip.exclude() then return '' end

	var timestr: int8[26] lib.osclock.ctime_r(&p.posted, &timestr[0])
	for i=0,26 do if timestr[i] == @'\n' then timestr[i] = 0 break end end -- 🙄

	var ptxt = pstr {ptr=p.body,ct=lib.str.sz(p.body)}
	if author.relationship.rel.disemvowel() then
		ptxt = lib.str.disemvowel(&co.srv.pool, ptxt)
	end
	var bhtml = lib.smackdown.html(&co.srv.pool, ptxt,false)
	--defer bhtml:free()

	var idbuf: int8[lib.math.shorthand.maxlen]
	var idlen = lib.math.shorthand.gen(p.id, idbuf)
	var permalink: lib.str.acc permalink:pool(&co.srv.pool, 7+idlen):lpush('/post/'):push(idbuf,idlen)
	var fullname = lib.render.nym(author,0,nil, false) defer fullname:free()
	var tpl = data.view.tweet {

Modified store.t from [131fc4292b] to [303dfd42c8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- vim: ft=terra
local m = {
	timepoint = lib.osclock.time_t;
	scope = lib.enum {
		'public', 'private', 'local';
		'personal', 'direct', 'circle';
	};
	noticetype = lib.enum {
	 -- only add new values to the end of this list! the numerical value
	 -- is stored in the database and must be kept synchronized across versions
		'none', 'mention', 'reply', 'like', 'rt', 'react', 'follow', 'followreq'
	};

	relation = lib.set {



<
<
<
<







1
2
3




4
5
6
7
8
9
10
-- vim: ft=terra
local m = {
	timepoint = lib.osclock.time_t;




	noticetype = lib.enum {
	 -- only add new values to the end of this list! the numerical value
	 -- is stored in the database and must be kept synchronized across versions
		'none', 'mention', 'reply', 'like', 'rt', 'react', 'follow', 'followreq'
	};

	relation = lib.set {

Modified str.t from [2798df18ea] to [ee5af81e76].

475
476
477
478
479
480
481
482














































































483

		else b:push(str.ptr + i,1) end
	end
	if mode ~= 0 then return m.t.null(), 0, false end

	return b:finalize(), max, spacebroke
end















































































return m








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561

		else b:push(str.ptr + i,1) end
	end
	if mode ~= 0 then return m.t.null(), 0, false end

	return b:finalize(), max, spacebroke
end

local terra disemvowel_codepoint(start: pstr): {pstr, pstr}
 -- TODO rewrite this in a more generative way -- it should be possible
 -- to have a long string listing vowels and generate all the necessary
 -- code based on that
	var dslen: intptr = 0
	var repl = pstr.null()

	var adc = m.cdowncase(start(0))
	if adc == @'a' or adc == @'e'
	or adc == @'i' or adc == @'o'
	or adc == @'u' then
		dslen = 1 goto done
	end

	if start.ct >= 2 then
		var tb = pstr { start.ptr, 2 }
		if tb:cmp('ä') or tb:cmp('ë') or tb:cmp('ï')
		or tb:cmp('Ä') or tb:cmp('Ë') or tb:cmp('Ï')
		or tb:cmp('ö') or tb:cmp('ü') -- haben Sie für diese Vokale
		or tb:cmp('Ö') or tb:cmp('Ü') -- kein Ausweis dabei, mein Herr

		or tb:cmp('á') or tb:cmp('é') or tb:cmp('í')
		or tb:cmp('Á') or tb:cmp('É') or tb:cmp('Í')
		or tb:cmp('ó') or tb:cmp('ú') 
		or tb:cmp('Ó') or tb:cmp('Ú')

		or tb:cmp('à') or tb:cmp('è') or tb:cmp('ì')
		or tb:cmp('À') or tb:cmp('È') or tb:cmp('Ì')
		or tb:cmp('ò') or tb:cmp('ù') -- not so fast,
		or tb:cmp('Ò') or tb:cmp('Ù') -- "il capo"

		or tb:cmp('ā') or tb:cmp('ē') or tb:cmp('ī')
		or tb:cmp('Ā') or tb:cmp('Ē') or tb:cmp('Ī')
		or tb:cmp('ō') or tb:cmp('ū') -- take that latin
		or tb:cmp('Ō') or tb:cmp('Ū') -- and also hawaiian

		or tb:cmp('æ') or tb:cmp('Æ') -- sorry elon
		or tb:cmp('œ') or tb:cmp('Œ') -- sacre bleu
		or tb:cmp('ij') or tb:cmp('IJ') -- ok wtf dutch

		then dslen = 2 goto done end
	end

	if start.ct >= 3 then
		var s = [&uint8](start.ptr) -- for safe unicode comparisons, bc char is dumb
		if s[0] == 0xe3 and -- eliminate kana
			((s[1] == 0x81 and s[2] >= 0x81) or
			 (s[1] == 0x82 and s[2] <= 0x96)) or
			((s[1] == 0x82 and s[2] >= 0xa1) or
			 (s[1] == 0x83 and s[2] <= 0xb6))
		then dslen = 3 goto done end
	end
	-- TODO handle more nonroman scripts
	-- maybe remove consonant pointing in arabic??
	-- i guess remove vowels from devanagari
	-- no idea what to do about chinese

	-- no disemvoweling applied, return the current byte as is
		repl = pstr { ptr = start.ptr, ct = 1 }
		dslen = 1

	::done::
	start:advance(dslen)
	lib.io.fmt('applied %llu bytes of disemvowelling; adding "%.*s"; continuing with "%.*s"\n', dslen, repl.ct, repl.ptr, start.ct, start.ptr)
	return repl, start
end

terra m.disemvowel(pool: &lib.mem.pool, str: m.t): m.t
	var acc: m.acc acc:pool(pool, str.ct)
	if str.ct == 0 then str.ct = m.sz(str.ptr) end
	var cur = str while cur.ct > 0 do
		var add, cont = disemvowel_codepoint(cur)
		if add:ref() then acc:ppush(add) end
		cur = cont
	end
	return acc:finalize()
end

return m

Modified view/profile.tpl from [b073906391] to [240a608504].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
		<div>
			<a class="button" href="/@:xid">posts</a>
			<a class="button" href="/@:xid/arc">archive</a>
			<a class="button" href="/@:xid/media">media</a>
			<a class="button" href="/@:xid/social">associates</a>
		</div>
		<div>
			<a class="button" href="#rel">options</a>
			@auxbtn
		</div>
	</form>
</div>

<form id="rel" class="modal" method="post">
<a href="#0" class="button">close</a><div>







<







21
22
23
24
25
26
27

28
29
30
31
32
33
34
		<div>
			<a class="button" href="/@:xid">posts</a>
			<a class="button" href="/@:xid/arc">archive</a>
			<a class="button" href="/@:xid/media">media</a>
			<a class="button" href="/@:xid/social">associates</a>
		</div>
		<div>

			@auxbtn
		</div>
	</form>
</div>

<form id="rel" class="modal" method="post">
<a href="#0" class="button">close</a><div>