Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: some event missing with multiple env webhook (#6705)

darkskygit8bdd940ac80a
diff --git a/packages/backend/server/src/plugins/payment/service.ts b/packages/backend/server/src/plugins/payment/service.ts
index 68dd218a00..fcdf6881b5 100644
--- a/packages/backend/server/src/plugins/payment/service.ts
+++ b/packages/backend/server/src/plugins/payment/service.ts
@@ -571,6 +571,13 @@ export class SubscriptionService {
const [plan, recurring] = this.decodePlanFromSubscription(subscription);
const planActivated = SubscriptionActivated.includes(subscription.status);
+ // update features first, features modify are idempotent
+ // so there is no need to skip if a subscription already exists.
+ this.event.emit('user.subscription.activated', {
+ userId: user.id,
+ plan,
+ });
+
let nextBillAt: Date | null = null;
if (planActivated && !subscription.canceled_at) {
// get next bill date from upcoming invoice
@@ -624,11 +631,6 @@ export class SubscriptionService {
data: update,
});
} else {
- this.event.emit('user.subscription.activated', {
- userId: user.id,
- plan,
- });
-
return await this.db.userSubscription.create({
data: {
userId: user.id,