TF-3985 Prefer to use domain from platform rather than from email
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:tmail_ui_user/features/paywall/domain/model/paywall_url_pattern.
|
||||
import 'package:tmail_ui_user/features/paywall/domain/usecases/get_paywall_url_interactor.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_utils.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||
|
||||
extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
|
||||
@@ -43,6 +44,7 @@ extension ValidateSaasPremiumAvailableExtension on MailboxDashBoardController {
|
||||
|
||||
final qualifiedPaywall = paywallUrlPattern!.getQualifiedUrl(
|
||||
ownerEmail: ownEmailAddress.value,
|
||||
domainName: RouteUtils.getRootDomain(),
|
||||
);
|
||||
|
||||
AppUtils.launchLink(qualifiedPaywall);
|
||||
|
||||
@@ -14,7 +14,7 @@ class PaywallUrlPattern with EquatableMixin {
|
||||
return PaywallUtils.buildPaywallUrlFromTemplate(
|
||||
template: pattern,
|
||||
localPart: mailAddress?.localPart,
|
||||
domainName: mailAddress?.domain.domainName,
|
||||
domainName: domainName ?? mailAddress?.domain.domainName,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -264,4 +264,20 @@ abstract class RouteUtils {
|
||||
static String generateMailtoLink(String mailAddress) {
|
||||
return '$baseOriginUrl/$mailtoPrefix/?uri=$mailtoPrefix:$mailAddress';
|
||||
}
|
||||
|
||||
static String? getRootDomain({String? hostname}) {
|
||||
final host = hostname ?? html.window.location.hostname;
|
||||
|
||||
if (host == null || host.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final parts = host.split('.');
|
||||
|
||||
if (parts.length >= 2) {
|
||||
return '${parts[parts.length - 2]}.${parts.last}';
|
||||
}
|
||||
|
||||
return host;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user