-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update subscription tracking #2461
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't have anything blocking 👀
src/routes/webhooks/paddle.ts
Outdated
const userId = await getUserId({ | ||
userId: customData?.user_id, | ||
subscriptionId: 'subscriptionId' in data.data && data.data.subscriptionId, | ||
}); | ||
const con = await createOrGetConnection(); | ||
const flags = await con.getRepository(User).findOne({ | ||
where: { id: userId }, | ||
select: ['subscriptionFlags'], | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We double query the user, once in getUserId
then again in the call in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to abstract anything maybe better that getUserId
is just getUser
and then we get user object either way which we can use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah was thinking of that as well, just meant more refactors on end type as it's a optional return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the early return only cares about returning the id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative could be to have a seperate function for this case? (only 1 user now, but maybe future more)
Let me know if you prefer that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just do it inline in both places but if we use util then I would go with getUser
. Neither blocking for this PR.
Co-authored-by: Ante Barić <[email protected]>
We should only fire the event if subscription cycle actually changed, not any of the other changes.
I also decided to update our flags in this case so we have the right setting stored at all times.
AS-744 #done