2024-08-23 13:32:32 +02:00
|
|
|
from app.db import Session
|
2024-05-23 10:27:08 +02:00
|
|
|
from app.events.event_dispatcher import EventDispatcher
|
2024-06-07 15:36:18 +02:00
|
|
|
from app.events.generated.event_pb2 import EventContent, UserPlanChanged
|
2023-05-26 15:33:55 +02:00
|
|
|
from app.models import User
|
|
|
|
|
|
|
|
|
|
|
|
def execute_subscription_webhook(user: User):
|
|
|
|
subscription_end = user.get_active_subscription_end(
|
|
|
|
include_partner_subscription=False
|
|
|
|
)
|
|
|
|
sl_subscription_end = None
|
|
|
|
if subscription_end:
|
|
|
|
sl_subscription_end = subscription_end.timestamp
|
2024-06-07 15:36:18 +02:00
|
|
|
event = UserPlanChanged(plan_end_time=sl_subscription_end)
|
2024-05-23 10:27:08 +02:00
|
|
|
EventDispatcher.send_event(user, EventContent(user_plan_change=event))
|
2024-08-23 13:32:32 +02:00
|
|
|
Session.commit()
|