Add X-Powered-By header to ease AGPL compliance

This commit is contained in:
Quantum 2022-03-04 00:55:46 -05:00
parent 3dfc0a3682
commit 6f0c3c09a3
3 changed files with 10 additions and 2 deletions

View file

@ -92,3 +92,4 @@ QLINKS_CHECK_MIN = timedelta(days=6)
QLINKS_CHECK_MAX = timedelta(days=8) QLINKS_CHECK_MAX = timedelta(days=8)
QLINKS_CHECK_THROTTLE = 1 QLINKS_CHECK_THROTTLE = 1
QLINKS_BROKEN_EMAIL = False QLINKS_BROKEN_EMAIL = False
QLINKS_POWERED_BY = 'QLinks <https://github.com/quantum5/qlinks>'

View file

@ -77,3 +77,7 @@ QLINKS_CANONICAL = None
# Enable emails. # Enable emails.
# QLINKS_BROKEN_EMAIL = True # QLINKS_BROKEN_EMAIL = True
# Update the X-Powered-By header to point to your fork if you are not running
# upstream code. This is required to comply with AGPLv3.
# QLINKS_POWERED_BY = 'QLinks <https://github.com/YOU/qlinks>'

View file

@ -1,9 +1,12 @@
from django.conf import settings
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render from django.shortcuts import get_object_or_404
from qlinks.models import Link from qlinks.models import Link
def short_link(request, slug): def short_link(request, slug):
link = get_object_or_404(Link.objects.values_list('long', flat=True), short=slug) link = get_object_or_404(Link.objects.values_list('long', flat=True), short=slug)
return HttpResponseRedirect(link) return HttpResponseRedirect(link, headers={
'X-Powered-By': settings.QLINKS_POWERED_BY
})