Merge branch 'feature/allowing-download-for-shared' into develop

This commit is contained in:
2025-09-08 13:58:35 +02:00
5 changed files with 54 additions and 2 deletions

19
.mcp copy.json Normal file
View File

@@ -0,0 +1,19 @@
{
"mcpServers": {
"serena": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/oraios/serena",
"serena",
"start-mcp-server",
"--enable-web-dashboard",
"false"
]
},
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp"
}
}
}

View File

@@ -0,0 +1,6 @@
import { NotFoundPage } from '@/app/ui/NotFoundPage';
const ShareAttachmentNotFound = () =>
<NotFoundPage title="404 File Not Found" description="Could not find the requested shared attachment." />;
export default ShareAttachmentNotFound;

View File

@@ -0,0 +1,27 @@
import { fetchBillById } from '@/app/lib/actions/billActions';
import { notFound } from 'next/navigation';
export async function GET(request: Request, { params:{ id } }: { params: { id:string } }) {
const [locationID, billID] = id.split('-');
const [location, bill] = await fetchBillById(locationID, billID, true) ?? [];
if(!bill?.attachment) {
notFound();
}
// convert fileContentsBase64 from Base64 string to binary string
const fileContentsBuffer = Buffer.from(bill.attachment.fileContentsBase64, 'base64');
// convert fileContentsBuffer to format that can be sent to the client
const fileContents = new Uint8Array(fileContentsBuffer);
return new Response(fileContents, {
status: 200,
headers: {
'Content-Type': "application/octet-stream",
'Content-Disposition': `attachment; filename="${bill.attachment.fileName}"`,
'Last-Modified': `${bill.attachment.fileLastModified}`
}
});
}

View File

@@ -63,7 +63,7 @@ export const ViewBillCard:FC<ViewBillCardProps> = ({ location, bill }) => {
attachment ? attachment ?
<span className="textarea textarea-bordered max-w-[400px] w-full grow"> <span className="textarea textarea-bordered max-w-[400px] w-full grow">
<p className="font-bold uppercase">{t("attachment")}</p> <p className="font-bold uppercase">{t("attachment")}</p>
<Link href={`/attachment/${locationID}-${billID}/`} target="_blank" className='text-center w-full max-w-[20em] text-nowrap truncate inline-block mt-2'> <Link href={`/share/attachment/${locationID}-${billID}/`} target="_blank" className='text-center w-full max-w-[20em] text-nowrap truncate inline-block mt-2'>
<DocumentIcon className="h-[1em] w-[1em] text-2xl inline-block mr-1" /> <DocumentIcon className="h-[1em] w-[1em] text-2xl inline-block mr-1" />
{decodeURIComponent(attachment.fileName)} {decodeURIComponent(attachment.fileName)}
</Link> </Link>

View File

@@ -10,7 +10,7 @@ import { locales, defaultLocale } from '@/app/i18n';
import { Session } from 'next-auth'; import { Session } from 'next-auth';
// http://localhost:3000/share/location/675c41b227d0df76a35f106e // http://localhost:3000/share/location/675c41b227d0df76a35f106e
const publicPages = ['/terms', '/policy', '/login', '/share/location/.*', '/share/bill/.*']; const publicPages = ['/terms', '/policy', '/login', '/share/location/.*', '/share/bill/.*', '/share/attachment/.*'];
const intlMiddleware = createIntlMiddleware({ const intlMiddleware = createIntlMiddleware({
locales, locales,