git ignore and minor webpush fix

This commit is contained in:
Fay Arnold 2021-04-01 16:20:17 +01:00
parent 49148320ee
commit 252ac0ef7b
7 changed files with 41 additions and 4 deletions

4
.gitignore vendored
View File

@ -1 +1,3 @@
/static/
settings.yml
static/
server/__pycache__

35
example-settings.yml Normal file
View File

@ -0,0 +1,35 @@
dependencies:
- djangoldp_account
- djangoldp_notification
- django-webpush
ldppackages:
- djangoldp_account
- djangoldp_notification
server:
DEBUG: true
ALLOWED_HOSTS:
- "*"
SECRET_KEY: "ak$t4x@9pcs$ypwt_m38)vcg^m=q@j7*2rs2gu7%h0wwcv)(y2"
DATABASES:
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
# STATIC_URL: = '/static/'
# STATICFILES_DIRS: = '/Users/trav/Documents/gitnsurge/autonomic/startinblox/startinblox-startinoff'
MEDIA_ROOT: media
INSTALLED_APPS:
- server
- djangoldp_crypto # only needed by decentral1se for #236
- webpush
WEBPUSH_SETTINGS:
VAPID_PUBLIC_KEY: "BIDVJ0sd4Cyycf_aGCxhQ_SmXBneWboI3wGO-Iyj3ofeGkvYyNp5o6W9eTf13YkJSz6NlRwiCHA08m8e82n5WXI"
VAPID_PRIVATE_KEY: "zQ-Apj3yLGvcq-l_YNFMFgNVBxQ5_JYEsUbZA36Yhes"
VAPID_ADMIN_EMAIL: "trav@teafry.me"

View File

@ -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,7 +27,7 @@ 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)