mirror of https://github.com/renzynx/bliss.git
By works, I meant 'doesnt work'. Works now..
This commit is contained in:
parent
df578fe459
commit
8710305a4c
4
TODO.md
4
TODO.md
|
@ -1,12 +1,10 @@
|
|||
### Todo
|
||||
|
||||
- [ ] Make docker installation instructions.
|
||||
- [ ] Switch verification from postgres to redis database.
|
||||
- [ ] Add user creation for admins
|
||||
- [ ] Add user administration settings (create, ban, ...etc).
|
||||
- [ ] Fix embed customizer validation.
|
||||
- [ ] Add support for multiple domains.
|
||||
- [ ] Fix download link.
|
||||
|
||||
### In Progress
|
||||
|
||||
|
@ -15,4 +13,6 @@
|
|||
|
||||
### Done
|
||||
|
||||
- [x] Make docker installation instructions.
|
||||
- [x] Fix download link.
|
||||
- [x] Add embed customizer.
|
||||
|
|
|
@ -16,6 +16,11 @@ import { RootService } from "./root.service";
|
|||
export class RootController {
|
||||
constructor(private readonly rootService: RootService) {}
|
||||
|
||||
@Get()
|
||||
hello() {
|
||||
return "<pre>Hello World!</pre>";
|
||||
}
|
||||
|
||||
@Get("server-settings")
|
||||
check() {
|
||||
return readServerSettings();
|
||||
|
@ -30,9 +35,6 @@ export class RootController {
|
|||
@Get(":slug")
|
||||
@Render("index")
|
||||
file(@Param("slug") slug: string, @Request() req: ERequest) {
|
||||
if (!slug) {
|
||||
return "Hello World!";
|
||||
}
|
||||
return this.rootService.getFile(slug, req);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,14 +34,16 @@ export class RootService {
|
|||
.then((stats) => {
|
||||
res.setHeader("Accept-Ranges", "bytes");
|
||||
res.setHeader("Content-Length", stats.size);
|
||||
res.setHeader(
|
||||
"Content-Disposition",
|
||||
`'attachment'; filename=${fn.split("_").pop()}`
|
||||
);
|
||||
res.setHeader("Content-Disposition", `'attachment'; filename=${fn}`);
|
||||
createReadStream(join(uploadDir, fn)).pipe(res);
|
||||
})
|
||||
.catch(() => {
|
||||
throw new NotFoundException();
|
||||
.catch((err) => {
|
||||
if (err === "ENOENT") {
|
||||
throw new NotFoundException();
|
||||
} else {
|
||||
this.logger.error(err);
|
||||
throw new InternalServerErrorException();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,7 +52,7 @@ export class RootService {
|
|||
throw new NotFoundException();
|
||||
}
|
||||
const file = await this.prismaService.file.findUnique({
|
||||
where: { slug },
|
||||
where: { slug: slug.split(".").shift() },
|
||||
include: { user: { include: { embed_settings: true } } },
|
||||
});
|
||||
|
||||
|
@ -82,7 +84,7 @@ export class RootService {
|
|||
|
||||
return {
|
||||
oembed: `${baseUrl}/${slug}.json`,
|
||||
url: `${baseUrl}/${file.filename}`,
|
||||
url: `${baseUrl}/${slug}.${ext}`,
|
||||
title: file.user.embed_settings?.title,
|
||||
description: file.user.embed_settings?.description,
|
||||
color: file.user.embed_settings?.color ?? generateRandomHexColor(),
|
||||
|
|
|
@ -27,7 +27,7 @@ const PreviewCard: FC<{
|
|||
options?: (RefetchOptions & RefetchQueryFilters<TPageData>) | undefined
|
||||
) => Promise<QueryObserverResult<any, unknown>>;
|
||||
}> = ({ file, refetch }) => {
|
||||
const fileURL = `${API_URL}/${file.filename}`;
|
||||
const fileURL = `${API_URL}/${file.slug}.${file.filename.split('.').pop()}`;
|
||||
const deleteFile = useCallback(() => {
|
||||
return axios
|
||||
.get(`${API_URL}/delete/${file.id}`)
|
||||
|
@ -52,7 +52,6 @@ const PreviewCard: FC<{
|
|||
}, [file.id, refetch]);
|
||||
|
||||
return (
|
||||
// <Paper withBorder radius="md" sx={{ overflow: 'hidden' }}>
|
||||
<Box>
|
||||
<Stack
|
||||
spacing={0}
|
||||
|
@ -145,7 +144,13 @@ const PreviewCard: FC<{
|
|||
<Grid mx="sm" mt="lg" gutter="xs" grow>
|
||||
<Grid.Col span={4}>
|
||||
<Button
|
||||
onClick={() => window.open(`${API_URL}/d/${file.slug}`)}
|
||||
onClick={() =>
|
||||
window.open(
|
||||
`${API_URL}/d/${file.slug}.${file.filename
|
||||
.split('.')
|
||||
.pop()}`
|
||||
)
|
||||
}
|
||||
fullWidth
|
||||
variant="light"
|
||||
color="teal"
|
||||
|
@ -180,7 +185,6 @@ const PreviewCard: FC<{
|
|||
</Stack>
|
||||
</Stack>
|
||||
</Box>
|
||||
// </Paper>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue