MCPcopy Create free account
hub / github.com/async-labs/async / getSubscriptionStatus

Method getSubscriptionStatus

api/server/models/User.ts:765–786  ·  view source on GitHub ↗
(userId)

Source from the content-addressed store, hash-verified

763
764 // test
765 public static async getSubscriptionStatus(userId) {
766 if (!userId) {
767 throw new Error('Bad data');
768 }
769
770 const teamLeader = await this.findOne({ _id: userId }).setOptions({
771 lean: true,
772 });
773
774 if (!teamLeader) {
775 throw new Error('Team Leader not found');
776 }
777
778 // isSubscriptionActiveForTeam: true or false
779 return {
780 isSubscriptionActiveForAccount: teamLeader.isSubscriptionActiveForAccount,
781 isPaymentFailedForAccount: teamLeader.isPaymentFailedForAccount,
782 isTrialPeriodOverForAccount: moment(new Date()).isAfter(
783 moment(teamLeader.trialPeriodStartDate).add(30, 'days'),
784 ),
785 };
786 }
787
788 // test
789 public static async createOrUpdateInvitedUserAndAddToTeam({ emailOfInvitee, teamId, userId }) {

Calls

no outgoing calls

Tested by

no test coverage detected