FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: store the email on the instance by MontaGhanmy · Pull Request #4934 · linagora/cozy-stack · GitHub

Repository navigation

feat: store the email on the instance - #4934

Merged
MontaGhanmy merged 6 commits into
masterfrom
feat/instance-internal-email
Oct 1, 2026
Merged

MontaGhanmy merged 6 commits into
masterfrom
feat/instance-internal-email

Conversation

MontaGhanmy commented Sep 22, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

  • user.created now stores the owner's email on the instance (email), lowercased and trimmed, so an instance can be found from its owner's email.
  • lifecycle.GetInstanceByEmail does that lookup through a new by-email global index. An email found on several instances is an error rather than a guess.
  • SetEmail takes a lock on the email and checks the by-email index before writing, so two instances cannot hold the same email, even when updated concurrently. It returns ErrEmailTaken otherwise, and user.created logs it and acks the message instead of requeuing it forever.
  • cozy-stack fix emails (POST /instances/fixers/emails) backfills existing instances from their settings email. It skips organization instances, keeps an email already set, lists the emails found on several instances for manual resolution, and writes nothing if a settings email can't be read. --dry-run reports without writing.

MontaGhanmy force-pushed the feat/instance-internal-email branch from f459d8d to 73cf9d0 Compare September 29, 2026 16:20
Comment thread worker/migrations/migrations.go Outdated
Comment thread worker/migrations/migrations.go Outdated
The field holds the owner's email for Twake and classic Cozy instances
alike, so it is stored as email, indexed by-email, and the fixer and
migration are named after it too. The internalEmail field of the RabbitMQ
messages is the platform contract and keeps its name.
SetEmail now takes a lock on the email and checks the by-email index
before writing, so two instances cannot end up with the same email,
even when they are updated concurrently.

The backfill reports such an email as a duplicate instead of an error,
and the user.created handler logs it and acks the message, since
requeuing it would loop forever.
The emails fixer already backfills every instance, with a dry run and a
report of the duplicates across organizations, so it is kept as the
single entry point.
MontaGhanmy changed the title feat: store the internal email on the instance feat: store the email on the instance Sep 30, 2026
MontaGhanmy self-assigned this Oct 1, 2026
MontaGhanmy merged commit de018cf into master Oct 1, 2026
4 checks passed
MontaGhanmy deleted the feat/instance-internal-email branch October 1, 2026 08:34
MontaGhanmy added a commit that referenced this pull request Oct 6, 2026
Stacked on #4934. Part 2 of #4796.

## Summary

The instance email is now a normalized mirror of the settings email.

- `instance.SyncEmail` is the single place that copies the settings
email to the instance: normalized, empty values ignored, organization
instances skipped (as in the backfill). It goes through `SetEmail`, so
the lock and the duplicate check of #4934 apply. An email held by
another instance is logged and left out, since the settings update is
already saved.
- Instance creation fills the email from the settings email.
- `lifecycle.Patch` syncs it on every settings update. That covers `PUT
/settings/instance`, the admin instance `PATCH` and the RabbitMQ
handlers, and any settings update brings back a drifted email.
- `user.created` now writes the email to the settings through
`lifecycle.Patch` instead of beside them, so there is a single source.
- `ConfirmEmailUpdate` (the email change confirmation flow) syncs it
too, through the instance service.
- `SetEmail` and `FindByEmail` move from `lifecycle` to the `instance`
package, so the settings service can reach them.
- Fixes `instance.Mock.Update`, which read the second return value of a
single-error method and panicked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL