mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-09 18:08:00 +00:00
Compare commits
5 commits
5ae3d55e44
...
89300057ef
Author | SHA1 | Date | |
---|---|---|---|
89300057ef | |||
b59ead5d05 | |||
b8aae4c1bb | |||
85a4797e68 | |||
c2aa8c48bb |
|
@ -17,7 +17,12 @@ if typing.TYPE_CHECKING:
|
|||
|
||||
def get_database(config: Config, migrate: bool = True) -> tinysql.Database:
|
||||
if config.db_type == "sqlite":
|
||||
db = tinysql.Database.sqlite(config.sqlite_path, connection_class = Connection)
|
||||
# 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
|
||||
)
|
||||
|
||||
elif config.db_type == "postgres":
|
||||
db = tinysql.Database.postgres(
|
||||
|
|
|
@ -180,6 +180,11 @@ 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 = '',
|
||||
|
|
|
@ -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 a 3.6.0
|
||||
# akkoma changed this in 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 view.config.is_banned_software(software):
|
||||
if conn.get_software_ban(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.inbox):
|
||||
if not conn.del_inbox(view.actor.id):
|
||||
logging.verbose(
|
||||
'Failed to delete "%s" with follow ID "%s"',
|
||||
view.actor.id,
|
||||
|
|
|
@ -9,6 +9,7 @@ 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
|
||||
|
@ -112,11 +113,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.inbox)
|
||||
self.instance = conn.get_inbox(self.actor.shared_inbox)
|
||||
config = conn.get_config_all()
|
||||
|
||||
## reject if the actor isn't whitelisted while the whiltelist is enabled
|
||||
|
@ -170,7 +171,7 @@ class ActorView(View):
|
|||
|
||||
self.actor = await self.client.get(self.signature.keyid, sign_headers = True)
|
||||
|
||||
if self.actor is None:
|
||||
if not self.actor:
|
||||
# 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')
|
||||
|
|
Loading…
Reference in a new issue