-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Emails sent and received by email aliases are not associated with the workspaceMember #5748
Comments
Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :). To resolve the issue, follow these steps:
async function getEmailAliases(userId) {
const res = await gmail.users.settings.sendAs.list({ userId });
return res.data.sendAs.map(alias => alias.sendAsEmail);
}
async function processMessage(message) {
const aliases = await getEmailAliases(message.userId);
const isAlias = email => aliases.includes(email);
if (isAlias(message.sender) || message.recipients.some(isAlias)) {
// Associate with workspaceMember
associateWithWorkspaceMember(message);
}
}
function createContactIfNotExists(email) {
if (!contactExists(email)) {
createContact(email);
}
}
function processMessage(message) {
const aliases = await getEmailAliases(message.userId);
const isAlias = email => aliases.includes(email);
if (isAlias(message.sender) || message.recipients.some(isAlias)) {
// Associate with workspaceMember
associateWithWorkspaceMember(message);
// Create contacts
message.recipients.forEach(createContactIfNotExists);
}
} Update the relevant files in the References |
We should store all aliases within our DB. If we try to hack this we will probably have more issues down the line Not sure how we will keep this data fresh, is there a webhook update for alias creation/deletion? |
@FelixMalfait We can try to implement alias webhook update once we have implemented it for messaging. In the meantime, we could just fetch user aliases before at the start of the message import job (doing it at the same time as we refresh connectedAccount access token for example). I would create an handleAliases ARRAY field to the messageChannel |
@charlesBochet Great! As long as we store all alias and not just the first one perfect |
Bug Description
Emails sent and received by email aliases are not associated with the workspaceMember and contacts are not created.
Expected behavior
Associate messages with the workspaceMember and create contacts for emails sent or received by email aliases.
Technical inputs
Use the users.settings.sendAs.list method to retrieve the sendAs aliases.
The text was updated successfully, but these errors were encountered: