parsav  Diff

Differences From Artifact [4959208545]:

To Artifact [71684bc451]:


     4      4   	scope = lib.enum {
     5      5   		'public', 'private', 'local';
     6      6   		'personal', 'direct', 'circle';
     7      7   	};
     8      8   	notiftype = lib.enum {
     9      9   		'mention', 'like', 'rt', 'react'
    10     10   	};
           11  +
    11     12   	relation = lib.enum {
    12     13   		'follow', 'mute', 'block'
    13     14   	};
    14     15   	credset = lib.set {
    15     16   		'pw', 'otp', 'challenge', 'trust'
    16     17   	};
    17     18   	privset = lib.set {
................................................................................
    20     21   	powerset = lib.set {
    21     22   		-- user powers -- default on
    22     23   		'login', 'visible', 'post', 'shout',
    23     24   		'propagate', 'upload', 'acct', 'edit';
    24     25   
    25     26   		-- admin powers -- default off
    26     27   		'purge', 'config', 'censor', 'suspend',
    27         -		'cred', 'elevate', 'demote', 'rebrand' -- modify site's brand identity
           28  +		'cred', 'elevate', 'demote', 'rebrand', -- modify site's brand identity
           29  +		'herald' -- grant serverwide epithets
           30  +	};
           31  +	prepmode = lib.enum {
           32  +		'full','conf','admin'
    28     33   	}
    29     34   }
    30     35   
    31     36   terra m.powerset:affect_users()
    32     37   	return self.purge() or self.censor() or self.suspend() or
    33         -	       self.elevate() or self.demote() or self.rebrand() or
    34         -		   self.cred()
           38  +	       self.elevate() or self.demote() or self.cred()
    35     39   end
    36     40   
    37     41   local str = rawstring
    38     42   local pstr = lib.mem.ptr(int8)
    39     43   
    40     44   struct m.source
    41     45   
................................................................................
    62     66   
    63     67   struct m.actor {
    64     68   	id: uint64
    65     69   	nym: str
    66     70   	handle: str
    67     71   	origin: uint64
    68     72   	bio: str
    69         -	title: str
           73  +	epithet: str
    70     74   	avatar: str
    71     75   	knownsince: m.timepoint
    72     76   	rights: m.rights
    73     77   	key: lib.mem.ptr(uint8)
    74     78   
    75     79   -- ephemera
    76     80   	xid: str
    77     81   	source: &m.source
    78     82   }
           83  +
           84  +terra m.actor.methods.mk(kbuf: &uint8)
           85  +	var newkp = lib.crypt.genkp()
           86  +	var privsz = lib.crypt.der(false,&newkp,kbuf)
           87  +	return m.actor {
           88  +		id = 0; nym = nil; handle = nil;
           89  +		origin = 0; bio = nil; avatar = nil;
           90  +		knownsince = lib.osclock.time(nil);
           91  +		rights = m.rights_default();
           92  +		epithet = nil, key = [lib.mem.ptr(uint8)] {
           93  +			ptr = &kbuf[0], ct = privsz
           94  +		};
           95  +	}
           96  +end
    79     97   
    80     98   struct m.actor_stats {
    81     99   	posts: intptr
    82    100   	follows: intptr
    83    101   	followers: intptr
    84    102   	mutuals: intptr
    85    103   }
................................................................................
   178    196   	blacklist: bool
   179    197   }
   180    198   
   181    199   -- backends only handle content on the local server
   182    200   struct m.backend { id: rawstring
   183    201   	open: &m.source -> &opaque
   184    202   	close: &m.source -> {}
          203  +	dbsetup: &m.source -> bool -- creates the schema needed to call conprep (called only once per database e.g. with `parsav db init`)
          204  +	conprep: {&m.source, m.prepmode.t} -> {} -- prepares queries and similar tasks that require the schema to already be in place
          205  +	obliterate_everything: &m.source -> bool -- wipes everything parsav-related out of the database
   185    206   
   186    207   	conf_get: {&m.source, rawstring} -> lib.mem.ptr(int8)
   187    208   	conf_set: {&m.source, rawstring, rawstring} -> {}
   188    209   	conf_reset: {&m.source, rawstring} -> {}
   189    210   
   190    211   	actor_save: {&m.source, &m.actor} -> bool
   191    212   	actor_create: {&m.source, &m.actor} -> uint64
................................................................................
   231    252   		-- notifies the backend module of the UID that has been assigned for
   232    253   		-- an authentication ID
   233    254   			-- aid: uint64
   234    255   			-- uid: uint64
   235    256   
   236    257   	actor_conf_str: cnf(rawstring, lib.mem.ptr(int8))
   237    258   	actor_conf_int: cnf(intptr, lib.stat(intptr))
          259  +
          260  +	auth_create_pw: {&m.source, uint64, bool, lib.mem.ptr(int8)} -> {}
          261  +		-- uid: uint64
          262  +		-- reset: bool (delete other passwords?)
          263  +		-- pw: pstring
   238    264   
   239    265   	post_save: {&m.source, &m.post} -> {}
   240    266   	post_create: {&m.source, &m.post} -> uint64
   241    267   	post_enum_author_uid: {&m.source, uint64, m.range} -> lib.mem.ptr(lib.mem.ptr(m.post))
   242    268   	convo_fetch_xid: {&m.source,rawstring} -> lib.mem.ptr(m.post)
   243    269   	convo_fetch_uid: {&m.source,uint64} -> lib.mem.ptr(m.post)
   244    270