@7365admin1/core 3.60.1-staging.272 → 3.60.1-staging.273

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/index.js CHANGED
@@ -29743,6 +29743,7 @@ function useOrgController() {
29743
29743
  const { inviteId, ...body } = req.body ?? {};
29744
29744
  let invitedFrom = null;
29745
29745
  let invitedRole = null;
29746
+ let inviteAlreadyComplete = false;
29746
29747
  let self = null;
29747
29748
  if (inviteId) {
29748
29749
  const [invite, caller] = await Promise.all([
@@ -29754,6 +29755,7 @@ function useOrgController() {
29754
29755
  if (samePerson) {
29755
29756
  invitedFrom = String(invite._id);
29756
29757
  invitedRole = invite.metadata?.role ? String(invite.metadata.role) : null;
29758
+ inviteAlreadyComplete = invite.status === "complete" /* COMPLETE */;
29757
29759
  } else {
29758
29760
  import_node_server_utils67.logger.log({
29759
29761
  level: "warn",
@@ -29770,6 +29772,19 @@ function useOrgController() {
29770
29772
  }
29771
29773
  }
29772
29774
  const _id = await _add({ ...body, createdBy, invitedFrom, invitedRole });
29775
+ if (invitedFrom && !inviteAlreadyComplete) {
29776
+ try {
29777
+ await useVerificationRepoV2().updateStatusById(
29778
+ invitedFrom,
29779
+ "complete" /* COMPLETE */
29780
+ );
29781
+ } catch (error2) {
29782
+ import_node_server_utils67.logger.log({
29783
+ level: "error",
29784
+ message: `[organizations/onboarding] could not close invitation ${invitedFrom} for organization ${_id}: ${error2?.message}`
29785
+ });
29786
+ }
29787
+ }
29773
29788
  const seededRoles = await seedDefaultRoles(_id, body.nature);
29774
29789
  try {
29775
29790
  const ownerRole = invitedRole || seededRoles.find((role) => role.type === "organization")?.id || "";