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

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

    52     52   			end
    53     53   		end
    54     54   	end
    55     55   	acc:lpush('</em></div>')
    56     56   	acc:lpush('<div id="tl" data-live="10">')
    57     57   	var newest: lib.store.timepoint = 0
    58     58   	for i = 0, posts.sz do
           59  +		var author = co:uid2actor(posts(i).ptr.author)
    59     60   		if mode == modes.mutual and posts(i).ptr.author ~= co.who.id then
    60         -			var author = co:uid2actor(posts(i).ptr.author)
    61     61   			if not author.relationship.recip.follow() then goto skip end
    62     62   		end
           63  +		if author.relationship.rel.mute() or 
           64  +		   author.relationship.rel.avoid() or 
           65  +		   author.relationship.recip.exclude() then goto skip end
    63     66   		lib.render.tweet(co, posts(i).ptr, &acc)
    64     67   		var t = lib.math.biggest(lib.math.biggest(posts(i).ptr.posted, posts(i).ptr.discovered),posts(i).ptr.edited)
    65     68   		if t > newest then newest = t end
    66     69   		::skip:: posts(i):free()
    67     70   	end
    68     71   	if posts.run > 0 then posts:free() end
    69     72   	acc:lpush('</div>')

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

    13     13   	acc:lpush('</a> retweeted</div>')
    14     14   	if co.aid ~= 0 and co.who.id == rter.id then
    15     15   		acc:lpush('<a href="/post/'):shpush(rid):lpush('/del" class="del">✖</a>')
    16     16   	end
    17     17   end
    18     18   			
    19     19   local terra 
    20         -render_tweet(co: &lib.srv.convo, p: &lib.store.post, acc: &lib.str.acc)
           20  +render_tweet(co: &lib.srv.convo, p: &lib.store.post, acc: &lib.str.acc): pstr
    21     21   	var author: &lib.store.actor = nil
    22     22   	var retweeter: &lib.store.actor = nil
    23     23   	for j = 0, co.actorcache.top do
    24     24   		if p.author == co.actorcache(j).ptr.id then author    = co.actorcache(j).ptr end
    25     25   		if p.rtdby  == co.actorcache(j).ptr.id then retweeter = co.actorcache(j).ptr end
    26     26   		if author ~= nil and (p.rtdby == 0 or retweeter ~= nil) then
    27     27   			goto foundauth
................................................................................
    31     31   		author = co.actorcache:insert(co:uid2actor_live(p.author)).ptr
    32     32   	end
    33     33   	if p.rtdby ~= 0 and retweeter == nil then
    34     34   		retweeter = co.actorcache:insert(co:uid2actor_live(p.rtdby)).ptr
    35     35   	end
    36     36   
    37     37   	::foundauth::
           38  +	if author.relationship.rel.mute() or
           39  +	   author.relationship.recip.exclude() then return '' end
           40  +
    38     41   	var timestr: int8[26] lib.osclock.ctime_r(&p.posted, &timestr[0])
    39     42   	for i=0,26 do if timestr[i] == @'\n' then timestr[i] = 0 break end end -- 🙄
    40         -
    41         -	var bhtml = lib.smackdown.html(&co.srv.pool, [lib.mem.ptr(int8)] {ptr=p.body,ct=0},false)
           43  +	var ptxt = pstr {ptr=p.body,ct=lib.str.sz(p.body)}
           44  +	if author.relationship.rel.disemvowel() then
           45  +		ptxt = lib.str.disemvowel(&co.srv.pool, ptxt)
           46  +	end
           47  +	var bhtml = lib.smackdown.html(&co.srv.pool, ptxt,false)
    42     48   	--defer bhtml:free()
    43     49   
    44     50   	var idbuf: int8[lib.math.shorthand.maxlen]
    45     51   	var idlen = lib.math.shorthand.gen(p.id, idbuf)
    46     52   	var permalink: lib.str.acc permalink:pool(&co.srv.pool, 7+idlen):lpush('/post/'):push(idbuf,idlen)
    47     53   	var fullname = lib.render.nym(author,0,nil, false) defer fullname:free()
    48     54   	var tpl = data.view.tweet {

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

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

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

   475    475   
   476    476   		else b:push(str.ptr + i,1) end
   477    477   	end
   478    478   	if mode ~= 0 then return m.t.null(), 0, false end
   479    479   
   480    480   	return b:finalize(), max, spacebroke
   481    481   end
          482  +
          483  +local terra disemvowel_codepoint(start: pstr): {pstr, pstr}
          484  + -- TODO rewrite this in a more generative way -- it should be possible
          485  + -- to have a long string listing vowels and generate all the necessary
          486  + -- code based on that
          487  +	var dslen: intptr = 0
          488  +	var repl = pstr.null()
          489  +
          490  +	var adc = m.cdowncase(start(0))
          491  +	if adc == @'a' or adc == @'e'
          492  +	or adc == @'i' or adc == @'o'
          493  +	or adc == @'u' then
          494  +		dslen = 1 goto done
          495  +	end
          496  +
          497  +	if start.ct >= 2 then
          498  +		var tb = pstr { start.ptr, 2 }
          499  +		if tb:cmp('ä') or tb:cmp('ë') or tb:cmp('ï')
          500  +		or tb:cmp('Ä') or tb:cmp('Ë') or tb:cmp('Ï')
          501  +		or tb:cmp('ö') or tb:cmp('ü') -- haben Sie für diese Vokale
          502  +		or tb:cmp('Ö') or tb:cmp('Ü') -- kein Ausweis dabei, mein Herr
          503  +
          504  +		or tb:cmp('á') or tb:cmp('é') or tb:cmp('í')
          505  +		or tb:cmp('Á') or tb:cmp('É') or tb:cmp('Í')
          506  +		or tb:cmp('ó') or tb:cmp('ú') 
          507  +		or tb:cmp('Ó') or tb:cmp('Ú')
          508  +
          509  +		or tb:cmp('à') or tb:cmp('è') or tb:cmp('ì')
          510  +		or tb:cmp('À') or tb:cmp('È') or tb:cmp('Ì')
          511  +		or tb:cmp('ò') or tb:cmp('ù') -- not so fast,
          512  +		or tb:cmp('Ò') or tb:cmp('Ù') -- "il capo"
          513  +
          514  +		or tb:cmp('ā') or tb:cmp('ē') or tb:cmp('ī')
          515  +		or tb:cmp('Ā') or tb:cmp('Ē') or tb:cmp('Ī')
          516  +		or tb:cmp('ō') or tb:cmp('ū') -- take that latin
          517  +		or tb:cmp('Ō') or tb:cmp('Ū') -- and also hawaiian
          518  +
          519  +		or tb:cmp('æ') or tb:cmp('Æ') -- sorry elon
          520  +		or tb:cmp('œ') or tb:cmp('Œ') -- sacre bleu
          521  +		or tb:cmp('ij') or tb:cmp('IJ') -- ok wtf dutch
          522  +
          523  +		then dslen = 2 goto done end
          524  +	end
          525  +
          526  +	if start.ct >= 3 then
          527  +		var s = [&uint8](start.ptr) -- for safe unicode comparisons, bc char is dumb
          528  +		if s[0] == 0xe3 and -- eliminate kana
          529  +			((s[1] == 0x81 and s[2] >= 0x81) or
          530  +			 (s[1] == 0x82 and s[2] <= 0x96)) or
          531  +			((s[1] == 0x82 and s[2] >= 0xa1) or
          532  +			 (s[1] == 0x83 and s[2] <= 0xb6))
          533  +		then dslen = 3 goto done end
          534  +	end
          535  +	-- TODO handle more nonroman scripts
          536  +	-- maybe remove consonant pointing in arabic??
          537  +	-- i guess remove vowels from devanagari
          538  +	-- no idea what to do about chinese
          539  +
          540  +	-- no disemvoweling applied, return the current byte as is
          541  +		repl = pstr { ptr = start.ptr, ct = 1 }
          542  +		dslen = 1
          543  +
          544  +	::done::
          545  +	start:advance(dslen)
          546  +	lib.io.fmt('applied %llu bytes of disemvowelling; adding "%.*s"; continuing with "%.*s"\n', dslen, repl.ct, repl.ptr, start.ct, start.ptr)
          547  +	return repl, start
          548  +end
          549  +
          550  +terra m.disemvowel(pool: &lib.mem.pool, str: m.t): m.t
          551  +	var acc: m.acc acc:pool(pool, str.ct)
          552  +	if str.ct == 0 then str.ct = m.sz(str.ptr) end
          553  +	var cur = str while cur.ct > 0 do
          554  +		var add, cont = disemvowel_codepoint(cur)
          555  +		if add:ref() then acc:ppush(add) end
          556  +		cur = cont
          557  +	end
          558  +	return acc:finalize()
          559  +end
   482    560   
   483    561   return m

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

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