Add activity push notifications and registration patches
This commit is contained in:
+4
-1
@@ -1,4 +1,4 @@
|
||||
"""Device registration only. This module deliberately contains no push sender."""
|
||||
"""Device registration. Background sending lives in notifications.py."""
|
||||
|
||||
import hashlib
|
||||
from uuid import UUID
|
||||
@@ -6,6 +6,8 @@ from uuid import UUID
|
||||
from fastapi import Request
|
||||
from fastapi.responses import JSONResponse
|
||||
from pydantic import BaseModel, Field
|
||||
from i18n import current_language
|
||||
from notifications import save_language
|
||||
|
||||
|
||||
class DeviceRegistration(BaseModel):
|
||||
@@ -59,6 +61,7 @@ def register_routes(app, get_db, get_user, cookie_name):
|
||||
RETURNING id
|
||||
''', (user['id'], session[0], data.device_id, data.token, data.platform, data.app_version))
|
||||
device_id = cursor.fetchone()[0]
|
||||
save_language(connection, user['id'], current_language.get())
|
||||
cursor.execute('DELETE FROM push_devices WHERE session_id IN '
|
||||
'(SELECT id FROM sessions WHERE expires_at<=CURRENT_TIMESTAMP) '
|
||||
'OR last_seen_at<CURRENT_TIMESTAMP - INTERVAL \'90 days\'')
|
||||
|
||||
Reference in New Issue
Block a user