mirror of
https://github.com/simple-login/app.git
synced 2024-11-18 06:31:27 +08:00
take into account AppleSubscription in premium formula
This commit is contained in:
parent
2a837f9213
commit
85fd4412ba
1 changed files with 12 additions and 0 deletions
|
@ -217,6 +217,10 @@ class User(db.Model, ModelMixin, UserMixin):
|
|||
if sub:
|
||||
return True
|
||||
|
||||
apple_sub: AppleSubscription = AppleSubscription.get_by(user_id=self.id)
|
||||
if apple_sub and apple_sub.is_valid():
|
||||
return True
|
||||
|
||||
manual_sub: ManualSubscription = ManualSubscription.get_by(user_id=self.id)
|
||||
if manual_sub and manual_sub.end_at > arrow.now():
|
||||
return True
|
||||
|
@ -251,6 +255,10 @@ class User(db.Model, ModelMixin, UserMixin):
|
|||
if sub and not sub.cancelled:
|
||||
return False
|
||||
|
||||
apple_sub: AppleSubscription = AppleSubscription.get_by(user_id=self.id)
|
||||
if apple_sub and apple_sub.is_valid():
|
||||
return False
|
||||
|
||||
manual_sub: ManualSubscription = ManualSubscription.get_by(user_id=self.id)
|
||||
# user who has giveaway premium can decide to upgrade
|
||||
if (
|
||||
|
@ -939,6 +947,10 @@ class AppleSubscription(db.Model, ModelMixin):
|
|||
|
||||
user = db.relationship(User)
|
||||
|
||||
def is_valid(self):
|
||||
# Todo: take into account grace period?
|
||||
return self.expires_date > arrow.now()
|
||||
|
||||
|
||||
class DeletedAlias(db.Model, ModelMixin):
|
||||
"""Store all deleted alias to make sure they are NOT reused"""
|
||||
|
|
Loading…
Reference in a new issue