parsav  Diff

Differences From Artifact [213b3d2729]:

To Artifact [5ad659a834]:


    12     12   		'follow', 'mute', 'block'
    13     13   	};
    14     14   	credset = lib.set {
    15     15   		'pw', 'otp', 'challenge', 'trust'
    16     16   	};
    17     17   	privset = lib.set {
    18     18   		'post', 'edit', 'acct', 'upload', 'censor', 'admin'
           19  +	};
           20  +	powerset = lib.set {
           21  +		-- user powers -- default on
           22  +		'login', 'visible', 'post', 'shout',
           23  +		'propagate', 'upload', 'acct', 'edit';
           24  +
           25  +		-- admin powers -- default off
           26  +		'purge', 'config', 'censor', 'suspend',
           27  +		'cred', 'elevate', 'demote', 'rebrand' -- modify site's brand identity
    19     28   	}
    20     29   }
           30  +
           31  +terra m.powerset:affect_users()
           32  +	return self.purge() or self.censor() or self.suspend() or
           33  +	       self.elevate() or self.demote() or self.rebrand() or
           34  +		   self.cred()
           35  +end
    21     36   
    22     37   local str = rawstring --lib.mem.ptr(int8)
    23     38   
    24     39   struct m.source
    25     40   
    26     41   struct m.rights {
    27     42   	rank: uint16 -- lower = more powerful except 0 = regular user
    28     43   	-- creating staff automatically assigns rank immediately below you
    29     44   	quota: uint32 -- # of allowed tweets per day; 0 = no limit
    30     45   	
    31         -	-- user powers -- default on
    32         -	login: bool
    33         -	visible: bool
    34         -	post: bool
    35         -	shout: bool
    36         -	propagate: bool
    37         -	upload: bool
    38         -	acct: bool
    39         -	edit: bool
    40         -
    41         -	-- admin powers -- default off
    42         -	ban: bool
    43         -	config: bool
    44         -	censor: bool
    45         -	suspend: bool
    46         -	rebrand: bool -- modify site's brand identity
           46  +	powers: m.powerset
    47     47   }
    48     48   
    49     49   terra m.rights_default()
    50         -	return m.rights {
    51         -		rank = 0, quota = 1000;
    52         -		
    53         -		login = true, visible = true, post = true;
    54         -		shout = true, propagate = true, upload = true;
    55         -
    56         -		ban = false, config = false, censor = false;
    57         -		suspend = false, rebrand = false;
    58         -	}
           50  +	var pow: m.powerset pow:fill()
           51  +	(pow.purge << false)
           52  +	(pow.config << false)
           53  +	(pow.censor << false)
           54  +	(pow.suspend << false)
           55  +	(pow.elevate << false)
           56  +	(pow.demote << false)
           57  +	(pow.cred << false)
           58  +	(pow.rebrand << false)
           59  +	return m.rights { rank = 0, quota = 1000, powers = pow; }
    59     60   end
    60     61   
    61     62   struct m.actor {
    62     63   	id: uint64
    63     64   	nym: str
    64     65   	handle: str
    65     66   	origin: uint64
    66     67   	bio: str
           68  +	avatar: str
           69  +	knownsince: int64
    67     70   	rights: m.rights
    68     71   	key: lib.mem.ptr(uint8)
    69     72   
           73  +-- ephemera
    70     74   	xid: str
    71         -
    72     75   	source: &m.source
    73     76   }
           77  +
           78  +struct m.actor_stats {
           79  +	posts: intptr
           80  +	follows: intptr
           81  +	followers: intptr
           82  +	mutuals: intptr
           83  +}
    74     84   
    75     85   struct m.range {
    76     86   	time: bool
    77     87   	union {
    78     88   		from_time: m.timepoint
    79     89   		from_idx: uint64
    80     90   	}
................................................................................
   165    175   	actor_save: {&m.source, m.actor} -> bool
   166    176   	actor_create: {&m.source, m.actor} -> bool
   167    177   	actor_fetch_xid: {&m.source, lib.mem.ptr(int8)} -> lib.mem.ptr(m.actor)
   168    178   	actor_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.actor)
   169    179   	actor_notif_fetch_uid: {&m.source, uint64} -> lib.mem.ptr(m.notif)
   170    180   	actor_enum: {&m.source} -> lib.mem.ptr(&m.actor)
   171    181   	actor_enum_local: {&m.source} -> lib.mem.ptr(&m.actor)
          182  +	actor_stats: {&m.source, uint64} -> m.actor_stats
   172    183   
   173         -	actor_auth_how: {&m.source, m.inet, rawstring} -> m.credset
          184  +	actor_auth_how: {&m.source, m.inet, rawstring} -> {m.credset, bool}
   174    185   		-- returns a set of auth method categories that are available for a
   175    186   		-- given user from a certain origin
   176    187   			-- origin: inet
   177         -			-- handle: rawstring
          188  +			-- username: rawstring
   178    189   	actor_auth_otp: {&m.source, m.inet, rawstring, rawstring} -> uint64
   179         -	actor_auth_pw: {&m.source, m.inet, rawstring, rawstring} -> uint64
          190  +	actor_auth_pw: {&m.source, m.inet, lib.mem.ptr(int8), lib.mem.ptr(int8) } -> uint64
   180    191   		-- handles password-based logins against hashed passwords
   181    192   			-- origin: inet
   182    193   			-- handle: rawstring
   183    194   			-- token:  rawstring
   184    195   	actor_auth_tls:    {&m.source, m.inet, rawstring} -> uint64
   185    196   		-- handles implicit authentication performed as part of an TLS connection
   186    197   			-- origin: inet
................................................................................
   219    230   terra m.source:free()
   220    231   	self.id:free()
   221    232   	self.string:free()
   222    233   end
   223    234   m.source.metamethods.__methodmissing = macro(function(meth, obj, ...)
   224    235   	local q = {...}
   225    236   	-- syntax sugar to forward unrecognized calls onto the backend
   226         -	return `obj.backend.[meth](&obj, [q])
          237  +	return quote var r = obj.backend.[meth](&obj, [q]) in r end
   227    238   end)
   228    239   
   229    240   return m