@studious-lms/server 1.1.24 → 1.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/fileUpload.d.ts +2 -2
- package/dist/lib/fileUpload.d.ts.map +1 -1
- package/dist/lib/fileUpload.js +76 -14
- package/dist/lib/googleCloudStorage.d.ts +7 -0
- package/dist/lib/googleCloudStorage.d.ts.map +1 -1
- package/dist/lib/googleCloudStorage.js +19 -0
- package/dist/lib/notificationHandler.d.ts +25 -0
- package/dist/lib/notificationHandler.d.ts.map +1 -0
- package/dist/lib/notificationHandler.js +28 -0
- package/dist/routers/_app.d.ts +818 -78
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/announcement.d.ts +290 -3
- package/dist/routers/announcement.d.ts.map +1 -1
- package/dist/routers/announcement.js +896 -10
- package/dist/routers/assignment.d.ts +70 -4
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +265 -131
- package/dist/routers/auth.js +1 -1
- package/dist/routers/file.d.ts +2 -0
- package/dist/routers/file.d.ts.map +1 -1
- package/dist/routers/file.js +9 -6
- package/dist/routers/labChat.d.ts.map +1 -1
- package/dist/routers/labChat.js +13 -5
- package/dist/routers/notifications.d.ts +8 -8
- package/dist/routers/section.d.ts +16 -0
- package/dist/routers/section.d.ts.map +1 -1
- package/dist/routers/section.js +139 -30
- package/dist/seedDatabase.d.ts +2 -2
- package/dist/seedDatabase.d.ts.map +1 -1
- package/dist/seedDatabase.js +2 -1
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +27 -2
- package/package.json +2 -2
- package/prisma/migrations/20251109122857_annuoncements_comments/migration.sql +30 -0
- package/prisma/migrations/20251109135555_reactions_announcements_comments/migration.sql +35 -0
- package/prisma/schema.prisma +50 -0
- package/src/lib/fileUpload.ts +79 -14
- package/src/lib/googleCloudStorage.ts +19 -0
- package/src/lib/notificationHandler.ts +36 -0
- package/src/routers/announcement.ts +1007 -10
- package/src/routers/assignment.ts +230 -82
- package/src/routers/auth.ts +1 -1
- package/src/routers/file.ts +10 -7
- package/src/routers/labChat.ts +15 -6
- package/src/routers/section.ts +158 -36
- package/src/seedDatabase.ts +2 -1
- package/src/utils/logger.ts +29 -2
- package/tests/setup.ts +3 -9
|
@@ -62,4 +62,23 @@ export async function deleteFile(filePath: string): Promise<void> {
|
|
|
62
62
|
message: 'Failed to delete file from storage',
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Checks if an object exists in Google Cloud Storage
|
|
69
|
+
* @param bucketName The name of the bucket (unused, uses default bucket)
|
|
70
|
+
* @param objectPath The path of the object to check
|
|
71
|
+
* @returns Promise<boolean> True if the object exists, false otherwise
|
|
72
|
+
*/
|
|
73
|
+
export async function objectExists(bucketName: string, objectPath: string): Promise<boolean> {
|
|
74
|
+
try {
|
|
75
|
+
const [exists] = await bucket.file(objectPath).exists();
|
|
76
|
+
return exists;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('Error checking if object exists in Google Cloud Storage:', error);
|
|
79
|
+
throw new TRPCError({
|
|
80
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
81
|
+
message: 'Failed to check object existence',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
65
84
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { prisma } from "./prisma.js";
|
|
2
|
+
|
|
3
|
+
interface notificationData {
|
|
4
|
+
title: string,
|
|
5
|
+
content: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export async function sendNotification(receiver: string, data: notificationData) {
|
|
9
|
+
const notification = await prisma.notification.create({
|
|
10
|
+
data: {
|
|
11
|
+
receiverId: receiver,
|
|
12
|
+
title: data.title,
|
|
13
|
+
content: data.content,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return notification;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function sendNotifications(receiverIds: Array<string>, data: notificationData) {
|
|
20
|
+
const notifications = await prisma.notification.createMany({
|
|
21
|
+
data: receiverIds.map(receiverId => ({
|
|
22
|
+
receiverId: receiverId,
|
|
23
|
+
title: data.title,
|
|
24
|
+
content: data.content,
|
|
25
|
+
})),
|
|
26
|
+
});
|
|
27
|
+
return notifications;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function markRead(id: string, read: boolean = true) {
|
|
31
|
+
const notification = await prisma.notification.update({
|
|
32
|
+
where: {id},
|
|
33
|
+
data: {read: read},
|
|
34
|
+
});
|
|
35
|
+
return notification;
|
|
36
|
+
}
|