funkwhale/api/funkwhale_api/users/adapters.py
Kuba Orlik 3a83290cc0 Fix feed formatting so it passes w3c validation
Feeds generated by Funkwhale do not pass validation with the [w3c
validator](https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fpodcast.midline.pl%2Fapi%2Fv1%2Fchannels%2FMidline%2Frss).
This commit addresses the problems identified during validation:

1. The `isPermalink` is not recognized -> changed it to
   `isPermaLink` (capital "L")

2. `itunes:summary` and `itunes:subtitle` are 256 characters after
   truncating, but the maximum is 255. The truncating function trims the
   text to 255 chars, but then adds `…`, so the text is one character
   too long

3. The tags within `itunes:keywords` are now separated with commas
   instead of spaces (https://validator.w3.org/feed/docs/warning/InvalidKeywords.html)
2020-10-22 15:06:28 +02:00

34 lines
1.1 KiB
Python

from allauth.account.adapter import DefaultAccountAdapter
from django.conf import settings
from dynamic_preferences.registries import global_preferences_registry
def get_email_context():
context = {}
context["funkwhale_url"] = settings.FUNKWHALE_URL
manager = global_preferences_registry.manager()
context["funkwhale_site_name"] = (
manager["instance__name"] or settings.FUNKWHALE_HOSTNAME
)
context["funkwhale_site_domain"] = settings.FUNKWHALE_HOSTNAME
return context
class FunkwhaleAccountAdapter(DefaultAccountAdapter):
def is_open_for_signup(self, request):
manager = global_preferences_registry.manager()
return manager["users__registration_enabled"]
def send_mail(self, template_prefix, email, context):
context.update(get_email_context())
return super().send_mail(template_prefix, email, context)
def get_login_redirect_url(self, request):
return "noop"
def get_signup_redirect_url(self, request):
return "noop"
def add_message(self, *args, **kwargs):
# disable message sending
return