Skip to content

Commit 0e571e1

Browse files
committed
Merge branch 'next' into beta
2 parents 20331b5 + 59783da commit 0e571e1

9 files changed

+111
-3
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [2.12.2](https://github.com/ReliefApplications/ems-backend/compare/v2.12.1...v2.12.2) (2025-02-20)
2+
3+
4+
### Bug Fixes
5+
6+
* allow files to be attached to emails ([#1191](https://github.com/ReliefApplications/ems-backend/issues/1191)) ([49d91cc](https://github.com/ReliefApplications/ems-backend/commit/49d91cc39db11a2c04a0278f5f515bc49c250c3f)), closes [AB#107812](https://github.com/AB/issues/107812)
7+
18
## [2.12.1](https://github.com/ReliefApplications/ems-backend/compare/v2.12.0...v2.12.1) (2025-02-15)
29

310

CHANGELOG/CHANGELOG_next.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [2.12.2-rc.1](https://github.com/ReliefApplications/ems-backend/compare/v2.12.1...v2.12.2-rc.1) (2025-02-19)
2+
3+
4+
### Bug Fixes
5+
6+
* allow files to be attached to emails ([#1191](https://github.com/ReliefApplications/ems-backend/issues/1191)) ([49d91cc](https://github.com/ReliefApplications/ems-backend/commit/49d91cc39db11a2c04a0278f5f515bc49c250c3f)), closes [AB#107812](https://github.com/AB/issues/107812)
7+
18
# [2.12.0-rc.3](https://github.com/ReliefApplications/ems-backend/compare/v2.12.0-rc.2...v2.12.0-rc.3) (2025-02-14)
29

310

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ems-backend",
3-
"version": "2.12.1",
3+
"version": "2.12.2",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

src/models/emailNotification.model.ts

+47
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@ export interface Dataset {
4444
};
4545
}
4646

47+
/** Interface File */
48+
export interface EmailNotificationFile {
49+
occurrence?: {
50+
id: string;
51+
name?: string;
52+
};
53+
driveId: string;
54+
itemId: string;
55+
fileName: string;
56+
clamAV?: string;
57+
fileFormat?: string;
58+
versionName?: string;
59+
fileSize: string;
60+
documentType?: any[];
61+
documentCategory?: any[];
62+
createdDate?: string;
63+
modifiedDate?: string;
64+
}
65+
66+
/** Model for email File attachement response */
67+
export interface EmailNotificationAttachment {
68+
sendAsAttachment: boolean;
69+
files?: EmailNotificationFile[];
70+
}
4771
/** custom notification documents interface declaration */
4872
export interface EmailNotification extends Document {
4973
kind: 'EmailNotification';
@@ -67,6 +91,7 @@ export interface EmailNotification extends Document {
6791
modifiedAt?: Date;
6892
isDraft?: boolean;
6993
draftStepper?: number;
94+
attachments?: EmailNotificationAttachment;
7095
}
7196

7297
/** Mongoose email notification schema declaration */
@@ -164,6 +189,28 @@ export const emailNotificationSchema = new Schema<EmailNotification>(
164189
draftStepper: {
165190
type: Number,
166191
},
192+
attachments: {
193+
sendAsAttachment: { type: Boolean, default: false },
194+
files: [
195+
{
196+
occurrence: {
197+
id: { type: String },
198+
name: { type: String },
199+
},
200+
driveId: { type: String, required: true },
201+
itemId: { type: String, required: true },
202+
fileName: { type: String, required: true },
203+
clamAV: { type: String },
204+
fileFormat: { type: String },
205+
versionName: { type: String },
206+
fileSize: { type: String, required: true },
207+
documentType: [{ type: mongoose.Schema.Types.Mixed }],
208+
documentCategory: [{ type: mongoose.Schema.Types.Mixed }],
209+
createdDate: { type: String },
210+
modifiedDate: { type: String },
211+
},
212+
],
213+
},
167214
},
168215
{
169216
timestamps: { createdAt: 'createdAt', updatedAt: 'modifiedAt' },

src/schema/inputs/emailNotification.input.ts

+44
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { EmailNotificationAttachment } from '@models';
12
import {
23
GraphQLInputObjectType,
34
GraphQLString,
@@ -28,6 +29,7 @@ export type EmailNotificationArgs = {
2829
isDeleted: number;
2930
isDraft: boolean;
3031
draftStepper: number;
32+
attachments: EmailNotificationAttachment;
3133
};
3234

3335
/**
@@ -65,6 +67,47 @@ export const DatasetInputType = new GraphQLInputObjectType({
6567
}),
6668
});
6769

70+
/**
71+
* Input type for email notification file details.
72+
*/
73+
export const EmailNotificationFileInputType = new GraphQLInputObjectType({
74+
name: 'EmailNotificationFileInputType',
75+
fields: () => ({
76+
occurrence: {
77+
type: new GraphQLInputObjectType({
78+
name: 'OccurrenceInputType',
79+
fields: {
80+
id: { type: new GraphQLNonNull(GraphQLString) },
81+
name: { type: GraphQLString },
82+
},
83+
}),
84+
},
85+
_id: { type: GraphQLID },
86+
driveId: { type: new GraphQLNonNull(GraphQLString) },
87+
itemId: { type: new GraphQLNonNull(GraphQLString) },
88+
fileName: { type: new GraphQLNonNull(GraphQLString) },
89+
clamAV: { type: GraphQLString },
90+
fileFormat: { type: GraphQLString },
91+
versionName: { type: GraphQLString },
92+
fileSize: { type: new GraphQLNonNull(GraphQLString) },
93+
documentType: { type: new GraphQLList(GraphQLJSON) },
94+
documentCategory: { type: new GraphQLList(GraphQLJSON) },
95+
createdDate: { type: GraphQLString },
96+
modifiedDate: { type: GraphQLString },
97+
}),
98+
});
99+
100+
/**
101+
* Input type for email notification attachment details.
102+
*/
103+
export const EmailNotificationAttachmentInputType = new GraphQLInputObjectType({
104+
name: 'EmailNotificationAttachmentInputType',
105+
fields: () => ({
106+
sendAsAttachment: { type: GraphQLBoolean },
107+
files: { type: new GraphQLList(EmailNotificationFileInputType) },
108+
}),
109+
});
110+
68111
/** GraphQL custom notification query input type definition */
69112
// eslint-disable-next-line @typescript-eslint/naming-convention
70113
export const EmailNotificationInputType = new GraphQLInputObjectType({
@@ -88,5 +131,6 @@ export const EmailNotificationInputType = new GraphQLInputObjectType({
88131
isDeleted: { type: GraphQLInt },
89132
isDraft: { type: GraphQLBoolean },
90133
draftStepper: { type: GraphQLInt },
134+
attachments: { type: EmailNotificationAttachmentInputType },
91135
}),
92136
});

src/schema/mutation/addEmailNotification.mutation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default {
8787
lastExecutionStatus: args.notification.lastExecutionStatus,
8888
isDraft: args.notification.isDraft,
8989
draftStepper: args.notification.draftStepper,
90+
attachments: args.notification.attachments,
9091
};
9192

9293
// Check permission to edit an email notification

src/schema/mutation/editEmailNotification.mutation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export default {
115115
isDeleted: args.notification.isDeleted,
116116
isDraft: args.notification.isDraft,
117117
draftStepper: args.notification.draftStepper,
118+
attachments: args.notification.attachments,
118119
};
119120

120121
// Check permission to edit an email notification

src/schema/types/emailNotification.type.ts

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export const EmailNotificationType = new GraphQLObjectType({
8585
isDeleted: { type: GraphQLInt },
8686
isDraft: { type: GraphQLBoolean },
8787
draftStepper: { type: GraphQLInt },
88+
attachments: { type: GraphQLJSON },
8889
}),
8990
});
9091

0 commit comments

Comments
 (0)