Merge branch 'main' of ssh://git.autonomic.zone:2222/decentral1se/startinblox-startinoff into main
no idea what is different
This commit is contained in:
commit
379b349e19
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,3 @@
|
||||
/static/
|
||||
settings.yml
|
||||
static/
|
||||
server/__pycache__
|
||||
|
@ -1,6 +1,11 @@
|
||||
dependencies:
|
||||
djangoldp_notifications
|
||||
- djangoldp_account
|
||||
- djangoldp_notification
|
||||
- django-webpush
|
||||
|
||||
ldppackages:
|
||||
- djangoldp_account
|
||||
- djangoldp_notification
|
||||
|
||||
server:
|
||||
DEBUG: true
|
||||
@ -11,6 +16,7 @@ server:
|
||||
default:
|
||||
ENGINE: django.db.backends.postgresql_psycopg2
|
||||
NAME: djangoldp
|
||||
USER: postgres
|
||||
LDP_RDF_CONTEXT: https://cdn.happy-dev.fr/owl/hdcontext.jsonld
|
||||
ROOT_URLCONF: server.urls
|
||||
STATIC_ROOT: static
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@ from django.views.decorators.http import require_GET
|
||||
from django.http.response import JsonResponse, HttpResponse
|
||||
from django.views.decorators.http import require_GET, require_POST
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.contrib.auth.models import User
|
||||
from djangoldp_account.models import LDPUser
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from webpush import send_user_notification
|
||||
from django.conf import settings
|
||||
@ -27,10 +27,10 @@ def send_push(request):
|
||||
return JsonResponse(status=400, data={"message": "Invalid data format"})
|
||||
|
||||
user_id = data['id']
|
||||
user = get_object_or_404(User, pk=user_id)
|
||||
user = get_object_or_404(LDPUser, pk=user_id)
|
||||
payload = {'head': data['head'], 'body': data['body']}
|
||||
send_user_notification(user=user, payload=payload, ttl=1000)
|
||||
|
||||
return JsonResponse(status=200, data={"message": "Web push successful"})
|
||||
except TypeError:
|
||||
return JsonResponse(status=500, data={"message": "An error occurred"})
|
||||
return JsonResponse(status=500, data={"message": "An error occurred"})
|
||||
|
Loading…
Reference in New Issue
Block a user