From 81399dd2e4814be5b3a95fb7d1621f15d9ffea0e Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Thu, 31 Jul 2025 10:29:53 +0200 Subject: [PATCH] Only show frontend user apps if they are enabled. --- modoboa/core/api/v2/viewsets.py | 55 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/modoboa/core/api/v2/viewsets.py b/modoboa/core/api/v2/viewsets.py index e6e2fae95..ef80c673f 100644 --- a/modoboa/core/api/v2/viewsets.py +++ b/modoboa/core/api/v2/viewsets.py @@ -1,5 +1,6 @@ """Core API v2 viewsets.""" +from django.conf import settings from django.utils.translation import gettext as _ from django_otp.plugins.otp_static.models import StaticDevice, StaticToken @@ -166,29 +167,37 @@ class AccountViewSet(core_v1_viewsets.AccountViewSet): } ) if hasattr(request.user, "mailbox"): - apps += [ - { - "name": "calendar", - "label": _("Calendars"), - "icon": "mdi-calendar", - "description": _("Calendar"), - "url": "/user/calendars", - }, - { - "name": "contacts", - "label": _("Contacts"), - "icon": "mdi-contacts-outline", - "description": _("Address book"), - "url": "/user/contacts", - }, - { - "name": "webmail", - "label": _("Webmail"), - "icon": "mdi-at", - "description": _("Webmail"), - "url": "/user/webmail", - }, - ] + if "modoboa.contacts" in settings.MODOBOA_APPS: + apps += [ + { + "name": "contacts", + "label": _("Contacts"), + "icon": "mdi-contacts-outline", + "description": _("Address book"), + "url": "/user/contacts", + } + ] + if "modoboa.calendars" in settings.MODOBOA_APPS: + apps += [ + { + "name": "calendar", + "label": _("Calendars"), + "icon": "mdi-calendar", + "description": _("Calendar"), + "url": "/user/calendars", + } + ] + if "modoboa.webmail" in settings.MODOBOA_APPS: + apps += [ + { + "name": "webmail", + "label": _("Webmail"), + "icon": "mdi-at", + "description": _("Webmail"), + "url": "/user/webmail", + } + ] + apps += exts_pool.get_available_apps() serializer = serializers.ModoboaApplicationSerializer(apps, many=True) return response.Response(serializer.data)