Sfoglia il codice sorgente

[web] Target all group subscriptions on Survey configuration (#31928)

Update the toggle behaviour to target all group subscription users,
regardless of whether they are in Recurly or Stripe.

GitOrigin-RevId: a3e72d93e440a8941472f868e387a654b8908d1f
Miguel Serrano 5 mesi fa
parent
commit
c1c9b9e1b7

+ 1 - 2
services/web/app/src/Features/Subscription/SubscriptionLocator.mjs

@@ -71,12 +71,11 @@ const SubscriptionLocator = {
     return subscription?.admin_id
   },
 
-  async hasRecurlyGroupSubscription(userOrId) {
+  async hasGroupSubscription(userOrId) {
     if (!Features.hasFeature('saas')) return false
     const userId = SubscriptionLocator._getUserId(userOrId)
     return await Subscription.exists({
       groupPlan: true,
-      recurlySubscription_id: { $exists: true },
       $or: [
         { member_ids: userId },
         { manager_ids: userId },

+ 4 - 4
services/web/app/src/Features/Survey/SurveyHandler.mjs

@@ -19,10 +19,10 @@ import UserGetter from '../User/UserGetter.mjs'
 async function getSurvey(userId) {
   const survey = await SurveyCache.get(true)
   if (survey) {
-    if (survey.options?.hasRecurlyGroupSubscription) {
-      const hasRecurlyGroupSubscription =
-        await SubscriptionLocator.promises.hasRecurlyGroupSubscription(userId)
-      if (!hasRecurlyGroupSubscription) {
+    if (survey.options?.hasGroupSubscription) {
+      const hasGroupSubscription =
+        await SubscriptionLocator.promises.hasGroupSubscription(userId)
+      if (!hasGroupSubscription) {
         return
       }
     }

+ 1 - 1
services/web/app/src/models/Survey.mjs

@@ -36,7 +36,7 @@ export const SurveySchema = new Schema(
       required: true,
     },
     options: {
-      hasRecurlyGroupSubscription: {
+      hasGroupSubscription: {
         type: Boolean,
         default: false,
       },