Compare commits

..

No commits in common. "b59ead5d05eacafd421cb8700ff64c36a5d4a2b2" and "815053c06faffcebca438056610a971f1f4033bc" have entirely different histories.

4 changed files with 7 additions and 18 deletions

View file

@ -17,12 +17,7 @@ if typing.TYPE_CHECKING:
def get_database(config: Config, migrate: bool = True) -> tinysql.Database:
if config.db_type == "sqlite":
# todo: remove check_same_thread when tinysql stores connections per thread
db = tinysql.Database.sqlite(
config.sqlite_path,
connection_class = Connection,
check_same_thread = False
)
db = tinysql.Database.sqlite(config.sqlite_path, connection_class = Connection)
elif config.db_type == "postgres":
db = tinysql.Database.postgres(

View file

@ -180,11 +180,6 @@ class Message(ApMessage):
class Response(AiohttpResponse):
# AiohttpResponse.__len__ method returns 0, so bool(response) always returns False
def __bool__(self) -> bool:
return True
@classmethod
def new(cls: type[Response],
body: str | bytes | dict = '',

View file

@ -17,7 +17,7 @@ cache = LRUCache(1024)
def person_check(actor: str, software: str) -> bool:
# pleroma and akkoma may use Person for the actor type for some reason
# akkoma changed this in 3.6.0
# akkoma changed this in a 3.6.0
if software in {'akkoma', 'pleroma'} and actor.id == f'https://{actor.domain}/relay':
return False
@ -62,7 +62,7 @@ async def handle_follow(view: ActorView) -> None:
with view.database.connection() as conn:
# reject if software used by actor is banned
if conn.get_software_ban(software):
if view.config.is_banned_software(software):
view.app.push_message(
view.actor.shared_inbox,
Message.new_response(
@ -141,7 +141,7 @@ async def handle_undo(view: ActorView) -> None:
return
with view.database.connection() as conn:
if not conn.del_inbox(view.actor.id):
if not conn.del_inbox(view.actor.inbox):
logging.verbose(
'Failed to delete "%s" with follow ID "%s"',
view.actor.id,

View file

@ -9,7 +9,6 @@ from aputils.errors import SignatureFailureError
from aputils.misc import Digest, HttpDate, Signature
from aputils.objects import Nodeinfo, Webfinger, WellKnownNodeinfo
from pathlib import Path
from urllib.parse import urlparse
from . import __version__
from . import logger as logging
@ -113,11 +112,11 @@ class ActorView(View):
async def post(self, request: Request) -> Response:
if response := await self.get_post_data():
if (response := await self.get_post_data()):
return response
with self.database.connection() as conn:
self.instance = conn.get_inbox(self.actor.shared_inbox)
self.instance = conn.get_inbox(self.actor.inbox)
config = conn.get_config_all()
## reject if the actor isn't whitelisted while the whiltelist is enabled
@ -171,7 +170,7 @@ class ActorView(View):
self.actor = await self.client.get(self.signature.keyid, sign_headers = True)
if not self.actor:
if self.actor is None:
# ld signatures aren't handled atm, so just ignore it
if self.message.type == 'Delete':
logging.verbose('Instance sent a delete which cannot be handled')