@stamhoofd/models 2.20.0 → 2.21.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/helpers/EmailBuilder.d.ts +12 -3
- package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
- package/dist/src/helpers/EmailBuilder.js +97 -6
- package/dist/src/helpers/EmailBuilder.js.map +1 -1
- package/dist/src/models/Order.d.ts.map +1 -1
- package/dist/src/models/Order.js +2 -10
- package/dist/src/models/Order.js.map +1 -1
- package/dist/src/models/Organization.d.ts.map +1 -1
- package/dist/src/models/Organization.js +0 -12
- package/dist/src/models/Organization.js.map +1 -1
- package/dist/src/models/Platform.d.ts +3 -1
- package/dist/src/models/Platform.d.ts.map +1 -1
- package/dist/src/models/Platform.js.map +1 -1
- package/dist/src/models/Registration.d.ts.map +1 -1
- package/dist/src/models/Registration.js +16 -27
- package/dist/src/models/Registration.js.map +1 -1
- package/dist/src/models/STPackage.d.ts.map +1 -1
- package/dist/src/models/STPackage.js +2 -12
- package/dist/src/models/STPackage.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/EmailBuilder.ts +112 -11
- package/src/models/Order.ts +3 -11
- package/src/models/Organization.ts +0 -12
- package/src/models/Platform.ts +4 -4
- package/src/models/Registration.ts +17 -30
- package/src/models/STPackage.ts +3 -14
|
@@ -6,7 +6,7 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
6
6
|
|
|
7
7
|
import { ArrayDecoder } from '@simonbackx/simple-encoding';
|
|
8
8
|
import { QueueHandler } from '@stamhoofd/queues';
|
|
9
|
-
import {
|
|
9
|
+
import { sendEmailTemplate } from '../helpers/EmailBuilder';
|
|
10
10
|
import { Document, Group, Organization, User } from './';
|
|
11
11
|
|
|
12
12
|
export class Registration extends Model {
|
|
@@ -251,6 +251,14 @@ export class Registration extends Model {
|
|
|
251
251
|
token: "lastName",
|
|
252
252
|
value: member.details.lastName,
|
|
253
253
|
}),
|
|
254
|
+
Replacement.create({
|
|
255
|
+
token: "firstNameMember",
|
|
256
|
+
value: member.details.firstName,
|
|
257
|
+
}),
|
|
258
|
+
Replacement.create({
|
|
259
|
+
token: "lastNameMember",
|
|
260
|
+
value: member.details.lastName,
|
|
261
|
+
}),
|
|
254
262
|
Replacement.create({
|
|
255
263
|
token: "email",
|
|
256
264
|
value: user.email
|
|
@@ -293,29 +301,18 @@ export class Registration extends Model {
|
|
|
293
301
|
|
|
294
302
|
const recipients = await this.getRecipients(organization, group)
|
|
295
303
|
|
|
296
|
-
const {from, replyTo} = organization.getGroupEmail(group)
|
|
297
|
-
|
|
298
304
|
// Create e-mail builder
|
|
299
|
-
|
|
305
|
+
await sendEmailTemplate(organization, {
|
|
300
306
|
template: {
|
|
301
307
|
type: data.type,
|
|
302
|
-
|
|
308
|
+
group
|
|
303
309
|
},
|
|
304
310
|
recipients,
|
|
305
|
-
from,
|
|
306
311
|
type: "transactional",
|
|
307
|
-
replyTo
|
|
308
312
|
})
|
|
309
|
-
|
|
310
|
-
if (builder) {
|
|
311
|
-
Email.schedule(builder)
|
|
312
|
-
}
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
static async sendTransferEmail(user: User, organization: Organization, payment: import('./').Payment) {
|
|
316
|
-
const data = {
|
|
317
|
-
type: EmailTemplateType.RegistrationTransferDetails
|
|
318
|
-
};
|
|
319
316
|
const paymentGeneral = await payment.getGeneralStructure();
|
|
320
317
|
const groupIds = paymentGeneral.groupIds;
|
|
321
318
|
|
|
@@ -386,31 +383,21 @@ export class Registration extends Model {
|
|
|
386
383
|
})
|
|
387
384
|
];
|
|
388
385
|
|
|
389
|
-
let
|
|
386
|
+
let group: Group|undefined|null = null;
|
|
390
387
|
|
|
391
388
|
if (groupIds.length == 1) {
|
|
392
389
|
const Group = (await import('./')).Group
|
|
393
|
-
|
|
394
|
-
if (group) {
|
|
395
|
-
const groupEmail = organization.getGroupEmail(group)
|
|
396
|
-
from = groupEmail.from
|
|
397
|
-
replyTo = groupEmail.replyTo
|
|
398
|
-
}
|
|
390
|
+
group = await Group.getByID(groupIds[0]);
|
|
399
391
|
}
|
|
400
392
|
|
|
401
393
|
// Create e-mail builder
|
|
402
|
-
|
|
394
|
+
await sendEmailTemplate(organization, {
|
|
403
395
|
template: {
|
|
404
|
-
type: EmailTemplateType.RegistrationTransferDetails
|
|
396
|
+
type: EmailTemplateType.RegistrationTransferDetails,
|
|
397
|
+
group
|
|
405
398
|
},
|
|
406
|
-
recipients
|
|
407
|
-
from,
|
|
408
|
-
replyTo
|
|
399
|
+
recipients
|
|
409
400
|
})
|
|
410
|
-
|
|
411
|
-
if (builder) {
|
|
412
|
-
Email.schedule(builder)
|
|
413
|
-
}
|
|
414
401
|
}
|
|
415
402
|
|
|
416
403
|
shouldIncludeStock() {
|
package/src/models/STPackage.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { column, Model } from "@simonbackx/simple-database";
|
|
2
2
|
import { SimpleError } from "@simonbackx/simple-errors";
|
|
3
|
-
import { Email } from "@stamhoofd/email";
|
|
4
3
|
import { EmailTemplateType, Recipient, Replacement, STPackageMeta, STPackageStatus, STPackageType } from '@stamhoofd/structures';
|
|
5
4
|
import { Formatter } from "@stamhoofd/utility";
|
|
6
5
|
import { v4 as uuidv4 } from "uuid";
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { sendEmailTemplate } from "../helpers/EmailBuilder";
|
|
9
8
|
import { GroupBuilder } from "../helpers/GroupBuilder";
|
|
10
9
|
import { Organization } from "./";
|
|
11
10
|
|
|
@@ -271,10 +270,6 @@ export class STPackage extends Model {
|
|
|
271
270
|
lastName: admin.lastName,
|
|
272
271
|
email: admin.email,
|
|
273
272
|
replacements: [
|
|
274
|
-
Replacement.create({
|
|
275
|
-
token: "firstName",
|
|
276
|
-
value: admin.firstName ?? ""
|
|
277
|
-
}),
|
|
278
273
|
Replacement.create({
|
|
279
274
|
token: "organizationName",
|
|
280
275
|
value: organization.name
|
|
@@ -300,17 +295,11 @@ export class STPackage extends Model {
|
|
|
300
295
|
);
|
|
301
296
|
|
|
302
297
|
// Create e-mail builder
|
|
303
|
-
|
|
298
|
+
await sendEmailTemplate(null, {
|
|
304
299
|
template: {
|
|
305
300
|
type: data.type
|
|
306
301
|
},
|
|
307
|
-
recipients
|
|
308
|
-
from: Email.getInternalEmailFor(organization.i18n),
|
|
309
|
-
replyTo: data.replyTo
|
|
302
|
+
recipients
|
|
310
303
|
})
|
|
311
|
-
|
|
312
|
-
if (builder) {
|
|
313
|
-
Email.schedule(builder)
|
|
314
|
-
}
|
|
315
304
|
}
|
|
316
305
|
}
|