Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding preferred domains #16

Merged
merged 3 commits into from
Aug 18, 2020
Merged

Adding preferred domains #16

merged 3 commits into from
Aug 18, 2020

Conversation

Dynom
Copy link
Owner

@Dynom Dynom commented Aug 18, 2020

Certain e-mail providers discriminate based on their TLD. Hotmail, for example, can have e-mail addresses on Hotmail.fr or Hotmail.nl which won't work on Hotmail.com. While all domains are legitimate e-mail receiving domains.

To compensate for this behaviour, I've added the feature to have a preferred mapping. This PR introduces the mapping, which you can specify in the configuration file or as runtime flags. This allows you to hint your users to a more preferred domain, while keeping the option open to allow for their specific choice.

The preferred alternative will be prepended to the otherwise found alternative. This means it'll also work on bad (but syntactically valid) results.

Example

This will offer the following suggestion:
Request

{
    "email": "this-is-just-a-test@hotmail.ln"
}

Response

{
    "alternatives": [
        "this-is-just-a-test@hotmail.com",
        "this-is-just-a-test@hotmail.nl"
    ],
    "malformed_syntax": false
}

Configuration

config.toml

     [services.suggest.prefer]
        # The syntax is: "<domain>" = "<preferred domain>"
        "hotmail.fr" = "hotmail.com"
        "hotmail.nl" = "hotmail.com"

flags
The equivalent with flags:

./web --services-suggest-prefer hotmail.fr=hotmail.com --services-suggest-prefer hotmail.nl=hotmail.com

@codecov-commenter
Copy link

Codecov Report

Merging #16 into master will increase coverage by 0.10%.
The diff coverage is 63.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #16      +/-   ##
==========================================
+ Coverage   47.76%   47.87%   +0.10%     
==========================================
  Files          35       36       +1     
  Lines        1790     1832      +42     
==========================================
+ Hits          855      877      +22     
- Misses        917      933      +16     
- Partials       18       22       +4     
Impacted Files Coverage Δ
cmd/web/main.go 0.00% <0.00%> (ø)
cmd/web/config/config.go 75.26% <17.64%> (-12.89%) ⬇️
cmd/web/services/suggest.go 88.70% <83.87%> (-6.85%) ⬇️
cmd/web/preferrer/preferrer.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ead6740...b3549e4. Read the comment docs.

@Dynom Dynom merged commit 4de8ad3 into master Aug 18, 2020
@Dynom Dynom deleted the AddingPreferredDomains branch August 18, 2020 11:59
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.

2 participants