2022-12-02 22:21:18 +00:00
|
|
|
from files.routes.wrappers import *
|
|
|
|
from files.__main__ import app
|
|
|
|
from flask import request, g
|
|
|
|
from files.classes.push_subscriptions import PushSubscription
|
|
|
|
|
|
|
|
@app.post("/push_subscribe")
|
2023-01-21 04:39:46 +00:00
|
|
|
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
|
2022-12-02 22:21:18 +00:00
|
|
|
@auth_required
|
|
|
|
def push_subscribe(v):
|
|
|
|
subscription_json = request.values.get("subscription_json")
|
|
|
|
|
|
|
|
subscription = g.db.query(PushSubscription).filter_by(
|
|
|
|
user_id=v.id,
|
|
|
|
subscription_json=subscription_json,
|
|
|
|
).one_or_none()
|
|
|
|
|
|
|
|
if not subscription:
|
|
|
|
subscription = PushSubscription(
|
|
|
|
user_id=v.id,
|
|
|
|
subscription_json=subscription_json,
|
|
|
|
)
|
|
|
|
g.db.add(subscription)
|
2023-01-01 11:36:20 +00:00
|
|
|
|
2022-12-02 22:21:18 +00:00
|
|
|
return ''
|