@stamhoofd/backend 2.32.3 → 2.33.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/package.json +10 -10
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +1 -1
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +33 -4
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +15 -17
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +0 -1
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +26 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/backend",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"@simonbackx/simple-encoding": "2.15.1",
|
|
37
37
|
"@simonbackx/simple-endpoints": "1.14.0",
|
|
38
38
|
"@simonbackx/simple-logging": "^1.0.1",
|
|
39
|
-
"@stamhoofd/backend-i18n": "2.
|
|
40
|
-
"@stamhoofd/backend-middleware": "2.
|
|
41
|
-
"@stamhoofd/email": "2.
|
|
42
|
-
"@stamhoofd/models": "2.
|
|
43
|
-
"@stamhoofd/queues": "2.
|
|
44
|
-
"@stamhoofd/sql": "2.
|
|
45
|
-
"@stamhoofd/structures": "2.
|
|
46
|
-
"@stamhoofd/utility": "2.
|
|
39
|
+
"@stamhoofd/backend-i18n": "2.33.0",
|
|
40
|
+
"@stamhoofd/backend-middleware": "2.33.0",
|
|
41
|
+
"@stamhoofd/email": "2.33.0",
|
|
42
|
+
"@stamhoofd/models": "2.33.0",
|
|
43
|
+
"@stamhoofd/queues": "2.33.0",
|
|
44
|
+
"@stamhoofd/sql": "2.33.0",
|
|
45
|
+
"@stamhoofd/structures": "2.33.0",
|
|
46
|
+
"@stamhoofd/utility": "2.33.0",
|
|
47
47
|
"archiver": "^7.0.1",
|
|
48
48
|
"aws-sdk": "^2.885.0",
|
|
49
49
|
"axios": "1.6.8",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"postmark": "4.0.2",
|
|
61
61
|
"stripe": "^16.6.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d274ebed63137db804e33e858100c452309855da"
|
|
64
64
|
}
|
|
@@ -76,7 +76,7 @@ export class VerifyEmailEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
76
76
|
throw new SimpleError({
|
|
77
77
|
code: "email_in_use",
|
|
78
78
|
message: "This e-mail is already in use, we cannot set it",
|
|
79
|
-
human: "We kunnen het e-mailadres van deze gebruiker niet instellen naar "+code.email+", omdat die al in gebruik is. Waarschijnlijk heb je meerdere accounts. Probeer met dat e-mailadres in te loggen of contacteer ons ("+request.$t("
|
|
79
|
+
human: "We kunnen het e-mailadres van deze gebruiker niet instellen naar "+code.email+", omdat die al in gebruik is. Waarschijnlijk heb je meerdere accounts. Probeer met dat e-mailadres in te loggen of contacteer ons ("+request.$t("59b85264-c4c3-4cf6-8923-9b43282b2787")+") als we de gebruikers moeten combineren tot één gebruiker."
|
|
80
80
|
})
|
|
81
81
|
}
|
|
82
82
|
throw e;
|
|
@@ -63,7 +63,7 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
63
63
|
human: 'Je kan geen activiteiten voor een specifieke organisatie aanmaken als je geen platform hoofdbeheerder bent',
|
|
64
64
|
})
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
const eventOrganization = put.organizationId ? (await Organization.getByID(put.organizationId)) : null
|
|
68
68
|
if (!eventOrganization && put.organizationId) {
|
|
69
69
|
throw new SimpleError({
|
|
@@ -79,8 +79,9 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
79
79
|
event.name = put.name
|
|
80
80
|
event.startDate = put.startDate
|
|
81
81
|
event.endDate = put.endDate
|
|
82
|
-
event.meta = put.meta
|
|
83
|
-
|
|
82
|
+
event.meta = put.meta;
|
|
83
|
+
const type = await PatchEventsEndpoint.getEventType(put.typeId);
|
|
84
|
+
event.typeId = type.id;
|
|
84
85
|
event.meta.organizationCache = eventOrganization ? NamedObject.create({id: eventOrganization.id, name: eventOrganization.name}) : null
|
|
85
86
|
await PatchEventsEndpoint.checkEventLimits(event)
|
|
86
87
|
|
|
@@ -110,6 +111,10 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
110
111
|
event.groupId = group.id
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
if(type.isLocationRequired === true) {
|
|
115
|
+
PatchEventsEndpoint.throwIfAddressIsMissing(event);
|
|
116
|
+
}
|
|
117
|
+
|
|
113
118
|
await event.save()
|
|
114
119
|
|
|
115
120
|
events.push(event)
|
|
@@ -178,7 +183,12 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
185
|
|
|
181
|
-
|
|
186
|
+
const type = await PatchEventsEndpoint.getEventType(patch.typeId ?? event.typeId);
|
|
187
|
+
|
|
188
|
+
if(patch.typeId) {
|
|
189
|
+
event.typeId = type.id;
|
|
190
|
+
}
|
|
191
|
+
|
|
182
192
|
await PatchEventsEndpoint.checkEventLimits(event)
|
|
183
193
|
|
|
184
194
|
if (patch.group !== undefined) {
|
|
@@ -230,6 +240,10 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
230
240
|
}
|
|
231
241
|
}
|
|
232
242
|
|
|
243
|
+
if(type.isLocationRequired === true) {
|
|
244
|
+
PatchEventsEndpoint.throwIfAddressIsMissing(event);
|
|
245
|
+
}
|
|
246
|
+
|
|
233
247
|
await event.save()
|
|
234
248
|
|
|
235
249
|
if (event.groupId) {
|
|
@@ -345,4 +359,19 @@ export class PatchEventsEndpoint extends Endpoint<Params, Query, Body, ResponseB
|
|
|
345
359
|
}
|
|
346
360
|
}
|
|
347
361
|
}
|
|
362
|
+
|
|
363
|
+
private static throwIfAddressIsMissing(event: Event) {
|
|
364
|
+
const address = event.meta.location?.address;
|
|
365
|
+
|
|
366
|
+
if(!address) {
|
|
367
|
+
throw new SimpleError({
|
|
368
|
+
code: "invalid_field",
|
|
369
|
+
message: "Empty number",
|
|
370
|
+
human: "De locatie is verplicht voor deze soort activiteit.",
|
|
371
|
+
field: "event_required"
|
|
372
|
+
})
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
address.throwIfIncomplete();
|
|
376
|
+
}
|
|
348
377
|
}
|
|
@@ -499,23 +499,21 @@ export class PatchOrganizationMembersEndpoint extends Endpoint<Params, Query, Bo
|
|
|
499
499
|
throw Context.auth.error("Je hebt niet voldoende rechten om dit lid te verwijderen")
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
//
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
// }
|
|
518
|
-
//}
|
|
502
|
+
await MemberUserSyncer.onDeleteMember(member)
|
|
503
|
+
await User.deleteForDeletedMember(member.id)
|
|
504
|
+
await BalanceItem.deleteForDeletedMember(member.id)
|
|
505
|
+
await member.delete()
|
|
506
|
+
shouldUpdateSetupSteps = true
|
|
507
|
+
|
|
508
|
+
// Update occupancy of this member because we removed registrations
|
|
509
|
+
const groupIds = member.registrations.flatMap(r => r.groupId)
|
|
510
|
+
for (const id of groupIds) {
|
|
511
|
+
const group = await getGroup(id)
|
|
512
|
+
if (group) {
|
|
513
|
+
// We need to update this group occupancy because we moved one member away from it
|
|
514
|
+
updateGroups.set(group.id, group)
|
|
515
|
+
}
|
|
516
|
+
}
|
|
519
517
|
}
|
|
520
518
|
|
|
521
519
|
await Member.updateOutstandingBalance(Formatter.uniqueArray(balanceItemMemberIds))
|
|
@@ -6,7 +6,6 @@ import { Organization, StripeAccount, StripeCheckoutSession, StripePaymentIntent
|
|
|
6
6
|
|
|
7
7
|
import { StripeHelper } from '../../../helpers/StripeHelper';
|
|
8
8
|
import { ExchangePaymentEndpoint } from '../../organization/shared/ExchangePaymentEndpoint';
|
|
9
|
-
import { QueueHandler } from '@stamhoofd/queues';
|
|
10
9
|
|
|
11
10
|
type Params = Record<string, never>;
|
|
12
11
|
class Body extends AutoEncoder {
|
|
@@ -2,13 +2,13 @@ import { AutoEncoderPatchType, Decoder, PatchableArrayAutoEncoder, PatchableArra
|
|
|
2
2
|
import { DecodedRequest, Endpoint, Request, Response } from "@simonbackx/simple-endpoints";
|
|
3
3
|
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
4
|
import { Document, Member, mergeTwoMembers, RateLimiter } from '@stamhoofd/models';
|
|
5
|
-
import {
|
|
5
|
+
import { MemberDetails, MembersBlob, MemberWithRegistrationsBlob } from "@stamhoofd/structures";
|
|
6
6
|
|
|
7
|
+
import { Email } from '@stamhoofd/email';
|
|
7
8
|
import { AuthenticatedStructures } from '../../../helpers/AuthenticatedStructures';
|
|
8
9
|
import { Context } from '../../../helpers/Context';
|
|
9
10
|
import { MemberUserSyncer } from '../../../helpers/MemberUserSyncer';
|
|
10
11
|
import { PatchOrganizationMembersEndpoint } from '../../global/members/PatchOrganizationMembersEndpoint';
|
|
11
|
-
import { Email } from '@stamhoofd/email';
|
|
12
12
|
type Params = Record<string, never>;
|
|
13
13
|
type Query = undefined;
|
|
14
14
|
type Body = PatchableArrayAutoEncoder<MemberWithRegistrationsBlob>
|
|
@@ -60,6 +60,8 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
60
60
|
struct.details.cleanData()
|
|
61
61
|
member.details = struct.details
|
|
62
62
|
|
|
63
|
+
this.throwIfInvalidDetails(member.details);
|
|
64
|
+
|
|
63
65
|
const duplicate = await this.checkDuplicate(member, struct.details.securityCode)
|
|
64
66
|
if (duplicate) {
|
|
65
67
|
addedMembers.push(duplicate)
|
|
@@ -95,8 +97,10 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
95
97
|
field: "details"
|
|
96
98
|
})
|
|
97
99
|
}
|
|
100
|
+
|
|
98
101
|
member.details.patchOrPut(struct.details)
|
|
99
|
-
member.details.cleanData()
|
|
102
|
+
member.details.cleanData();
|
|
103
|
+
this.throwIfInvalidDetails(member.details);
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
if (!member.details) {
|
|
@@ -184,7 +188,7 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
184
188
|
code: "invalid_field",
|
|
185
189
|
field: 'details.securityCode',
|
|
186
190
|
message: "Invalid security code",
|
|
187
|
-
human: Context.i18n.$t(
|
|
191
|
+
human: Context.i18n.$t('49753d6a-7ca4-4145-8024-0be05a9ab063'),
|
|
188
192
|
statusCode: 400
|
|
189
193
|
})
|
|
190
194
|
}
|
|
@@ -206,4 +210,22 @@ export class PatchUserMembersEndpoint extends Endpoint<Params, Query, Body, Resp
|
|
|
206
210
|
return duplicate
|
|
207
211
|
}
|
|
208
212
|
}
|
|
213
|
+
|
|
214
|
+
private throwIfInvalidDetails(details: MemberDetails) {
|
|
215
|
+
if(details.firstName.length < 2) {
|
|
216
|
+
throw new SimpleError({
|
|
217
|
+
code: "invalid_field",
|
|
218
|
+
message: "Voornaam is te kort",
|
|
219
|
+
field: "firstName"
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if(details.lastName.length < 2) {
|
|
224
|
+
throw new SimpleError({
|
|
225
|
+
code: "invalid_field",
|
|
226
|
+
message: "Achternaam is te kort",
|
|
227
|
+
field: "lastName"
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
209
231
|
}
|