Compare commits

...

4 commits

Author SHA1 Message Date
Izalia Mae 85825f6de1 don't use cached nodeinfo data when instance follows 2024-08-23 01:37:15 -04:00
Izalia Mae c9598ff273 update barkshark-lib and activitypub-utils 2024-08-23 01:13:55 -04:00
Izalia Mae 4203355d7d better error message when trying to set invalid config key 2024-08-23 01:13:32 -04:00
Izalia Mae 1516f27b76 properly convert Date objects for sqlite databases 2024-08-23 00:35:00 -04:00
5 changed files with 20 additions and 11 deletions

View file

@ -14,11 +14,11 @@ classifiers = [
"Programming Language :: Python :: 3.12"
]
dependencies = [
"activitypub-utils >= 0.3.1.post1, < 0.4.0",
"activitypub-utils >= 0.3.2, < 0.4",
"aiohttp >= 3.9.5",
"aiohttp-swagger[performance] == 1.0.16",
"argon2-cffi == 23.1.0",
"barkshark-lib >= 0.1.6, < 0.2.0",
"barkshark-lib >= 0.2.2.post2, < 0.3.0",
"barkshark-sql >= 0.2.0rc2, < 0.3.0",
"click == 8.1.2",
"hiredis == 2.3.2",

View file

@ -1,3 +1,6 @@
import sqlite3
from blib import Date
from bsql import Database
from .config import THEMES, ConfigData
@ -9,6 +12,9 @@ from ..config import Config
from ..misc import get_resource
sqlite3.register_adapter(Date, Date.timestamp)
def get_database(config: Config, migrate: bool = True) -> Database[Connection]:
options = {
'connection_class': Connection,

View file

@ -230,12 +230,10 @@ class HttpClient:
return
async def fetch_nodeinfo(self, domain: str) -> Nodeinfo:
async def fetch_nodeinfo(self, domain: str, force: bool = False) -> Nodeinfo:
nodeinfo_url = None
wk_nodeinfo = await self.get(
f'https://{domain}/.well-known/nodeinfo',
False,
WellKnownNodeinfo
f'https://{domain}/.well-known/nodeinfo', False, WellKnownNodeinfo, force
)
for version in ('20', '21'):
@ -248,7 +246,7 @@ class HttpClient:
if nodeinfo_url is None:
raise ValueError(f'Failed to fetch nodeinfo url for {domain}')
return await self.get(nodeinfo_url, False, Nodeinfo)
return await self.get(nodeinfo_url, False, Nodeinfo, force)
async def get(*args: Any, **kwargs: Any) -> Any:

View file

@ -362,10 +362,15 @@ def cli_config_list(ctx: click.Context) -> None:
def cli_config_set(ctx: click.Context, key: str, value: Any) -> None:
'Set a config value'
with ctx.obj.database.session() as conn:
new_value = conn.put_config(key, value)
try:
with ctx.obj.database.session() as conn:
new_value = conn.put_config(key, value)
print(f'{key}: {repr(new_value)}')
except:
click.echo('Invalid config name:', key)
return
click.echo(f'{key}: {repr(new_value)}')
@cli.group('user')

View file

@ -58,7 +58,7 @@ async def handle_forward(view: ActorView, conn: Connection) -> None:
async def handle_follow(view: ActorView, conn: Connection) -> None:
nodeinfo = await view.client.fetch_nodeinfo(view.actor.domain)
nodeinfo = await view.client.fetch_nodeinfo(view.actor.domain, force = True)
software = nodeinfo.sw_name if nodeinfo else None
config = conn.get_config_all()