Add setting to keep migration off by default for now

This commit is contained in:
Andrew Godwin 2023-11-09 11:58:40 -07:00
parent 5cc74900b1
commit e17f17385a
5 changed files with 21 additions and 4 deletions

View File

@ -1,9 +1,12 @@
from django.conf import settings
from core.models import Config from core.models import Config
def config_context(request): def config_context(request):
return { return {
"config": Config.system, "config": Config.system,
"allow_migration": settings.SETUP.ALLOW_USER_MIGRATION,
"top_section": request.path.strip("/").split("/")[0], "top_section": request.path.strip("/").split("/")[0],
"opengraph_defaults": { "opengraph_defaults": {
"og:site_name": Config.system.site_name, "og:site_name": Config.system.site_name,

View File

@ -27,6 +27,11 @@ Minor changes also include:
* Profile pages are no longer shown for remote identities; instead, users are * Profile pages are no longer shown for remote identities; instead, users are
linked or redirected directly to the remote profile page. linked or redirected directly to the remote profile page.
* Inbound migration has been implemented, but is disabled by default as outbound
migration is not yet complete, and we don't want to release a system that
captures users with no outward path. If you *really* want to enable it, set
``TAKAHE_ALLOW_USER_MIGRATION=true`` in your environment.
If you'd like to help with code, design, or other areas, see If you'd like to help with code, design, or other areas, see
:doc:`/contributing` to see how to get in touch. :doc:`/contributing` to see how to get in touch.

View File

@ -151,6 +151,9 @@ class Settings(BaseSettings):
STATOR_CONCURRENCY: int = 50 STATOR_CONCURRENCY: int = 50
STATOR_CONCURRENCY_PER_MODEL: int = 15 STATOR_CONCURRENCY_PER_MODEL: int = 15
# If user migration is allowed (off by default until outbound is done)
ALLOW_USER_MIGRATION: bool = False
# Web Push keys # Web Push keys
# Generate via https://web-push-codelab.glitch.me/ # Generate via https://web-push-codelab.glitch.me/
VAPID_PUBLIC_KEY: str | None = None VAPID_PUBLIC_KEY: str | None = None

View File

@ -14,10 +14,12 @@
<i class="fa-solid fa-cloud-arrow-up"></i> <i class="fa-solid fa-cloud-arrow-up"></i>
<span>Import/Export</span> <span>Import/Export</span>
</a> </a>
{% if allow_migration %}
<a href="{% url "settings_migrate_in" handle=identity.handle %}" {% if section == "migrate_in" %}class="selected"{% endif %} title="Interface"> <a href="{% url "settings_migrate_in" handle=identity.handle %}" {% if section == "migrate_in" %}class="selected"{% endif %} title="Interface">
<i class="fa-solid fa-door-open"></i> <i class="fa-solid fa-door-open"></i>
<span>Migrate Inbound</span> <span>Migrate Inbound</span>
</a> </a>
{% endif %}
<a href="{% url "settings_tokens" handle=identity.handle %}" {% if section == "tokens" %}class="selected"{% endif %} title="Authorized Apps"> <a href="{% url "settings_tokens" handle=identity.handle %}" {% if section == "tokens" %}class="selected"{% endif %} title="Authorized Apps">
<i class="fa-solid fa-window-restore"></i> <i class="fa-solid fa-window-restore"></i>
<span>Authorized Apps</span> <span>Authorized Apps</span>

View File

@ -1,6 +1,8 @@
from django import forms from django import forms
from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import Http404
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.views.generic import FormView from django.views.generic import FormView
@ -38,6 +40,8 @@ class MigrateInPage(IdentityViewMixin, FormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
if not settings.SETUP.ALLOW_USER_MIGRATION:
raise Http404()
# If they asked for an alias deletion, do it here # If they asked for an alias deletion, do it here
if "remove_alias" in self.request.GET: if "remove_alias" in self.request.GET:
self.identity.remove_alias(self.request.GET["remove_alias"]) self.identity.remove_alias(self.request.GET["remove_alias"])