@stamhoofd/backend 2.32.4 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stamhoofd/backend",
3
- "version": "2.32.4",
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.32.4",
40
- "@stamhoofd/backend-middleware": "2.32.4",
41
- "@stamhoofd/email": "2.32.4",
42
- "@stamhoofd/models": "2.32.4",
43
- "@stamhoofd/queues": "2.32.4",
44
- "@stamhoofd/sql": "2.32.4",
45
- "@stamhoofd/structures": "2.32.4",
46
- "@stamhoofd/utility": "2.32.4",
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": "b3fb87740644d823bff02163b856477c3e7c45db"
63
+ "gitHead": "d274ebed63137db804e33e858100c452309855da"
64
64
  }
@@ -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
- event.typeId = await PatchEventsEndpoint.validateEventType(put.typeId)
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
- event.typeId = patch.typeId ? (await PatchEventsEndpoint.validateEventType(patch.typeId)) : event.typeId
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
  }