@oneuptime/common 8.0.5580 → 8.0.5581
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/Models/DatabaseModels/AlertInternalNote.ts +58 -1
- package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.ts +1 -0
- package/Models/DatabaseModels/File.ts +1 -1
- package/Models/DatabaseModels/IncidentInternalNote.ts +58 -1
- package/Models/DatabaseModels/IncidentPublicNote.ts +58 -1
- package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.ts +58 -1
- package/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts +58 -1
- package/Models/DatabaseModels/StatusPageAnnouncement.ts +49 -0
- package/Server/API/AlertInternalNoteAPI.ts +96 -0
- package/Server/API/IncidentInternalNoteAPI.ts +96 -0
- package/Server/API/IncidentPublicNoteAPI.ts +96 -0
- package/Server/API/ScheduledMaintenanceInternalNoteAPI.ts +100 -0
- package/Server/API/ScheduledMaintenancePublicNoteAPI.ts +100 -0
- package/Server/API/StatusPageAPI.ts +585 -59
- package/Server/API/StatusPageAnnouncementAPI.ts +98 -0
- package/Server/API/UserAPI.ts +95 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.ts +79 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.ts +81 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1763480947474-MigrationName.ts +79 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
- package/Server/Middleware/ProjectAuthorization.ts +3 -1
- package/Server/Services/AlertInternalNoteService.ts +75 -2
- package/Server/Services/IncidentInternalNoteService.ts +76 -2
- package/Server/Services/IncidentPublicNoteService.ts +76 -2
- package/Server/Services/ScheduledMaintenanceInternalNoteService.ts +76 -2
- package/Server/Services/ScheduledMaintenancePublicNoteService.ts +76 -2
- package/Server/Services/ScheduledMaintenanceService.ts +10 -7
- package/Server/Services/StatusPagePrivateUserService.ts +10 -7
- package/Server/Services/StatusPageService.ts +12 -7
- package/Server/Services/StatusPageSubscriberService.ts +19 -13
- package/Server/Utils/FileAttachmentMarkdownUtil.ts +98 -0
- package/Server/Utils/Response.ts +13 -0
- package/Types/File/MimeType.ts +18 -0
- package/UI/Components/AttachmentList/EventAttachmentList.tsx +121 -0
- package/UI/Components/EventItem/EventItem.tsx +22 -0
- package/UI/Components/Feed/FeedItem.tsx +9 -16
- package/UI/Components/FilePicker/FilePicker.tsx +441 -145
- package/UI/Components/Forms/Fields/FormField.tsx +32 -15
- package/UI/Components/Forms/FormSummary.tsx +168 -1
- package/UI/Components/Forms/ModelForm.tsx +46 -24
- package/UI/Components/Forms/Types/FormFieldSchemaType.ts +1 -0
- package/UI/Components/Icon/Icon.tsx +1 -1
- package/UI/Utils/API/RequestOptions.ts +2 -0
- package/UI/Utils/ModelAPI/ModelAPI.ts +18 -0
- package/UI/Utils/User.ts +8 -0
- package/Utils/API.ts +11 -1
- package/build/dist/Models/DatabaseModels/AlertInternalNote.js +49 -1
- package/build/dist/Models/DatabaseModels/AlertInternalNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js +1 -0
- package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js.map +1 -1
- package/build/dist/Models/DatabaseModels/File.js +1 -1
- package/build/dist/Models/DatabaseModels/File.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentInternalNote.js +49 -1
- package/build/dist/Models/DatabaseModels/IncidentInternalNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentPublicNote.js +49 -1
- package/build/dist/Models/DatabaseModels/IncidentPublicNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +49 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +49 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js +48 -0
- package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js.map +1 -1
- package/build/dist/Server/API/AlertInternalNoteAPI.js +68 -0
- package/build/dist/Server/API/AlertInternalNoteAPI.js.map +1 -0
- package/build/dist/Server/API/IncidentInternalNoteAPI.js +68 -0
- package/build/dist/Server/API/IncidentInternalNoteAPI.js.map +1 -0
- package/build/dist/Server/API/IncidentPublicNoteAPI.js +68 -0
- package/build/dist/Server/API/IncidentPublicNoteAPI.js.map +1 -0
- package/build/dist/Server/API/ScheduledMaintenanceInternalNoteAPI.js +68 -0
- package/build/dist/Server/API/ScheduledMaintenanceInternalNoteAPI.js.map +1 -0
- package/build/dist/Server/API/ScheduledMaintenancePublicNoteAPI.js +68 -0
- package/build/dist/Server/API/ScheduledMaintenancePublicNoteAPI.js.map +1 -0
- package/build/dist/Server/API/StatusPageAPI.js +488 -85
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageAnnouncementAPI.js +68 -0
- package/build/dist/Server/API/StatusPageAnnouncementAPI.js.map +1 -0
- package/build/dist/Server/API/UserAPI.js +66 -0
- package/build/dist/Server/API/UserAPI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.js +34 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.js +34 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763480947474-MigrationName.js +34 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763480947474-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js +4 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
- package/build/dist/Server/Services/AlertInternalNoteService.js +54 -2
- package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentInternalNoteService.js +54 -2
- package/build/dist/Server/Services/IncidentInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentPublicNoteService.js +54 -2
- package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js +54 -2
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +54 -2
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +6 -5
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/StatusPagePrivateUserService.js +6 -4
- package/build/dist/Server/Services/StatusPagePrivateUserService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageService.js +7 -4
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberService.js +11 -7
- package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
- package/build/dist/Server/Utils/FileAttachmentMarkdownUtil.js +67 -0
- package/build/dist/Server/Utils/FileAttachmentMarkdownUtil.js.map +1 -0
- package/build/dist/Server/Utils/Response.js +8 -0
- package/build/dist/Server/Utils/Response.js.map +1 -1
- package/build/dist/Types/File/MimeType.js +18 -0
- package/build/dist/Types/File/MimeType.js.map +1 -1
- package/build/dist/UI/Components/AttachmentList/EventAttachmentList.js +42 -0
- package/build/dist/UI/Components/AttachmentList/EventAttachmentList.js.map +1 -0
- package/build/dist/UI/Components/EventItem/EventItem.js +5 -1
- package/build/dist/UI/Components/EventItem/EventItem.js.map +1 -1
- package/build/dist/UI/Components/Feed/FeedItem.js +6 -4
- package/build/dist/UI/Components/Feed/FeedItem.js.map +1 -1
- package/build/dist/UI/Components/FilePicker/FilePicker.js +262 -77
- package/build/dist/UI/Components/FilePicker/FilePicker.js.map +1 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js +24 -12
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/Forms/FormSummary.js +77 -1
- package/build/dist/UI/Components/Forms/FormSummary.js.map +1 -1
- package/build/dist/UI/Components/Forms/ModelForm.js +32 -18
- package/build/dist/UI/Components/Forms/ModelForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js +1 -0
- package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +1 -1
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +30 -45
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/User.js +7 -0
- package/build/dist/UI/Utils/User.js.map +1 -1
- package/build/dist/Utils/API.js +3 -0
- package/build/dist/Utils/API.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import IncidentPublicNote from "../../Models/DatabaseModels/IncidentPublicNote";
|
|
2
|
+
import File from "../../Models/DatabaseModels/File";
|
|
3
|
+
import NotFoundException from "../../Types/Exception/NotFoundException";
|
|
4
|
+
import ObjectID from "../../Types/ObjectID";
|
|
5
|
+
import IncidentPublicNoteService, {
|
|
6
|
+
Service as IncidentPublicNoteServiceType,
|
|
7
|
+
} from "../Services/IncidentPublicNoteService";
|
|
8
|
+
import Response from "../Utils/Response";
|
|
9
|
+
import BaseAPI from "./BaseAPI";
|
|
10
|
+
import UserMiddleware from "../Middleware/UserAuthorization";
|
|
11
|
+
import {
|
|
12
|
+
ExpressRequest,
|
|
13
|
+
ExpressResponse,
|
|
14
|
+
NextFunction,
|
|
15
|
+
} from "../Utils/Express";
|
|
16
|
+
import CommonAPI from "./CommonAPI";
|
|
17
|
+
import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
18
|
+
|
|
19
|
+
export default class IncidentPublicNoteAPI extends BaseAPI<
|
|
20
|
+
IncidentPublicNote,
|
|
21
|
+
IncidentPublicNoteServiceType
|
|
22
|
+
> {
|
|
23
|
+
public constructor() {
|
|
24
|
+
super(IncidentPublicNote, IncidentPublicNoteService);
|
|
25
|
+
|
|
26
|
+
this.router.get(
|
|
27
|
+
`${new this.entityType().getCrudApiPath()?.toString()}/attachment/:projectId/:noteId/:fileId`,
|
|
28
|
+
UserMiddleware.getUserMiddleware,
|
|
29
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
30
|
+
try {
|
|
31
|
+
await this.getAttachment(req, res);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
next(err);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private async getAttachment(
|
|
40
|
+
req: ExpressRequest,
|
|
41
|
+
res: ExpressResponse,
|
|
42
|
+
): Promise<void> {
|
|
43
|
+
const noteIdParam: string | undefined = req.params["noteId"];
|
|
44
|
+
const fileIdParam: string | undefined = req.params["fileId"];
|
|
45
|
+
|
|
46
|
+
if (!noteIdParam || !fileIdParam) {
|
|
47
|
+
throw new NotFoundException("Attachment not found");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let noteId: ObjectID;
|
|
51
|
+
let fileId: ObjectID;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
noteId = new ObjectID(noteIdParam);
|
|
55
|
+
fileId = new ObjectID(fileIdParam);
|
|
56
|
+
} catch {
|
|
57
|
+
throw new NotFoundException("Attachment not found");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const props: DatabaseCommonInteractionProps =
|
|
61
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
62
|
+
|
|
63
|
+
const note: IncidentPublicNote | null = await this.service.findOneBy({
|
|
64
|
+
query: {
|
|
65
|
+
_id: noteId,
|
|
66
|
+
},
|
|
67
|
+
select: {
|
|
68
|
+
attachments: {
|
|
69
|
+
_id: true,
|
|
70
|
+
file: true,
|
|
71
|
+
fileType: true,
|
|
72
|
+
name: true,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
props,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const attachment: File | undefined = note?.attachments?.find(
|
|
79
|
+
(file: File) => {
|
|
80
|
+
const attachmentId: string | null = file._id
|
|
81
|
+
? file._id.toString()
|
|
82
|
+
: file.id
|
|
83
|
+
? file.id.toString()
|
|
84
|
+
: null;
|
|
85
|
+
return attachmentId === fileId.toString();
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (!attachment || !attachment.file) {
|
|
90
|
+
throw new NotFoundException("Attachment not found");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Response.setNoCacheHeaders(res);
|
|
94
|
+
return Response.sendFileResponse(req, res, attachment);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import ScheduledMaintenanceInternalNote from "../../Models/DatabaseModels/ScheduledMaintenanceInternalNote";
|
|
2
|
+
import File from "../../Models/DatabaseModels/File";
|
|
3
|
+
import NotFoundException from "../../Types/Exception/NotFoundException";
|
|
4
|
+
import ObjectID from "../../Types/ObjectID";
|
|
5
|
+
import ScheduledMaintenanceInternalNoteService, {
|
|
6
|
+
Service as ScheduledMaintenanceInternalNoteServiceType,
|
|
7
|
+
} from "../Services/ScheduledMaintenanceInternalNoteService";
|
|
8
|
+
import Response from "../Utils/Response";
|
|
9
|
+
import BaseAPI from "./BaseAPI";
|
|
10
|
+
import UserMiddleware from "../Middleware/UserAuthorization";
|
|
11
|
+
import CommonAPI from "./CommonAPI";
|
|
12
|
+
import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
13
|
+
import {
|
|
14
|
+
ExpressRequest,
|
|
15
|
+
ExpressResponse,
|
|
16
|
+
NextFunction,
|
|
17
|
+
} from "../Utils/Express";
|
|
18
|
+
|
|
19
|
+
export default class ScheduledMaintenanceInternalNoteAPI extends BaseAPI<
|
|
20
|
+
ScheduledMaintenanceInternalNote,
|
|
21
|
+
ScheduledMaintenanceInternalNoteServiceType
|
|
22
|
+
> {
|
|
23
|
+
public constructor() {
|
|
24
|
+
super(
|
|
25
|
+
ScheduledMaintenanceInternalNote,
|
|
26
|
+
ScheduledMaintenanceInternalNoteService,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
this.router.get(
|
|
30
|
+
`${new this.entityType().getCrudApiPath()?.toString()}/attachment/:projectId/:noteId/:fileId`,
|
|
31
|
+
UserMiddleware.getUserMiddleware,
|
|
32
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
33
|
+
try {
|
|
34
|
+
await this.getAttachment(req, res);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
next(err);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private async getAttachment(
|
|
43
|
+
req: ExpressRequest,
|
|
44
|
+
res: ExpressResponse,
|
|
45
|
+
): Promise<void> {
|
|
46
|
+
const noteIdParam: string | undefined = req.params["noteId"];
|
|
47
|
+
const fileIdParam: string | undefined = req.params["fileId"];
|
|
48
|
+
|
|
49
|
+
if (!noteIdParam || !fileIdParam) {
|
|
50
|
+
throw new NotFoundException("Attachment not found");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let noteId: ObjectID;
|
|
54
|
+
let fileId: ObjectID;
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
noteId = new ObjectID(noteIdParam);
|
|
58
|
+
fileId = new ObjectID(fileIdParam);
|
|
59
|
+
} catch {
|
|
60
|
+
throw new NotFoundException("Attachment not found");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const props: DatabaseCommonInteractionProps =
|
|
64
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
65
|
+
|
|
66
|
+
const note: ScheduledMaintenanceInternalNote | null =
|
|
67
|
+
await this.service.findOneBy({
|
|
68
|
+
query: {
|
|
69
|
+
_id: noteId,
|
|
70
|
+
},
|
|
71
|
+
select: {
|
|
72
|
+
attachments: {
|
|
73
|
+
_id: true,
|
|
74
|
+
file: true,
|
|
75
|
+
fileType: true,
|
|
76
|
+
name: true,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
props,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const attachment: File | undefined = note?.attachments?.find(
|
|
83
|
+
(file: File) => {
|
|
84
|
+
const attachmentId: string | null = file._id
|
|
85
|
+
? file._id.toString()
|
|
86
|
+
: file.id
|
|
87
|
+
? file.id.toString()
|
|
88
|
+
: null;
|
|
89
|
+
return attachmentId === fileId.toString();
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
if (!attachment || !attachment.file) {
|
|
94
|
+
throw new NotFoundException("Attachment not found");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Response.setNoCacheHeaders(res);
|
|
98
|
+
return Response.sendFileResponse(req, res, attachment);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import ScheduledMaintenancePublicNote from "../../Models/DatabaseModels/ScheduledMaintenancePublicNote";
|
|
2
|
+
import File from "../../Models/DatabaseModels/File";
|
|
3
|
+
import NotFoundException from "../../Types/Exception/NotFoundException";
|
|
4
|
+
import ObjectID from "../../Types/ObjectID";
|
|
5
|
+
import ScheduledMaintenancePublicNoteService, {
|
|
6
|
+
Service as ScheduledMaintenancePublicNoteServiceType,
|
|
7
|
+
} from "../Services/ScheduledMaintenancePublicNoteService";
|
|
8
|
+
import Response from "../Utils/Response";
|
|
9
|
+
import BaseAPI from "./BaseAPI";
|
|
10
|
+
import UserMiddleware from "../Middleware/UserAuthorization";
|
|
11
|
+
import {
|
|
12
|
+
ExpressRequest,
|
|
13
|
+
ExpressResponse,
|
|
14
|
+
NextFunction,
|
|
15
|
+
} from "../Utils/Express";
|
|
16
|
+
import CommonAPI from "./CommonAPI";
|
|
17
|
+
import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
18
|
+
|
|
19
|
+
export default class ScheduledMaintenancePublicNoteAPI extends BaseAPI<
|
|
20
|
+
ScheduledMaintenancePublicNote,
|
|
21
|
+
ScheduledMaintenancePublicNoteServiceType
|
|
22
|
+
> {
|
|
23
|
+
public constructor() {
|
|
24
|
+
super(
|
|
25
|
+
ScheduledMaintenancePublicNote,
|
|
26
|
+
ScheduledMaintenancePublicNoteService,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
this.router.get(
|
|
30
|
+
`${new this.entityType().getCrudApiPath()?.toString()}/attachment/:projectId/:noteId/:fileId`,
|
|
31
|
+
UserMiddleware.getUserMiddleware,
|
|
32
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
33
|
+
try {
|
|
34
|
+
await this.getAttachment(req, res);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
next(err);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private async getAttachment(
|
|
43
|
+
req: ExpressRequest,
|
|
44
|
+
res: ExpressResponse,
|
|
45
|
+
): Promise<void> {
|
|
46
|
+
const noteIdParam: string | undefined = req.params["noteId"];
|
|
47
|
+
const fileIdParam: string | undefined = req.params["fileId"];
|
|
48
|
+
|
|
49
|
+
if (!noteIdParam || !fileIdParam) {
|
|
50
|
+
throw new NotFoundException("Attachment not found");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let noteId: ObjectID;
|
|
54
|
+
let fileId: ObjectID;
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
noteId = new ObjectID(noteIdParam);
|
|
58
|
+
fileId = new ObjectID(fileIdParam);
|
|
59
|
+
} catch {
|
|
60
|
+
throw new NotFoundException("Attachment not found");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const props: DatabaseCommonInteractionProps =
|
|
64
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
65
|
+
|
|
66
|
+
const note: ScheduledMaintenancePublicNote | null =
|
|
67
|
+
await this.service.findOneBy({
|
|
68
|
+
query: {
|
|
69
|
+
_id: noteId,
|
|
70
|
+
},
|
|
71
|
+
select: {
|
|
72
|
+
attachments: {
|
|
73
|
+
_id: true,
|
|
74
|
+
file: true,
|
|
75
|
+
fileType: true,
|
|
76
|
+
name: true,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
props,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const attachment: File | undefined = note?.attachments?.find(
|
|
83
|
+
(file: File) => {
|
|
84
|
+
const attachmentId: string | null = file._id
|
|
85
|
+
? file._id.toString()
|
|
86
|
+
: file.id
|
|
87
|
+
? file.id.toString()
|
|
88
|
+
: null;
|
|
89
|
+
return attachmentId === fileId.toString();
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
if (!attachment || !attachment.file) {
|
|
94
|
+
throw new NotFoundException("Attachment not found");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Response.setNoCacheHeaders(res);
|
|
98
|
+
return Response.sendFileResponse(req, res, attachment);
|
|
99
|
+
}
|
|
100
|
+
}
|