mirror of
https://github.com/diced/zipline.git
synced 2025-12-12 07:40:45 -08:00
fix: #876
This commit is contained in:
@@ -4,6 +4,7 @@ import { verifyPassword } from '@/lib/crypto';
|
|||||||
import { datasource } from '@/lib/datasource';
|
import { datasource } from '@/lib/datasource';
|
||||||
import { prisma } from '@/lib/db';
|
import { prisma } from '@/lib/db';
|
||||||
import { log } from '@/lib/logger';
|
import { log } from '@/lib/logger';
|
||||||
|
import { canInteract } from '@/lib/role';
|
||||||
import { userMiddleware } from '@/server/middleware/user';
|
import { userMiddleware } from '@/server/middleware/user';
|
||||||
import fastifyPlugin from 'fastify-plugin';
|
import fastifyPlugin from 'fastify-plugin';
|
||||||
|
|
||||||
@@ -44,10 +45,16 @@ export default fastifyPlugin(
|
|||||||
const file = await prisma.file.findFirst({
|
const file = await prisma.file.findFirst({
|
||||||
where: {
|
where: {
|
||||||
id,
|
id,
|
||||||
userId: req.user.id,
|
},
|
||||||
|
include: {
|
||||||
|
User: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (file && file.userId !== req.user.id) {
|
||||||
|
if (!canInteract(req.user.role, file.User?.role)) return res.callNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
if (file?.deletesAt && file.deletesAt <= new Date()) {
|
if (file?.deletesAt && file.deletesAt <= new Date()) {
|
||||||
try {
|
try {
|
||||||
await datasource.delete(file.name);
|
await datasource.delete(file.name);
|
||||||
|
|||||||
Reference in New Issue
Block a user