mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-23 15:08:00 +00:00
fix a few api endpoints
This commit is contained in:
parent
bd4790212e
commit
101c668173
|
@ -284,13 +284,16 @@ class DomainBanSingle(View):
|
|||
if not conn.get_domain_ban(domain):
|
||||
return Response.new_error(404, 'Domain not banned', 'json')
|
||||
|
||||
data = await self.get_api_data(['domain'], ['note', 'reason'])
|
||||
data = await self.get_api_data([], ['note', 'reason'])
|
||||
|
||||
if isinstance(data, Response):
|
||||
return data
|
||||
|
||||
if not any([data.get('note'), data.get('reason')]):
|
||||
return Response.new_error(400, 'Must include note and/or reason parameters', 'json')
|
||||
|
||||
with conn.transaction():
|
||||
ban = conn.update_domain_ban(**data)
|
||||
ban = conn.update_domain_ban(domain, **data)
|
||||
|
||||
return Response.new(ban, ctype = 'json')
|
||||
|
||||
|
@ -336,27 +339,30 @@ class SoftwareBanSingle(View):
|
|||
return Response.new(ban, ctype = 'json')
|
||||
|
||||
|
||||
async def post(self, request: Request, conn: Connection, name: str) -> Response:
|
||||
async def patch(self, request: Request, conn: Connection, name: str) -> Response:
|
||||
if not conn.get_software_ban(name):
|
||||
return Response.new_error(404, 'Software not banned', 'json')
|
||||
|
||||
data = await self.get_api_data(['name'], ['note', 'reason'])
|
||||
data = await self.get_api_data([], ['note', 'reason'])
|
||||
|
||||
if isinstance(data, Response):
|
||||
return data
|
||||
|
||||
if not any([data.get('note'), data.get('reason')]):
|
||||
return Response.new_error(400, 'Must include note and/or reason parameters', 'json')
|
||||
|
||||
with conn.transaction():
|
||||
ban = conn.update_software_ban(**data)
|
||||
ban = conn.update_software_ban(name, **data)
|
||||
|
||||
return Response.new(ban, ctype = 'json')
|
||||
|
||||
|
||||
async def delete(self, request: Request, conn: Connection, domain: str) -> Response:
|
||||
if not conn.get_software_ban(domain):
|
||||
async def delete(self, request: Request, conn: Connection, name: str) -> Response:
|
||||
if not conn.get_software_ban(name):
|
||||
return Response.new_error(404, 'Software not banned', 'json')
|
||||
|
||||
with conn.transaction():
|
||||
conn.del_software_ban(domain)
|
||||
conn.del_software_ban(name)
|
||||
|
||||
return Response.new({'message': 'Unbanned software'}, ctype = 'json')
|
||||
|
||||
|
|
Loading…
Reference in a new issue