feat(notification): add target_mode enum constraint and merge register-notifications script
- Add NotificationTargetMode enum (new_users/exist_users/all_users/user_ids) - Create Alembic migrations: drop duplicate indexes, add target_mode column - Merge register-notifications.sh into dev-migrate.sh sync-notifications subcommand - Shorten notification config path: static/notification/notifications -> static/notifications - Update registration flow to dispatch notifications by target_mode - Add is_first_registration to RegisterBonusResult for first-time user detection - Remove dead code: link_published_notifications_to_user - Update welcome_points.yaml to target new_users only - Add 44 unit tests + 1 integration test, all passing
This commit is contained in:
@@ -61,6 +61,7 @@ class RegisterBonusResult:
|
||||
amount: int
|
||||
balance_after: int
|
||||
event_id: str
|
||||
is_first_registration: bool = False
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -122,14 +123,17 @@ class PointsService:
|
||||
account = await self._repository.get_or_create_user_points_for_update(
|
||||
user_id=user_id
|
||||
)
|
||||
if claim is not None and claim.balance_snapshot is not None:
|
||||
account.balance = max(int(claim.balance_snapshot), 0)
|
||||
account.version = int(account.version) + 1
|
||||
if claim is not None:
|
||||
is_first_registration = claim.first_user_id_snapshot is None
|
||||
if claim.balance_snapshot is not None:
|
||||
account.balance = max(int(claim.balance_snapshot), 0)
|
||||
account.version = int(account.version) + 1
|
||||
return RegisterBonusResult(
|
||||
granted=False,
|
||||
amount=0,
|
||||
balance_after=int(account.balance),
|
||||
event_id=event_id,
|
||||
is_first_registration=is_first_registration,
|
||||
)
|
||||
|
||||
claimed = await self._repository.claim_register_bonus(
|
||||
@@ -144,6 +148,7 @@ class PointsService:
|
||||
amount=0,
|
||||
balance_after=int(account.balance),
|
||||
event_id=event_id,
|
||||
is_first_registration=False,
|
||||
)
|
||||
|
||||
balance = int(account.balance)
|
||||
@@ -197,6 +202,7 @@ class PointsService:
|
||||
amount=bonus_points,
|
||||
balance_after=int(account.balance),
|
||||
event_id=event_id,
|
||||
is_first_registration=True,
|
||||
)
|
||||
|
||||
async def ensure_run_points_available(
|
||||
|
||||
Reference in New Issue
Block a user