@stamhoofd/models 2.3.0 → 2.4.0
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/src/factories/GroupFactory.d.ts.map +1 -1
- package/dist/src/factories/GroupFactory.js +5 -5
- package/dist/src/factories/GroupFactory.js.map +1 -1
- package/dist/src/helpers/EmailBuilder.d.ts +3 -2
- package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
- package/dist/src/helpers/EmailBuilder.js +29 -16
- package/dist/src/helpers/EmailBuilder.js.map +1 -1
- package/dist/src/helpers/GroupBuilder.d.ts.map +1 -1
- package/dist/src/helpers/GroupBuilder.js +0 -23
- package/dist/src/helpers/GroupBuilder.js.map +1 -1
- package/dist/src/migrations/1721050380-email-table.sql +24 -0
- package/dist/src/migrations/1721050381-email-recipients-table.sql +18 -0
- package/dist/src/migrations/1721342679-responsibility-groupId.sql +2 -0
- package/dist/src/migrations/1721342680-responsibility-groupId-foreign-key.sql +1 -0
- package/dist/src/migrations/1721400546-users-memberId.sql +3 -0
- package/dist/src/migrations/1721639159-membership-deleted-at.sql +2 -0
- package/dist/src/migrations/1721639160-membership-generated.sql +2 -0
- package/dist/src/migrations/1721841819-group-type.sql +2 -0
- package/dist/src/migrations/1722090482-events.sql +18 -0
- package/dist/src/models/DocumentTemplate.js +14 -14
- package/dist/src/models/DocumentTemplate.js.map +1 -1
- package/dist/src/models/Email.d.ts +41 -0
- package/dist/src/models/Email.d.ts.map +1 -0
- package/dist/src/models/Email.js +490 -0
- package/dist/src/models/Email.js.map +1 -0
- package/dist/src/models/EmailRecipient.d.ts +20 -0
- package/dist/src/models/EmailRecipient.d.ts.map +1 -0
- package/dist/src/models/EmailRecipient.js +95 -0
- package/dist/src/models/EmailRecipient.js.map +1 -0
- package/dist/src/models/EmailTemplate.d.ts +2 -1
- package/dist/src/models/EmailTemplate.d.ts.map +1 -1
- package/dist/src/models/EmailTemplate.js +4 -0
- package/dist/src/models/EmailTemplate.js.map +1 -1
- package/dist/src/models/Event.d.ts +19 -0
- package/dist/src/models/Event.d.ts.map +1 -0
- package/dist/src/models/Event.js +78 -0
- package/dist/src/models/Event.js.map +1 -0
- package/dist/src/models/Group.d.ts +2 -1
- package/dist/src/models/Group.d.ts.map +1 -1
- package/dist/src/models/Group.js +9 -22
- package/dist/src/models/Group.js.map +1 -1
- package/dist/src/models/Member.d.ts +1 -0
- package/dist/src/models/Member.d.ts.map +1 -1
- package/dist/src/models/Member.js +42 -11
- package/dist/src/models/Member.js.map +1 -1
- package/dist/src/models/MemberPlatformMembership.d.ts +7 -0
- package/dist/src/models/MemberPlatformMembership.d.ts.map +1 -1
- package/dist/src/models/MemberPlatformMembership.js +22 -0
- package/dist/src/models/MemberPlatformMembership.js.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.d.ts +3 -0
- package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -1
- package/dist/src/models/MemberResponsibilityRecord.js +8 -0
- package/dist/src/models/MemberResponsibilityRecord.js.map +1 -1
- package/dist/src/models/Organization.d.ts +8 -1
- package/dist/src/models/Organization.d.ts.map +1 -1
- package/dist/src/models/Organization.js +37 -9
- package/dist/src/models/Organization.js.map +1 -1
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts +1 -0
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/OrganizationRegistrationPeriod.js +7 -0
- package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -1
- package/dist/src/models/RegistrationPeriod.d.ts +1 -0
- package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
- package/dist/src/models/RegistrationPeriod.js +12 -0
- package/dist/src/models/RegistrationPeriod.js.map +1 -1
- package/dist/src/models/User.d.ts +2 -1
- package/dist/src/models/User.d.ts.map +1 -1
- package/dist/src/models/User.js +13 -3
- package/dist/src/models/User.js.map +1 -1
- package/dist/src/models/index.d.ts +3 -0
- package/dist/src/models/index.d.ts.map +1 -1
- package/dist/src/models/index.js +3 -0
- package/dist/src/models/index.js.map +1 -1
- package/package.json +2 -2
- package/src/factories/GroupFactory.ts +6 -6
- package/src/helpers/EmailBuilder.ts +33 -18
- package/src/helpers/GroupBuilder.ts +0 -23
- package/src/migrations/1721050380-email-table.sql +24 -0
- package/src/migrations/1721050381-email-recipients-table.sql +18 -0
- package/src/migrations/1721342679-responsibility-groupId.sql +2 -0
- package/src/migrations/1721342680-responsibility-groupId-foreign-key.sql +1 -0
- package/src/migrations/1721400546-users-memberId.sql +3 -0
- package/src/migrations/1721639159-membership-deleted-at.sql +2 -0
- package/src/migrations/1721639160-membership-generated.sql +2 -0
- package/src/migrations/1721841819-group-type.sql +2 -0
- package/src/migrations/1722090482-events.sql +18 -0
- package/src/models/DocumentTemplate.ts +2 -2
- package/src/models/Email.ts +556 -0
- package/src/models/EmailRecipient.ts +81 -0
- package/src/models/EmailTemplate.ts +5 -1
- package/src/models/Event.ts +71 -0
- package/src/models/Group.ts +10 -37
- package/src/models/Member.ts +60 -12
- package/src/models/MemberPlatformMembership.ts +21 -0
- package/src/models/MemberResponsibilityRecord.ts +7 -0
- package/src/models/Organization.ts +42 -9
- package/src/models/OrganizationRegistrationPeriod.ts +8 -0
- package/src/models/RegistrationPeriod.ts +14 -0
- package/src/models/User.ts +13 -3
- package/src/models/index.ts +3 -0
|
@@ -2,13 +2,14 @@ import { EmailAddress, EmailBuilder } from "@stamhoofd/email";
|
|
|
2
2
|
import { Recipient, Replacement } from "@stamhoofd/structures";
|
|
3
3
|
import { Formatter } from "@stamhoofd/utility";
|
|
4
4
|
|
|
5
|
-
import { Organization,
|
|
5
|
+
import { Organization, Platform, User } from "../models";
|
|
6
|
+
import { SimpleError } from "@simonbackx/simple-errors";
|
|
6
7
|
|
|
7
|
-
export async function getEmailBuilder(organization: Organization, email: {
|
|
8
|
+
export async function getEmailBuilder(organization: Organization|null, email: {
|
|
8
9
|
defaultReplacements?: Replacement[],
|
|
9
10
|
recipients: Recipient[],
|
|
10
11
|
from: string,
|
|
11
|
-
replyTo?: string,
|
|
12
|
+
replyTo?: string|null,
|
|
12
13
|
subject: string,
|
|
13
14
|
//text: string | null,
|
|
14
15
|
html: string | null,
|
|
@@ -21,21 +22,31 @@ export async function getEmailBuilder(organization: Organization, email: {
|
|
|
21
22
|
type?: "transactional" | "broadcast",
|
|
22
23
|
unsubscribeType?: 'all'|'marketing',
|
|
23
24
|
fromStamhoofd?: boolean,
|
|
24
|
-
singleBcc?: string
|
|
25
|
+
singleBcc?: string,
|
|
26
|
+
callback?: (error: Error|null) => void; // for each email
|
|
25
27
|
}) {
|
|
28
|
+
const platform = await Platform.getSharedStruct()
|
|
26
29
|
// Update recipients
|
|
27
30
|
const cleaned: Recipient[] = []
|
|
28
31
|
for (const recipient of email.recipients) {
|
|
29
32
|
try {
|
|
30
|
-
const unsubscribe = await EmailAddress.getOrCreate(recipient.email, email.fromStamhoofd ? null : organization.id)
|
|
33
|
+
const unsubscribe = await EmailAddress.getOrCreate(recipient.email, email.fromStamhoofd || !organization ? null : organization.id)
|
|
31
34
|
|
|
32
35
|
if (unsubscribe.unsubscribedAll || unsubscribe.hardBounce || unsubscribe.markedAsSpam || !unsubscribe.token || (unsubscribe.unsubscribedMarketing && email.unsubscribeType === 'marketing')) {
|
|
33
36
|
// Ignore
|
|
37
|
+
if (email.callback) {
|
|
38
|
+
email.callback(
|
|
39
|
+
new SimpleError({
|
|
40
|
+
code: 'email_unsubscribed',
|
|
41
|
+
message: unsubscribe.unsubscribedAll ? "Recipient has unsubscribed" : (unsubscribe.hardBounce ? 'Recipient has hard bounced' : (unsubscribe.markedAsSpam ? 'Recipient has marked as spam' : 'Recipient has unsubscribed from marketing'))
|
|
42
|
+
})
|
|
43
|
+
)
|
|
44
|
+
}
|
|
34
45
|
continue
|
|
35
46
|
}
|
|
36
47
|
recipient.replacements.push(Replacement.create({
|
|
37
48
|
token: "unsubscribeUrl",
|
|
38
|
-
value: "https://"+STAMHOOFD.domains.dashboard+"/"+organization.i18n.locale+"
|
|
49
|
+
value: "https://"+STAMHOOFD.domains.dashboard+"/"+(organization ? (organization.i18n.locale + '/') : '')+"unsubscribe?id="+encodeURIComponent(unsubscribe.id)+"&token="+encodeURIComponent(unsubscribe.token)+"&type="+encodeURIComponent(email.unsubscribeType ?? 'all')
|
|
39
50
|
}))
|
|
40
51
|
|
|
41
52
|
// Override headers
|
|
@@ -55,14 +66,12 @@ export async function getEmailBuilder(organization: Organization, email: {
|
|
|
55
66
|
recipient.replacements = recipient.replacements.slice()
|
|
56
67
|
|
|
57
68
|
// Default signInUrl
|
|
58
|
-
let signInUrl = "https://"+organization.getHost()+"/login?email="+encodeURIComponent(recipient.email)
|
|
69
|
+
let signInUrl = "https://"+(organization && STAMHOOFD.userMode === 'organization' ? organization.getHost() : STAMHOOFD.domains.dashboard)+"/login?email="+encodeURIComponent(recipient.email)
|
|
59
70
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
signInUrl = await PasswordToken.getMagicSignInUrl(recipientUser, organization)
|
|
65
|
-
}
|
|
71
|
+
const recipientUser = await User.getForAuthentication(organization?.id ?? null, recipient.email)
|
|
72
|
+
if (!recipientUser) {
|
|
73
|
+
// We can create a special token
|
|
74
|
+
signInUrl = "https://"+(organization && STAMHOOFD.userMode === 'organization' ? organization.getHost() : STAMHOOFD.domains.dashboard)+"/account-aanmaken?email="+encodeURIComponent(recipient.email)
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
recipient.replacements.push(Replacement.create({
|
|
@@ -74,8 +83,13 @@ export async function getEmailBuilder(organization: Organization, email: {
|
|
|
74
83
|
recipient.replacements.push(...email.defaultReplacements)
|
|
75
84
|
}
|
|
76
85
|
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
if (organization) {
|
|
87
|
+
const extra = organization.meta.getEmailReplacements()
|
|
88
|
+
recipient.replacements.push(...extra)
|
|
89
|
+
} else {
|
|
90
|
+
const extra = platform.config.getEmailReplacements()
|
|
91
|
+
recipient.replacements.push(...extra)
|
|
92
|
+
}
|
|
79
93
|
}
|
|
80
94
|
|
|
81
95
|
const queue = email.recipients.slice()
|
|
@@ -107,7 +121,7 @@ export async function getEmailBuilder(organization: Organization, email: {
|
|
|
107
121
|
|
|
108
122
|
return {
|
|
109
123
|
from: email.from,
|
|
110
|
-
replyTo: email.replyTo,
|
|
124
|
+
replyTo: email.replyTo ?? undefined,
|
|
111
125
|
bcc: emailIndex === 1 ? email.singleBcc : undefined,
|
|
112
126
|
to: [
|
|
113
127
|
{
|
|
@@ -120,8 +134,9 @@ export async function getEmailBuilder(organization: Organization, email: {
|
|
|
120
134
|
html: replacedHtml ?? undefined,
|
|
121
135
|
attachments: email.attachments,
|
|
122
136
|
headers: recipient.headers,
|
|
123
|
-
type: email.type
|
|
137
|
+
type: email.type,
|
|
138
|
+
callback: email.callback
|
|
124
139
|
}
|
|
125
140
|
}
|
|
126
141
|
return builder;
|
|
127
|
-
}
|
|
142
|
+
}
|
|
@@ -87,7 +87,6 @@ export class GroupBuilder {
|
|
|
87
87
|
genderType: mixedType,
|
|
88
88
|
startDate: this.organization.meta.defaultStartDate,
|
|
89
89
|
endDate: this.organization.meta.defaultEndDate,
|
|
90
|
-
prices: this.organization.meta.defaultPrices,
|
|
91
90
|
minAge: 6,
|
|
92
91
|
maxAge: 7
|
|
93
92
|
})
|
|
@@ -102,7 +101,6 @@ export class GroupBuilder {
|
|
|
102
101
|
genderType: mixedType,
|
|
103
102
|
startDate: this.organization.meta.defaultStartDate,
|
|
104
103
|
endDate: this.organization.meta.defaultEndDate,
|
|
105
|
-
prices: this.organization.meta.defaultPrices,
|
|
106
104
|
minAge: 17,
|
|
107
105
|
maxAge: 17
|
|
108
106
|
})
|
|
@@ -118,7 +116,6 @@ export class GroupBuilder {
|
|
|
118
116
|
genderType: GroupGenderType.Mixed,
|
|
119
117
|
startDate: this.organization.meta.defaultStartDate,
|
|
120
118
|
endDate: this.organization.meta.defaultEndDate,
|
|
121
|
-
prices: this.organization.meta.defaultPrices,
|
|
122
119
|
minAge: 8,
|
|
123
120
|
maxAge: 10
|
|
124
121
|
})
|
|
@@ -133,7 +130,6 @@ export class GroupBuilder {
|
|
|
133
130
|
genderType: GroupGenderType.Mixed,
|
|
134
131
|
startDate: this.organization.meta.defaultStartDate,
|
|
135
132
|
endDate: this.organization.meta.defaultEndDate,
|
|
136
|
-
prices: this.organization.meta.defaultPrices,
|
|
137
133
|
minAge: 11,
|
|
138
134
|
maxAge: 13
|
|
139
135
|
})
|
|
@@ -148,7 +144,6 @@ export class GroupBuilder {
|
|
|
148
144
|
genderType: GroupGenderType.Mixed,
|
|
149
145
|
startDate: this.organization.meta.defaultStartDate,
|
|
150
146
|
endDate: this.organization.meta.defaultEndDate,
|
|
151
|
-
prices: this.organization.meta.defaultPrices,
|
|
152
147
|
minAge: 14,
|
|
153
148
|
maxAge: 16
|
|
154
149
|
})
|
|
@@ -165,7 +160,6 @@ export class GroupBuilder {
|
|
|
165
160
|
genderType: GroupGenderType.OnlyFemale,
|
|
166
161
|
startDate: this.organization.meta.defaultStartDate,
|
|
167
162
|
endDate: this.organization.meta.defaultEndDate,
|
|
168
|
-
prices: this.organization.meta.defaultPrices,
|
|
169
163
|
minAge: 8,
|
|
170
164
|
maxAge: 10
|
|
171
165
|
})
|
|
@@ -180,7 +174,6 @@ export class GroupBuilder {
|
|
|
180
174
|
genderType: GroupGenderType.OnlyFemale,
|
|
181
175
|
startDate: this.organization.meta.defaultStartDate,
|
|
182
176
|
endDate: this.organization.meta.defaultEndDate,
|
|
183
|
-
prices: this.organization.meta.defaultPrices,
|
|
184
177
|
minAge: 11,
|
|
185
178
|
maxAge: 13
|
|
186
179
|
})
|
|
@@ -195,7 +188,6 @@ export class GroupBuilder {
|
|
|
195
188
|
genderType: GroupGenderType.OnlyFemale,
|
|
196
189
|
startDate: this.organization.meta.defaultStartDate,
|
|
197
190
|
endDate: this.organization.meta.defaultEndDate,
|
|
198
|
-
prices: this.organization.meta.defaultPrices,
|
|
199
191
|
minAge: 14,
|
|
200
192
|
maxAge: 16
|
|
201
193
|
})
|
|
@@ -212,7 +204,6 @@ export class GroupBuilder {
|
|
|
212
204
|
genderType: GroupGenderType.OnlyMale,
|
|
213
205
|
startDate: this.organization.meta.defaultStartDate,
|
|
214
206
|
endDate: this.organization.meta.defaultEndDate,
|
|
215
|
-
prices: this.organization.meta.defaultPrices,
|
|
216
207
|
minAge: 8,
|
|
217
208
|
maxAge: 10
|
|
218
209
|
})
|
|
@@ -227,7 +218,6 @@ export class GroupBuilder {
|
|
|
227
218
|
genderType: GroupGenderType.OnlyMale,
|
|
228
219
|
startDate: this.organization.meta.defaultStartDate,
|
|
229
220
|
endDate: this.organization.meta.defaultEndDate,
|
|
230
|
-
prices: this.organization.meta.defaultPrices,
|
|
231
221
|
minAge: 11,
|
|
232
222
|
maxAge: 13
|
|
233
223
|
})
|
|
@@ -242,7 +232,6 @@ export class GroupBuilder {
|
|
|
242
232
|
genderType: GroupGenderType.OnlyMale,
|
|
243
233
|
startDate: this.organization.meta.defaultStartDate,
|
|
244
234
|
endDate: this.organization.meta.defaultEndDate,
|
|
245
|
-
prices: this.organization.meta.defaultPrices,
|
|
246
235
|
minAge: 14,
|
|
247
236
|
maxAge: 16
|
|
248
237
|
})
|
|
@@ -268,7 +257,6 @@ export class GroupBuilder {
|
|
|
268
257
|
genderType: mixedType,
|
|
269
258
|
startDate: this.organization.meta.defaultStartDate,
|
|
270
259
|
endDate: this.organization.meta.defaultEndDate,
|
|
271
|
-
prices: this.organization.meta.defaultPrices,
|
|
272
260
|
minAge: 6,
|
|
273
261
|
maxAge: 7
|
|
274
262
|
})
|
|
@@ -282,7 +270,6 @@ export class GroupBuilder {
|
|
|
282
270
|
genderType: mixedType,
|
|
283
271
|
startDate: this.organization.meta.defaultStartDate,
|
|
284
272
|
endDate: this.organization.meta.defaultEndDate,
|
|
285
|
-
prices: this.organization.meta.defaultPrices,
|
|
286
273
|
minAge: 8,
|
|
287
274
|
maxAge: 9
|
|
288
275
|
})
|
|
@@ -297,7 +284,6 @@ export class GroupBuilder {
|
|
|
297
284
|
genderType: mixedType,
|
|
298
285
|
startDate: this.organization.meta.defaultStartDate,
|
|
299
286
|
endDate: this.organization.meta.defaultEndDate,
|
|
300
|
-
prices: this.organization.meta.defaultPrices,
|
|
301
287
|
minAge: 16,
|
|
302
288
|
maxAge: 17
|
|
303
289
|
})
|
|
@@ -312,7 +298,6 @@ export class GroupBuilder {
|
|
|
312
298
|
genderType: GroupGenderType.Mixed,
|
|
313
299
|
startDate: this.organization.meta.defaultStartDate,
|
|
314
300
|
endDate: this.organization.meta.defaultEndDate,
|
|
315
|
-
prices: this.organization.meta.defaultPrices,
|
|
316
301
|
minAge: 10,
|
|
317
302
|
maxAge: 11
|
|
318
303
|
})
|
|
@@ -326,7 +311,6 @@ export class GroupBuilder {
|
|
|
326
311
|
genderType: GroupGenderType.Mixed,
|
|
327
312
|
startDate: this.organization.meta.defaultStartDate,
|
|
328
313
|
endDate: this.organization.meta.defaultEndDate,
|
|
329
|
-
prices: this.organization.meta.defaultPrices,
|
|
330
314
|
minAge: 12,
|
|
331
315
|
maxAge: 13
|
|
332
316
|
})
|
|
@@ -340,7 +324,6 @@ export class GroupBuilder {
|
|
|
340
324
|
genderType: GroupGenderType.Mixed,
|
|
341
325
|
startDate: this.organization.meta.defaultStartDate,
|
|
342
326
|
endDate: this.organization.meta.defaultEndDate,
|
|
343
|
-
prices: this.organization.meta.defaultPrices,
|
|
344
327
|
minAge: 14,
|
|
345
328
|
maxAge: 15
|
|
346
329
|
})
|
|
@@ -356,7 +339,6 @@ export class GroupBuilder {
|
|
|
356
339
|
genderType: GroupGenderType.OnlyFemale,
|
|
357
340
|
startDate: this.organization.meta.defaultStartDate,
|
|
358
341
|
endDate: this.organization.meta.defaultEndDate,
|
|
359
|
-
prices: this.organization.meta.defaultPrices,
|
|
360
342
|
minAge: 10,
|
|
361
343
|
maxAge: 11
|
|
362
344
|
})
|
|
@@ -370,7 +352,6 @@ export class GroupBuilder {
|
|
|
370
352
|
genderType: GroupGenderType.OnlyFemale,
|
|
371
353
|
startDate: this.organization.meta.defaultStartDate,
|
|
372
354
|
endDate: this.organization.meta.defaultEndDate,
|
|
373
|
-
prices: this.organization.meta.defaultPrices,
|
|
374
355
|
minAge: 12,
|
|
375
356
|
maxAge: 13
|
|
376
357
|
})
|
|
@@ -384,7 +365,6 @@ export class GroupBuilder {
|
|
|
384
365
|
genderType: GroupGenderType.OnlyFemale,
|
|
385
366
|
startDate: this.organization.meta.defaultStartDate,
|
|
386
367
|
endDate: this.organization.meta.defaultEndDate,
|
|
387
|
-
prices: this.organization.meta.defaultPrices,
|
|
388
368
|
minAge: 14,
|
|
389
369
|
maxAge: 15
|
|
390
370
|
})
|
|
@@ -400,7 +380,6 @@ export class GroupBuilder {
|
|
|
400
380
|
genderType: GroupGenderType.OnlyMale,
|
|
401
381
|
startDate: this.organization.meta.defaultStartDate,
|
|
402
382
|
endDate: this.organization.meta.defaultEndDate,
|
|
403
|
-
prices: this.organization.meta.defaultPrices,
|
|
404
383
|
minAge: 10,
|
|
405
384
|
maxAge: 11
|
|
406
385
|
})
|
|
@@ -414,7 +393,6 @@ export class GroupBuilder {
|
|
|
414
393
|
genderType: GroupGenderType.OnlyMale,
|
|
415
394
|
startDate: this.organization.meta.defaultStartDate,
|
|
416
395
|
endDate: this.organization.meta.defaultEndDate,
|
|
417
|
-
prices: this.organization.meta.defaultPrices,
|
|
418
396
|
minAge: 12,
|
|
419
397
|
maxAge: 13
|
|
420
398
|
})
|
|
@@ -428,7 +406,6 @@ export class GroupBuilder {
|
|
|
428
406
|
genderType: GroupGenderType.OnlyMale,
|
|
429
407
|
startDate: this.organization.meta.defaultStartDate,
|
|
430
408
|
endDate: this.organization.meta.defaultEndDate,
|
|
431
|
-
prices: this.organization.meta.defaultPrices,
|
|
432
409
|
minAge: 14,
|
|
433
410
|
maxAge: 15
|
|
434
411
|
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
CREATE TABLE `emails` (
|
|
2
|
+
`id` varchar(36) NOT NULL DEFAULT '',
|
|
3
|
+
`organizationId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
|
|
4
|
+
`userId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
|
|
5
|
+
`recipientFilter` json NOT NULL,
|
|
6
|
+
`subject` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
|
|
7
|
+
`text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
|
|
8
|
+
`html` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
|
|
9
|
+
`json` json NOT NULL,
|
|
10
|
+
`status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
11
|
+
`recipientsStatus` varchar(255) NOT NULL,
|
|
12
|
+
`attachments` json NOT NULL,
|
|
13
|
+
`sentAt` datetime DEFAULT NULL,
|
|
14
|
+
`updatedAt` datetime NOT NULL,
|
|
15
|
+
`createdAt` datetime NOT NULL,
|
|
16
|
+
`fromAddress` text,
|
|
17
|
+
`recipientCount` int DEFAULT NULL,
|
|
18
|
+
`fromName` text,
|
|
19
|
+
PRIMARY KEY (`id`),
|
|
20
|
+
KEY `organizationId` (`organizationId`),
|
|
21
|
+
KEY `userId` (`userId`),
|
|
22
|
+
CONSTRAINT `emails_ibfk_1` FOREIGN KEY (`organizationId`) REFERENCES `organizations` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
23
|
+
CONSTRAINT `emails_ibfk_2` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
|
24
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
CREATE TABLE `email_recipients` (
|
|
2
|
+
`id` varchar(36) NOT NULL,
|
|
3
|
+
`emailId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
4
|
+
`firstName` varchar(128) DEFAULT NULL,
|
|
5
|
+
`lastName` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
|
|
6
|
+
`email` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
7
|
+
`replacements` json NOT NULL,
|
|
8
|
+
`failErrorMessage` text,
|
|
9
|
+
`failCount` int NOT NULL DEFAULT '0',
|
|
10
|
+
`firstFailedAt` datetime DEFAULT NULL,
|
|
11
|
+
`lastFailedAt` datetime DEFAULT NULL,
|
|
12
|
+
`sentAt` datetime DEFAULT NULL,
|
|
13
|
+
`updatedAt` datetime NOT NULL,
|
|
14
|
+
`createdAt` datetime NOT NULL,
|
|
15
|
+
PRIMARY KEY (`id`),
|
|
16
|
+
KEY `emailId` (`emailId`),
|
|
17
|
+
CONSTRAINT `email_recipients_ibfk_1` FOREIGN KEY (`emailId`) REFERENCES `emails` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
18
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `member_responsibility_records` ADD FOREIGN KEY (`groupId`) REFERENCES `groups` (`id`) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
CREATE TABLE `events` (
|
|
2
|
+
`id` varchar(36) NOT NULL DEFAULT '',
|
|
3
|
+
`typeId` varchar(36) NOT NULL,
|
|
4
|
+
`name` text NOT NULL,
|
|
5
|
+
`startDate` datetime NOT NULL,
|
|
6
|
+
`endDate` datetime NOT NULL,
|
|
7
|
+
`createdAt` datetime NOT NULL,
|
|
8
|
+
`updatedAt` datetime NOT NULL,
|
|
9
|
+
`organizationId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
|
|
10
|
+
`groupId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
|
|
11
|
+
`meta` json NOT NULL,
|
|
12
|
+
PRIMARY KEY (`id`),
|
|
13
|
+
KEY `organizationId` (`organizationId`),
|
|
14
|
+
KEY `groupId` (`groupId`),
|
|
15
|
+
KEY `startDate` (`startDate`) USING BTREE,
|
|
16
|
+
CONSTRAINT `events_ibfk_1` FOREIGN KEY (`organizationId`) REFERENCES `organizations` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
17
|
+
CONSTRAINT `events_ibfk_2` FOREIGN KEY (`groupId`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
|
18
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
@@ -96,14 +96,14 @@ export class DocumentTemplate extends Model {
|
|
|
96
96
|
id: "registration.startDate",
|
|
97
97
|
type: RecordType.Date,
|
|
98
98
|
}), // settings will be overwritten
|
|
99
|
-
dateValue: group?.settings?.
|
|
99
|
+
dateValue: group?.settings?.startDate
|
|
100
100
|
}),
|
|
101
101
|
"registration.endDate": RecordDateAnswer.create({
|
|
102
102
|
settings: RecordSettings.create({
|
|
103
103
|
id: "registration.endDate",
|
|
104
104
|
type: RecordType.Date,
|
|
105
105
|
}), // settings will be overwritten
|
|
106
|
-
dateValue: group?.settings?.
|
|
106
|
+
dateValue: group?.settings?.endDate
|
|
107
107
|
}),
|
|
108
108
|
"registration.price":
|
|
109
109
|
RecordPriceAnswer.create({
|