fix: change push.register return type to tuple and only send welcome notification on new registration
This commit is contained in:
+3
-3
@@ -250,7 +250,7 @@ async def notify_user(user_uid: str, payload: dict[str, Any]) -> None:
|
||||
|
||||
async def register(
|
||||
user_uid: str, endpoint: str, key_auth: str, key_p256dh: str
|
||||
) -> dict[str, Any]:
|
||||
) -> tuple[dict[str, Any], bool]:
|
||||
table = get_table("push_registration")
|
||||
existing = table.find_one(
|
||||
user_uid=user_uid,
|
||||
@@ -261,7 +261,7 @@ async def register(
|
||||
)
|
||||
if existing:
|
||||
logger.debug("Push subscription already registered for user %s", user_uid)
|
||||
return existing
|
||||
return existing, False
|
||||
|
||||
record = {
|
||||
"uid": generate_uid(),
|
||||
@@ -274,4 +274,4 @@ async def register(
|
||||
}
|
||||
table.insert(record)
|
||||
logger.info("Registered push subscription for user %s", user_uid)
|
||||
return record
|
||||
return record, True
|
||||
|
||||
Reference in New Issue
Block a user