-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2025 Wire Swiss GmbH <opensource@wire.com>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Wire.API.Routes.Features where

import Wire.API.Conversation.Role
import Wire.API.Error.Galley
import Wire.API.Routes.Version (Version (V17))
import Wire.API.Team.Feature

type family FeatureErrors cfg where
  FeatureErrors LegalholdConfig =
    '[ 'ActionDenied 'RemoveConversationMember,
       'CannotEnableLegalHoldServiceLargeTeam,
       'LegalHoldNotEnabled,
       'LegalHoldDisableUnimplemented,
       'LegalHoldServiceNotRegistered,
       'UserLegalHoldIllegalOperation,
       'LegalHoldCouldNotBlockConnections
     ]
  FeatureErrors _ = '[]

type family FeatureAPIDesc cfg where
  FeatureAPIDesc EnforceFileDownloadLocationConfig =
    "<p><b>Custom feature: only supported on some dedicated on-prem systems.</b></p>"
  FeatureAPIDesc RequireExternalEmailVerificationConfig =
    "<p>Controls whether externally managed email addresses (from SAML or SCIM) must be verified by the user, or are auto-activated.</p><p>The external feature name is kept as <code>validateSAMLemails</code> for backward compatibility. That name is misleading because the feature also applies to SCIM-managed users, and it controls email ownership verification rather than generic email validation.</p>"
  FeatureAPIDesc _ = ""

type family VersionedFeatureAPIDesc v cfg where
  VersionedFeatureAPIDesc V17 PreventAdminlessGroupsConfig =
    "<p>For API version 17, use duration strings for the timeout fields. The request body must have the following shape:</p><pre>{\n  &quot;config&quot;: {\n    &quot;deletionTimeoutDuration&quot;: &quot;7d&quot;,\n    &quot;promotionStrategy&quot;: &quot;alphabetical&quot;,\n    &quot;reminderTimeoutDurations&quot;: [\n      &quot;2d&quot;,\n      &quot;4d&quot;,\n      &quot;6d&quot;\n    ]\n  },\n  &quot;status&quot;: &quot;enabled&quot;\n}</pre><p>Older API versions use the legacy numeric fields <code>deletionTimeout</code> and <code>reminderTimeouts</code>.</p>"
  VersionedFeatureAPIDesc _ cfg = FeatureAPIDesc cfg
