This commit is contained in:
retoor 2025-05-13 23:33:24 +02:00
parent 0ea0cd96db
commit af1cf4f5ae

View File

@ -8,7 +8,7 @@ from snek.system.view import BaseView
import aiofiles import aiofiles
from aiohttp import web from aiohttp import web
import pathlib import pathlib
import urllib.parse
class ChannelAttachmentView(BaseView): class ChannelAttachmentView(BaseView):
async def get(self): async def get(self):
@ -116,10 +116,16 @@ class ChannelAttachmentView(BaseView):
while chunk := await field.read_chunk(): while chunk := await field.read_chunk():
await f.write(chunk) await f.write(chunk)
attachment_records = []
for attachment in attachments:
attachment_record = attachment.record
attachment_record['relative_url'] = urllib.parse.quote(attachment_record['relative_url'])
attachment_records.append(attachment_record)
return web.json_response( return web.json_response(
{ {
"message": "Files uploaded successfully", "message": "Files uploaded successfully",
"files": [attachment.record for attachment in attachments], "files": attachment_records,
"channel_uid": channel_uid, "channel_uid": channel_uid,
} }
) )