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

feat: gmail attachments #5081

Closed
wants to merge 7 commits into from

Conversation

rostaklein
Copy link
Contributor

@rostaklein rostaklein commented Apr 21, 2024

closes #4108

Wow, this one took some time to set up. I gave up multiple times when I was exhausted after work (there have been a lot of changes around the email sync lately, including folder structure and lot of stuff necessary for the actual setup etc.). After exchanging few messages with @bosiraphael I finally got it running! 😄

  1. had to create my own Google app to access the gmail API
  2. had to set up .env correctly (AUTH_GOOGLE_APIS_CALLBACK_URL, CACHE_STORAGE_TYPE...)
  3. had to add Redis so it persists the message thread ids to the cache so I can run yarn nx command twenty-server cron:messaging:gmail-fetch-messages-from-cache via debugger to see whats going on

this is just a draft to ask first few questions, ill continue developing in this branch :)

Copy link
Contributor

@bosiraphael bosiraphael left a comment

Choose a reason for hiding this comment

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

Thank you very much @rostaklein for your contribution. Sorry, we forgot to notify you about some changes relative to this issue, I detailed them in the comments below. Do not hesitate to ask me or @charlesBochet if you have any questions.

@@ -55,6 +57,36 @@ export class AttachmentObjectMetadata extends BaseObjectMetadata {
})
type: string;

@FieldMetadata({
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the change, but after discussion with the team, we now want to create a new composite FieldMetadataType File (you can take example on FieldMetadataType.Link in packages/twenty-server/src/engine/metadata-modules/field-metadata/composite-types/link.composite-type.ts) instead of creating a new storage driver type, since gmail is not really a storage driver type.
This composite field should have the following properties:

  • fileName: string
  • fileExtension: string
  • uploadedAt: DateTime
  • storageType: 'server' | 'gmail'
  • We also want to add a virtual property fullPath which will be computed inside query-result-getters.factory.

The table Attachment will only have one column of type File (in addition to the id, createdAt, updatedAt ... and the relations).

In packages/twenty-server/src/engine/core-modules/file/controllers/file.controller.ts we want to create a new endpoint @Get(gmail/:filename) which will call users.messages.attachments.get to get the fileStream.

@charlesBochet can help you if you have any questions regarding this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense 👍 Ive actually already added one composite field :D #4492 This time it should be hopefully a bit easier though as I wont aim to add it as a field assignable to an object + read/write table, right?

Copy link
Member

Choose a reason for hiding this comment

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

Great! It will actually be very similar, with an additional tweak on the getters logic! I can assist you if you have any question :)

Copy link
Member

Choose a reason for hiding this comment

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

Feel free to ping on Discord direclty if you need real time inputs!

@charlesBochet
Copy link
Member

Closing this one (we still have the code in the closed PR) as we decide to move on with smaller PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log email attachments
3 participants