forgot to add a few files

This commit is contained in:
Izalia Mae 2021-09-16 04:11:04 -04:00
parent 14af3349a7
commit 6b952cf0d0
2 changed files with 122 additions and 0 deletions

110
uncia/database/base.py Normal file
View file

@ -0,0 +1,110 @@
import json
from datetime import datetime
from functools import partial
from izzylib import DotDict, boolean, logging
from izzylib.http_requests_client.signature import generate_rsa_key
from izzylib.sql import SqlDatabase, SqlSession
from izzylib.sql import SqlColumn as Column
from urllib.parse import urlparse
from . import get, put, delete
from ..config import config, dbconfig
tables = {
'config': [
Column('id'),
Column('key', 'text', nullable=False),
Column('value', 'text')
],
'inbox': [
Column('id'),
Column('domain', 'text', nullable=False),
Column('inbox', 'text', nullable=False, unique=True),
Column('actor', 'text', nullable=False, unique=True),
Column('followid', 'text'),
Column('timestamp')
],
'retry': [
Column('id'),
Column('msgid', 'text', nullable=False),
Column('inboxid', 'integer', nullable=False, fkey='inbox.id'),
Column('data', 'json', nullable=False),
Column('headers', 'json')
],
'user': [
Column('id'),
Column('handle', 'text', nullable=False, unique=True),
Column('username', 'text'),
Column('hash', 'text'),
Column('level', 'integer', nullable=False, default=0),
Column('timestamp')
],
'token': [
Column('id'),
Column('userid', 'integer', fkey='user.id'),
Column('code', 'text', nullable=False, unique=True),
Column('timestamp')
],
'whitelist': [
Column('id'),
Column('domain', 'text', nullable=False, unique=True),
Column('timestamp')
],
'ban': [
Column('id'),
Column('handle', 'text'),
Column('domain', 'text'),
Column('reason', 'text'),
Column('timestamp')
],
'actor_cache': [
Column('id'),
Column('url', 'text', nullable=False, unique=True),
Column('data', 'json', nullable=False),
Column('timestamp')
]
}
class Session(SqlSession):
#get = get
#put = put
#delete = delete
config_defaults = dict(
version = (0, int),
pubkey = (None, str),
privkey = (None, str),
name = ('Uncia Relay', str),
description = ('Small and fast ActivityPub relay', str),
rules = ([], json.loads),
email = (None, str),
blocked_software = (['unciarelay', 'activityrelay', 'aoderelay', 'seatlerelay'], json.loads),
block_relays = (True, boolean),
require_approval = (True, boolean),
show_domain_bans = (False, boolean),
show_user_bans = (False, boolean),
show_whitelist = (False, boolean),
whitelist = (False, boolean)
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.get = DotDict()
self.put = DotDict()
self.delete = DotDict()
self._set_commands('get', get)
self._set_commands('put', put)
self._set_commands('delete', delete)
def _set_commands(self, name, mod):
for method in dir(mod):
if method.startswith('cmd_'):
getattr(self, name)[method[4:]] = partial(getattr(mod, method), self)

View file

@ -0,0 +1,12 @@
-extends 'base.haml'
-set page = 'About'
-block content
.title -> About
%h3 << Rules:
%ul#rules
-for rule in config.rules
%li -> =rule