properly fetch domain bans and cleanup middleware and inbox view
This commit is contained in:
parent
22d0ed0b9a
commit
4b0ac36ecc
|
@ -38,15 +38,14 @@ def cmd_ban(self, handle=None, domain=None):
|
|||
return cache
|
||||
|
||||
if handle and not domain:
|
||||
return self.fetch('ban', handle=handle)
|
||||
row = self.fetch('ban', handle=handle)
|
||||
|
||||
elif not handle and domain:
|
||||
return self.fetch('ban', domain=domain)
|
||||
elif not handle and not domain:
|
||||
raise ValueError('handle or domain not specified')
|
||||
|
||||
elif handle and domain:
|
||||
return self.fetch('ban', handle=handle, domain=domain)
|
||||
|
||||
raise ValueError('handle or domain not specified')
|
||||
row = self.fetch('ban', handle=handle, domain=domain)
|
||||
self.cache.ban.store(cache_key, row)
|
||||
return row
|
||||
|
||||
|
||||
def cmd_config(self, key):
|
||||
|
|
|
@ -78,14 +78,14 @@ class AuthCheck(MiddlewareBase):
|
|||
logging.warning('Actor data is a db row:', actor)
|
||||
return response.text(f'An unknown error happened', status=500)
|
||||
|
||||
if not request.instance and data.get('type', '').lower() != 'follow':
|
||||
return response.text(f'Follow the relay first', status=401)
|
||||
|
||||
validated = verify_request(request, request.actor)
|
||||
|
||||
if not validated:
|
||||
logging.debug(f'Not validated: {actor}')
|
||||
return response.text(f'Failed signature check', status=401)
|
||||
|
||||
if not request.instance and data and data.type.lower() != 'follow':
|
||||
return response.text(f'Follow the relay first', status=401)
|
||||
|
||||
if any(map(request.path.startswith, auth_paths)) and not request.user:
|
||||
return response.redir('/login')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import asyncio
|
||||
import asyncio, json
|
||||
|
||||
from izzylib import DotDict, logging
|
||||
from izzylib.http_server import View
|
||||
|
@ -135,11 +135,15 @@ class UnciaActor(View):
|
|||
|
||||
processor = ProcessData(request, response, request.data.json)
|
||||
|
||||
if not processor.valid_type():
|
||||
return response.json({'error': f'Message type unhandled: {processor.type}'}, status=401)
|
||||
if processor.valid_type():
|
||||
loop = asyncio.get_running_loop()
|
||||
loop.create_task(processor())
|
||||
|
||||
loop = asyncio.get_running_loop()
|
||||
loop.create_task(processor())
|
||||
else:
|
||||
logging.verbose('Message type not handled:', processor.type)
|
||||
logging.debug(f'Headers: {json.dumps(request.headers)}')
|
||||
logging.debug(f'Body: {json.dumps(request.body)}')
|
||||
#return response.json({'error': f'Message type unhandled: {processor.type}'}, status=401)
|
||||
|
||||
return response.text('UvU', status=202)
|
||||
|
||||
|
|
Loading…
Reference in a new issue