Skip to content

[19.0][MIG] mail_gateway: Migration to 19.0 - #202

Open
DucTruongKomit wants to merge 385 commits into
OCA:19.0from
komit-consulting:19.0-mig-mail_gateway
Open

[19.0][MIG] mail_gateway: Migration to 19.0#202
DucTruongKomit wants to merge 385 commits into
OCA:19.0from
komit-consulting:19.0-mig-mail_gateway

Conversation

@DucTruongKomit

@DucTruongKomit DucTruongKomit commented Jun 1, 2026

Copy link
Copy Markdown

[MIG] mail_gateway: Migration to 19.0

@pedrobaeza

Copy link
Copy Markdown
Member

Thanks for the move. I'm afraid you have lost the commit history. You should do a similar method than the migration one, but adding an extra remote for OCA/social.

@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch 14 times, most recently from 5e50ef4 to 7c9d8cc Compare June 1, 2026 11:17
@DucTruongKomit

Copy link
Copy Markdown
Author

Thanks for the move. I'm afraid you have lost the commit history. You should do a similar method than the migration one, but adding an extra remote for OCA/social.

yes, I did.

@pedrobaeza

Copy link
Copy Markdown
Member

Can you check CIs?

@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch 3 times, most recently from 0ec67ff to a649485 Compare June 2, 2026 01:31
@DucTruongKomit
DucTruongKomit marked this pull request as draft June 2, 2026 04:01
@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch 3 times, most recently from 56e4d37 to 6e924d8 Compare June 5, 2026 09:30

@huan-tq huan-tq left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Functional Testing:

  • The Menus introduced by this module are available.
  • The Gateway buttons are available throughout the system.
  • This is a base module intended to be extended by other mail_gateway modules.

LGTM.

@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch 2 times, most recently from 8706f65 to e169248 Compare June 12, 2026 10:05
Jairo Llopis and others added 24 commits July 31, 2026 16:41
Before this patch, the module was designed after the [deprecated Mailgun webhooks][3]. However Mailgun had the [events API][2] which was quite different. Modern Mailgun has deprecated those webhooks and instead uses new ones that include the same payload as the events API, so you can reuse code.

However, this was incorrectly reusing the code inversely: trying to process the events API through the same code prepared for the deprecated webhooks.

Besides, both `failed` and `rejected` mailgun events were mapped to `error` state, but that was also wrong because [`mail_tracking` doesn't have an `error` state][1].

So the logic of the whole module is changed, adapting it to process the events API payload, both through controllers (prepared for the new webhooks) and manual updates that directly call the events API.

Also, `rejected` is now translated into `reject`, and `failed` is translated into `hard_bounce` or `soft_bounce` depending on the severity, as specified by [mailgun docs][2]. Also, `bounced` and `dropped` mailgun states are removed because they don't exist, and instead `failed` and `rejected` properly get their metadata.

Of course, to know the severity, now the method to obtain that info must change, it' can't be a simple dict anymore.

Added more parameters because for example modern Mailgun uses different keys for signing payload than for accessing the API. As there are so many parameters, configuration is now possible through `res.config.settings`. Go there to autoregister webhooks too.

Since the new webhooks are completely incompatible with the old supposedly-abstract webhooks controllers (that were never really that abstract), support for old webhooks is removed, and it will be removed in the future from `mail_tracking` directly. There is a migration script that attempts to unregister old webhooks and register new ones automatically.

[1]: https://github.com/OCA/social/blob/f73de421e28a43d018176f61725a3a59665f715d/mail_tracking/models/mail_tracking_event.py#L31-L42
[2]: https://documentation.mailgun.com/en/latest/api-events.html#event-types
[3]: https://documentation.mailgun.com/en/latest/api-webhooks-deprecated.html
Mass mailing are tracked from mail.trace as the don't store a message in
the db. In order to gather the message_id and be able to do manual
checks to mailgun, that's the table where we should get the message id.

TT40816
Since odoo/odoo@9a47101
bouncing the emails through the mailgun controller causes a singleton
error when the anonymous user tries to record the bounce message.

TT44585
Currently translated at 100.0% (60 of 60 strings)

Translation: social-15.0/social-15.0-mail_tracking_mailgun
Translate-URL: https://translation.odoo-community.org/projects/social-15-0/social-15-0-mail_tracking_mailgun/es/
- Fix tests
- Fix warnings
- Improve code
- Get rid of superfluous stuff
- Remove auto-validation. It couldn't be working as it was and it would
  drag performance on contacts creation/write if active.

TT44207
Currently translated at 100.0% (58 of 58 strings)

Translation: social-16.0/social-16.0-mail_tracking_mailgun
Translate-URL: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_tracking_mailgun/it/
Currently translated at 37.9% (22 of 58 strings)

Translation: social-16.0/social-16.0-mail_tracking_mailgun
Translate-URL: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_tracking_mailgun/fr/
When we use the same Mailgun domain for other services, the email events
for those services we'll be pushed to the Odoo controller as well. We
want to discard them as they're useless to us.

Aside from that, in the case a wrong db is called to the controller, we
better logging the failed request is going to be more useful than
raising an error.
Correct link message on the chatter, using also the provided native
method instead of building it manually.
WARNING prod py.warnings: /opt/odoo/auto/addons/mail_tracking_mailgun/controllers/main.py:28: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).

WARNING prod py.warnings: /opt/odoo/auto/addons/mail_tracking_mailgun/models/mail_tracking_email.py:106: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch from 41c6b42 to e36d783 Compare July 31, 2026 11:08
@DucTruongKomit

Copy link
Copy Markdown
Author

@hieulucky111 @Quan-nhm @Willysan2020 I updated the code, thank you

@DucTruongKomit
DucTruongKomit force-pushed the 19.0-mig-mail_gateway branch from 9eaba56 to cf4ea59 Compare July 31, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.