Skip to content

[IMP] gmail: remove the enrichment feature from the addon#52

Merged
tde-banana-odoo merged 7 commits intoodoo:masterfrom
std-odoo:master-mail-plugin-rework-no-iap-std
Jan 9, 2026
Merged

[IMP] gmail: remove the enrichment feature from the addon#52
tde-banana-odoo merged 7 commits intoodoo:masterfrom
std-odoo:master-mail-plugin-rework-no-iap-std

Conversation

@std-odoo
Copy link
Contributor

@std-odoo std-odoo commented Sep 30, 2025

Remove the enrichment feature

Then enrichment feature of the addon made it slow and hard to use in
practice, so we simplify it, and we keep only the core feature, which
is logging the email on the records and viewing information about the
contact.

Move from appscript to HTTP addin

The current addin is slow, because of how appscript work (Google host
a web server, with our app running, that server restart at each call,
the language itself is synchronous...).

In alternative way of creating addin, is to host the application ourselves.
It's faster because we can keep the server alive, and we can make the
HTTP calls in parallel (to the Gmail API and to the Odoo database).

https://developers.google.com/workspace/add-ons/guides/alternate-runtimes

UI

If a conversation contains many contacts, before it took the first
one. We can now choose the contact we want to open.

Allow searching any records, not only partners.

We fixed some UI issues than were introduced by
update of the Gmail API.

Technical

Serve image file instead of encoding in base 64 (now that we use HTTP addin).
Prevent state modification with JWT (the process of the server is now share among the users).

Task-4727609

@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 6 times, most recently from e679c10 to 2da20fd Compare October 3, 2025 12:50
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 3 times, most recently from 173c0ec to d710a18 Compare October 13, 2025 13:40
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 4 times, most recently from e259ed2 to 89e1fb5 Compare October 15, 2025 12:50
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 4 times, most recently from 6a4bfa2 to 4610569 Compare October 23, 2025 12:55
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 2 times, most recently from df57832 to 8784f69 Compare October 30, 2025 15:41
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 6 times, most recently from 36c5354 to 9d9c14a Compare November 20, 2025 14:04
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch from 9d9c14a to 6e15be2 Compare November 24, 2025 12:07
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 4 times, most recently from 7407ba1 to 1a8cfd2 Compare December 3, 2025 13:05
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 7 times, most recently from 0c8e3ce to 243823e Compare December 6, 2025 19:03
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 5 times, most recently from 4c8a33e to b0f1f54 Compare December 23, 2025 08:38
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch 3 times, most recently from e78683b to fe52487 Compare January 8, 2026 10:24
Copy link
Collaborator

@tde-banana-odoo tde-banana-odoo left a comment

Choose a reason for hiding this comment

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

Zboing, thanks for your work, quite a big PR and nice work done here !

Added some questions and while going through, in addition to what we already discussed. Should be quick to answer / update, so we can probably close this soonish :) :) .

Thanks again, addin people are going to be happy !


constructor(
id: number,
email: string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure we always receive a normalized email ? As we search for exact email ( _getUserFromEmail ), asking to be sure we won't run into formatted email issues as we had in standard odoo ^^

Copy link
Collaborator

Choose a reason for hiding this comment

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

Globally, question is: do we always deal with normalized emails for users ? Their gmail email probably, but asking to be sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think yes, or at least, the google api should always return the same value
(as we use that information to login the user, I wouldn't be confident to do some post-processing on the value I receive from the api, as it could result in authentication bypass...)

"res.partner": [],
"crm.lead": [],
"helpdesk.ticket": [],
"project.task": [],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wild question: wouldn't we support applicants at some point ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know 🙂 might be a cool idea

const body = _formatEmailBody(_t, rawBody, error);

const response = await postJsonRpc(
user.odooUrl + URLS.LOG_EMAIL,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same global remarks for recipients: seems we don't keep recipients ? Especially we can now store raw emails on message model (incoming_email_to and incoming_email_cc) for that purpose, allowing to avoid creating useless partners.

Copy link
Contributor Author

@std-odoo std-odoo Jan 9, 2026

Choose a reason for hiding this comment

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

good idea 🙂

Note that in discuss, the "reply to" button just reply to the email_from when there's no "reply-to" header, but I guess it should be for an other task

} catch {
return ERROR_PAGE.replace(
"__ERROR_MESSAGE__",
"The token exchange failed. Maybe your token has expired or your database can not be reached by the Google server." +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will that be translated ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it is before the odoo authentication, so we cannot do a request to know which language the user has on his settings
(same for the buttons on the login page, they will be always in English)

@tde-banana-odoo
Copy link
Collaborator

Also feels like the PR message is a bit centered on IAP while the changes are a bit broader ^^

Purpose
=======
Because we cannot close the popup in which the user login like before,
we now show the rainbow man when we have received the access token
during the login flow.

Task-4727609
Purpose
=======
Before the subject, email from, etc were added in the body of the
email when we log it in a record. Now, those values are properly written
in the fields of the `mail.message`, and so we need to send them to the
Odoo endpoint.

Parse all the contacts in the email TO, CC,... to prepare the
following commit.

Before, if we wait some time before logging the email on a record,
an error could be raised because the token we received to get the
information expired. To solve that issue, we parse and save then in
the state when the addin is loaded.

Task-4727609
Purpose
=======
Then enrichment feature of the addon made it slow and hard to use in
practice, so we simplify it, and we keep only the core feature, which
is logging the email on the records and viewing information about the
contact.

If a conversation contains many contacts, before it took the first
one. We can now choose the contact we want to open.

Allow searching any records, not only partners.

We fixed some UI issues than were introduced by
update of the Gmail API.

Task-4727609
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch from fe52487 to 8d6b2e1 Compare January 9, 2026 09:28
Purpose
=======
The current addin is slow, because of how appscript work (Google host
a web server, with our app running, that server restart at each call,
the language itself is synchronous...).

In alternative way of creating addin, is to host the application ourselves.
It's faster because we can keep the server alive, and we can make the
HTTP calls in parallel (to the Gmail API and to the Odoo database).
> https://developers.google.com/workspace/add-ons/guides/alternate-runtimes

We choose to use node with express, because it's asynchronous, and we
will make a lot of request (to the Odoo database, to the Gmail API, etc).

Also, most of the code can be re-used (the core logic).

The main changes compared to appscript are
- we need to store the user settings ourselves (and we use psql for that)
- so the translations and the email logging state is moved to the user
  (it's considered as "User Settings / Information").
- to build the view, our endpoints need to return JSON, so we created
  some helper classes similar to the one use by appscript (no official
  library exists for that at the moment, for typescript)

The application has been kept as similar as the one using appscript as
possible (the execution of action, with the state of the current page
is sent in the response).

Task-4727609
Purpose
=======
Now that all users will share the same process on the server,
we want to prevent the state from being modified by using JWT token.

Task-4727609
Purpose
=======
When we used appscript, we didn't have a web server to store the image
(and to do the processing to translate text inside the SVG), and so
we base 64 encoded them. Now that we moved the HTTP addin, we have a
web server, and we can serve the files (and translate them on the fly),
so that the images are cached by the browser, and we don't download
them each time we view a new card.

When Gmail shows images, it doesn't add our URL in the dom, instead
it fetches the image, and store it in `googleusercontent.com`. But,
it won't fetch the images if they come from a ngrok domain name, so
now, we need a "real" domain name for development.

Task-4727609
@std-odoo std-odoo force-pushed the master-mail-plugin-rework-no-iap-std branch from 8d6b2e1 to 7b988ea Compare January 9, 2026 10:27
Copy link
Contributor Author

@std-odoo std-odoo left a comment

Choose a reason for hiding this comment

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

@tde-banana-odoo Hi 🙂

I did the changes and answered 🙂

Cheers

const userEmail = user.email.toLowerCase();
const contacts = [
...this._emailSplitTuple(headers["to"] || "", userEmail),
...this._emailSplitTuple(headers["from"] || "", userEmail),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's in case you open an email you sent, vs an email you received (otherwise you will see your own partner)

(it's more a "list of users in the email headers", but a bit long 😅)

} catch {
return ERROR_PAGE.replace(
"__ERROR_MESSAGE__",
"The token exchange failed. Maybe your token has expired or your database can not be reached by the Google server." +
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it is before the odoo authentication, so we cannot do a request to know which language the user has on his settings
(same for the buttons on the login page, they will be always in English)

const body = _formatEmailBody(_t, rawBody, error);

const response = await postJsonRpc(
user.odooUrl + URLS.LOG_EMAIL,
Copy link
Contributor Author

@std-odoo std-odoo Jan 9, 2026

Choose a reason for hiding this comment

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

good idea 🙂

Note that in discuss, the "reply to" button just reply to the email_from when there's no "reply-to" header, but I guess it should be for an other task

@tde-banana-odoo tde-banana-odoo merged commit 6695811 into odoo:master Jan 9, 2026
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