@koloseum/utils 0.2.27 → 0.2.28

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/utils.d.ts CHANGED
@@ -261,7 +261,7 @@ export declare const Utility: {
261
261
  */
262
262
  sanitiseHtml: (input: string) => string;
263
263
  /**
264
- * Sends a welcome notification to a user.
264
+ * Sends a welcome notification to a new user.
265
265
  * @param {SupabaseClient<Database>} supabase - The Supabase client
266
266
  * @param {UserWithCustomMetadata} user - The user to send the notification to
267
267
  * @param {MicroserviceGroup} microserviceGroup - The microservice group the user belongs to
package/dist/utils.js CHANGED
@@ -868,19 +868,23 @@ export const Utility = {
868
868
  // Assign result of authorisation check
869
869
  isAuthorised = data;
870
870
  }
871
- // Validate SuprSend subscriber
872
- let personData = {};
873
- if (user.app_metadata.person_data) {
874
- const { first_name: firstName, last_name: lastName, pseudonym } = user.app_metadata.person_data;
875
- personData = { firstName, lastName, phone: user.phone, pseudonym };
871
+ // If user has completed Player registration
872
+ if (roles.includes("player")) {
873
+ // Prepare person data
874
+ let personData = {};
875
+ if (user.app_metadata.person_data) {
876
+ const { first_name: firstName, last_name: lastName, pseudonym } = user.app_metadata.person_data;
877
+ personData = { firstName, lastName, phone: user.phone, pseudonym };
878
+ }
879
+ // Validate SuprSend subscriber
880
+ const { code, error: validationError } = await Utility.callEdgeFunction(false, supabase, `suprsend/validate-subscriber?user-id=${user.id}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: personData });
881
+ if (validationError)
882
+ return { error: Utility.customError(code, validationError) };
883
+ // Send welcome notification if not already sent
884
+ const { error: welcomeError } = await Utility.sendWelcomeNotification(supabase, user, microserviceGroup);
885
+ if (welcomeError)
886
+ return { error: welcomeError };
876
887
  }
877
- const { code, error: validationError } = await Utility.callEdgeFunction(false, supabase, `suprsend/validate-subscriber?user-id=${user.id}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: personData });
878
- if (validationError)
879
- return { error: Utility.customError(code, validationError) };
880
- // Send welcome notification if needed
881
- const { error: welcomeError } = await Utility.sendWelcomeNotification(supabase, user, microserviceGroup);
882
- if (welcomeError)
883
- return { error: welcomeError };
884
888
  // Return result
885
889
  return { isAuthorised };
886
890
  },
@@ -1477,7 +1481,7 @@ export const Utility = {
1477
1481
  */
1478
1482
  sanitiseHtml: (input) => typeof input !== "string" ? "" : sanitize(input, { allowedTags: [], allowedAttributes: {} }),
1479
1483
  /**
1480
- * Sends a welcome notification to a user.
1484
+ * Sends a welcome notification to a new user.
1481
1485
  * @param {SupabaseClient<Database>} supabase - The Supabase client
1482
1486
  * @param {UserWithCustomMetadata} user - The user to send the notification to
1483
1487
  * @param {MicroserviceGroup} microserviceGroup - The microservice group the user belongs to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koloseum/utils",
3
- "version": "0.2.27",
3
+ "version": "0.2.28",
4
4
  "author": "Koloseum Technologies Limited",
5
5
  "type": "module",
6
6
  "description": "Utility logic for use across Koloseum web apps (TypeScript)",