Skip to content

Conversation

@dab246
Copy link
Member

@dab246 dab246 commented Nov 12, 2025

Issue

#4145

Summary

Refactor the logic to generate the Paywall URL using the user's workplaceFqdn instead of relying solely on static domain resolution.

Context

Previously, the Paywall URL was built using a default fallback pattern (pattern.getQualifiedUrl), which combined the user's email and a root domain from RouteUtils.getRootDomain(). This approach worked, but did not respect the user’s actual workspace domain (FQDN).

To fix this, the system now leverages the workplaceFqdn obtained from the authenticated OIDC user info (oidcUserInfo.workplaceFqdn) to dynamically generate the Paywall URL for the correct tenant.

Implementation Details

  1. Using WebLinkGenerator.safeGenerateWebLink
  • The workplaceFqdn value (e.g. alice.example.app) is passed to WebLinkGenerator to construct the Paywall URL.
  • The method automatically handles malformed or missing values and guarantees a valid https:// link.
  • Example
WebLinkGenerator.safeGenerateWebLink(workplaceFqdn: 'alice.example.app');
// → https://alice.example.app/
  1. Improved fallback behavior

If workplaceFqdn is unavailable or invalid, the code now gracefully falls back to:

pattern.getQualifiedUrl(
  ownerEmail: ownEmailAddress,
  domainName: RouteUtils.getRootDomain(),
);

This ensures that even in the worst case, the Paywall link remains functional.

@github-actions
Copy link

This PR has been deployed to https://linagora.github.io/tmail-flutter/4147.

/// Generates a web link based on a workplace FQDN and app slug.
///
/// Throws [ArgumentError] when input is invalid.
static String generateWebLink({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for paywall, it should not the same pattern: https://tdvudev.stg.lin-saas.com/settings/premium, so IMO, we should have a different way to generate paywall link

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not according to the ADR description of this issue we need to generate paywall from workplaceFqdn. The generateWebLink function is the function used to handle workplaceFqdn, so we still need it. And if we handle it according to this function our current paywall will be https://tdvudev.stg.lin-saas.com/premium instead of https://tdvudev.stg.lin-saas.com/settings/premium. And we also have a fallback for if this generateWebLink process fails. We will get the paywall link generated from eco-system

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated paywall url correctly from workplaceFqdn

@dab246 dab246 requested a review from hoangdat November 14, 2025 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants