Skip to content

Commit

Permalink
fix: NOTIFY_DAYS_LEFT
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintShit committed Aug 4, 2024
1 parent 46995d0 commit 530649d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ UVICORN_PORT = 8000
# NOTIFY_USER_DELETED = True
# NOTIFY_USER_DATA_USED_RESET = True
# NOTIFY_USER_SUB_REVOKED = True
# NOTIFY_DATA_USAGE_PERCENT_REACHED = True
# NOTIFY_DAYS_LEFT = True
# NOTIFY_IF_DATA_USAGE_PERCENT_REACHED = True
# NOTIFY_IF_DAYS_LEF_REACHED = True
# NOTIFY_LOGIN = True

### for developers
Expand Down
14 changes: 8 additions & 6 deletions app/utils/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
NOTIFY_USER_DELETED,
NOTIFY_USER_DATA_USED_RESET,
NOTIFY_USER_SUB_REVOKED,
NOTIFY_DATA_USAGE_PERCENT_REACHED,
NOTIFY_DAYS_LEFT,
NOTIFY_IF_DATA_USAGE_PERCENT_REACHED,
NOTIFY_IF_DAYS_LEF_REACHED,
NOTIFY_LOGIN
)


def status_change(
username: str, status: UserStatus, user: UserResponse, user_admin: Admin = None, by: Admin = None) -> None:
if NOTIFY_STATUS_CHANGE:
Expand Down Expand Up @@ -150,7 +151,8 @@ def user_subscription_revoked(user: UserResponse, by: Admin, user_admin: Admin =
)
except Exception:
pass
notify(UserSubscriptionRevoked(username=user.username, action=Notification.Type.subscription_revoked, by=by, user=user))
notify(UserSubscriptionRevoked(username=user.username,
action=Notification.Type.subscription_revoked, by=by, user=user))
try:
discord.report_user_subscription_revoked(
username=user.username,
Expand All @@ -163,15 +165,15 @@ def user_subscription_revoked(user: UserResponse, by: Admin, user_admin: Admin =

def data_usage_percent_reached(
db: Session, percent: float, user: UserResponse, user_id: int, expire: Optional[int] = None) -> None:
if NOTIFY_DATA_USAGE_PERCENT_REACHED:
if NOTIFY_IF_DATA_USAGE_PERCENT_REACHED:
notify(ReachedUsagePercent(username=user.username, user=user, used_percent=percent))
create_notification_reminder(db, ReminderType.data_usage,
expires_at=dt.utcfromtimestamp(expire) if expire else None, user_id=user_id)
expires_at=dt.utcfromtimestamp(expire) if expire else None, user_id=user_id)


def expire_days_reached(db: Session, days: int, user: UserResponse, user_id: int, expire: int) -> None:
notify(ReachedDaysLeft(username=user.username, user=user, days_left=days))
if NOTIFY_DAYS_LEFT:
if NOTIFY_IF_DAYS_LEF_REACHED:
create_notification_reminder(
db, ReminderType.expiration_date, expires_at=dt.utcfromtimestamp(expire),
user_id=user_id)
Expand Down
4 changes: 2 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
NOTIFY_USER_DELETED = config("NOTIFY_USER_DELETED", default=True, cast=bool)
NOTIFY_USER_DATA_USED_RESET = config("NOTIFY_USER_DATA_USED_RESET", default=True, cast=bool)
NOTIFY_USER_SUB_REVOKED = config("NOTIFY_USER_SUB_REVOKED", default=True, cast=bool)
NOTIFY_DATA_USAGE_PERCENT_REACHED = config("NOTIFY_DATA_USAGE_PERCENT_REACHED", default=True, cast=bool)
NOTIFY_DAYS_LEFT = config("NOTIFY_DAYS_LEFT", default=True, cast=bool)
NOTIFY_IF_DATA_USAGE_PERCENT_REACHED = config("NOTIFY_IF_DATA_USAGE_PERCENT_REACHED", default=True, cast=bool)
NOTIFY_IF_DAYS_LEF_REACHED = config("NOTIFY_IF_DAYS_LEF_REACHED", default=True, cast=bool)
NOTIFY_LOGIN = config("NOTIFY_LOGIN", default=True, cast=bool)

ACTIVE_STATUS_TEXT = config("ACTIVE_STATUS_TEXT", default="Active")
Expand Down

0 comments on commit 530649d

Please sign in to comment.