Skip to content

Use Gmail API for Gmail accounts in all situations #2122

Closed

Description

@tomholub

Alright, now I understood why we kept IMAP on consumer.

Yes, let's use Gmail API for Gmail on consumer too.

Originally posted by @tomholub in https://github.com/FlowCrypt/flowcrypt-web/issues/725#issuecomment-1369925920

Activity

  1. added this to the 1.4.0 milestone on Jan 3, 2023
  2. DenBond7 commented on Jan 3, 2023

    @DenBond7
    Collaborator

    @tomholub @martgil Also please look at this comment, position 1). Other questions are not actual today.

    #932 (comment)

  3. tomholub commented on Jan 3, 2023

    @tomholub
    CollaboratorAuthor

    copy @sosnovsky

    Of course, a user can update every folder via pull to refresh functionality at any time. That's true for IMAP and Gmail API.

    you could also run a refresh every time user navigates to the inbox screen

    For example:

    1. open app, renders inbox (run refresh)
    2. create new message, send
    3. user is sent back to inbox (run refresh)

    etc

  4. modified the milestones: 1.4.0, 1.4.1 on Jan 11, 2023
  5. DenBond7 commented on Jan 23, 2023

    @DenBond7
    Collaborator

    @tomholub Would you like to just switch to using Gmail API for all users or should I add an opportunity to use both options

    • via Gmail API
    • via IMAP/SMTP

    It will not be possible to switch protocols after a setup from settings. A user will have to logout-login to choose another option.

  6. tomholub commented on Jan 23, 2023

    @tomholub
    CollaboratorAuthor

    I don't think we should give them option. Gmail means use Gmail API

  7. DenBond7 commented on Jan 23, 2023

    @DenBond7
    Collaborator

    What about existing users? I mean who is already sign-in. Can we still use IMAP for them? On my side, it will be simpler to leave it as-is. After logout-login they will use Gmail API.

  8. tomholub commented on Jan 23, 2023

    @tomholub
    CollaboratorAuthor

    The access token is the same, right? Is it because you store different things when they use IMAP? So the problematic part is already existing local storatge / cache?

  9. DenBond7 commented on Jan 23, 2023

    @DenBond7
    Collaborator

    So the problematic part is already existing local storatge / cache?

    Yes. In that case, I have to review all things and the migration process.

  10. DenBond7 commented on Jan 23, 2023

    @DenBond7
    Collaborator

    It's not a problem. Just it will be more work.

  11. tomholub commented on Jan 23, 2023

    @tomholub
    CollaboratorAuthor

    Of course, for now, you could still leave original users as they are. I just worry we'll forget about it one day, and cause trouble. Because you won't be able to change things if you still have some users on IMAP that cannot be properly tested.

    Could you somewhere add a condition that if imap is used and it is gmail account, always pretend to throw an auth error when connecting to IMAP? That should pull up authorization / re-connect screen (existing code), which should cause the app to then switch to Gmail API mode (after this update). That would maybe take care of the problem easily? Just brainstorming how to do the right thin without too much extra work.

  12. DenBond7 commented on Jan 23, 2023

    @DenBond7
    Collaborator

    Got it. I will investigate my code and share more details a bit later.

  13. 6 remaining items

  14. DenBond7 commented on Mar 20, 2023

    @DenBond7
    Collaborator

    Could you somewhere add a condition that if imap is used and it is gmail account, always pretend to throw an auth error when connecting to IMAP? That should pull up authorization / re-connect screen (existing code), which should cause the app to then switch to Gmail API mode (after this update). That would maybe take care of the problem easily? Just brainstorming how to do the right thin without too much extra work.

    @sosnovsky I have more details. Unfortunately, moving to use Gmail API for users who are already logged in and use IMAP protocol is impossible without logout-login. Caching - is the reason. We use some additional fields for Gmail API when we load messages which are empty in the IMAP realization. So, we will have the following logic after allowing Gmail API for all:

    • already logged users will use IMAP. After logout-login, they will use Gmail API
    • not-logged users will use Gmail API right after login
  15. added a commit that references this issue on Mar 20, 2023
  16. sosnovsky commented on Mar 20, 2023

    @sosnovsky
    Collaborator

    What about solution proposed by Tom - after this update throw auth error for users who use imap, so they'll need to re-login? Will it clear cache and add needed fields for Gmail API or they'll need manually logout and then re-login?

  17. DenBond7 commented on Mar 20, 2023

    @DenBond7
    Collaborator
    • "manually logout-login" - means the user understands what he is doing. And this makes all process clear. We logout, clear all old things, then login with a new method.
    • "throw auth error for users who use imap, so they'll need to re-login" - this case is a bit difficult. I really need to clear old data in a few tables before proceed. If I choose this method for a user it will mean he will lost some cached data like info about messages and attachments. If it looks ok, I can try to do that. Need to add that technically we do not need to re-login via Google sign-in. We use the same token for Gmail API and IMAP. So just need to clear some cache.
  18. sosnovsky commented on Mar 20, 2023

    @sosnovsky
    Collaborator

    Need to add that technically we do not need to re-login via Google sign-in. We use the same token for Gmail API and IMAP. So just need to clear some cache.

    So, in theory, we can migrate user data from IMAP to Gmail API without any user interaction?

    And for missing fields from Gmail API - can we just re-fetch them when user opens message?

  19. DenBond7 commented on Mar 20, 2023

    @DenBond7
    Collaborator

    So, in theory, we can migrate user data from IMAP to Gmail API without any user interaction?

    Yup. For now I see that. But need to clear cache. It will look like a user just logged in.

    And for missing fields from Gmail API - can we just re-fetch them when user opens message.

    No, we can not. Need to clear cache for a user completely. It will look like a user just logged in.

  20. sosnovsky commented on Mar 20, 2023

    @sosnovsky
    Collaborator

    Then on the first start after update we can show splash screen with message like Optimizing local data, please wait..., while in background we'll download the latest messages. When messages will be downloaded (should take just some seconds, I think) app will go to home screen.

    What do you think?

  21. DenBond7 commented on Mar 22, 2023

    @DenBond7
    Collaborator

    What do you think?

    I've added new changes that include the cache cleaning. It works fast so we don't need to show a splash screen. So I think our migration will look smooth.

  22. DenBond7 commented on Mar 23, 2023

    @DenBond7
    Collaborator

    @martgil Please note that starting with version 1.4.3, all users using Google Sign-in will use the Gmail API instead of IMAP.

  23. martgil commented on Mar 23, 2023

    @martgil
    Collaborator

    Got it - Thank you, sir Den. Does 1.4.3 include automatic email retrieval even when the app is closed?

  24. DenBond7 commented on Mar 23, 2023

    @DenBond7
    Collaborator

    Does 1.4.3 include automatic email retrieval even when the app is closed?

    We used to use Gmail API for the enterprise only. From 1.4.3 we will use Gmail API for all users who use Google Sign-in. automatic email retrieval works for all users, but it works differently for Gmail API and IMAP. IMAP has idle and automatic email retrieval can work faster. Gmail API fetches updates no more than once every 15 minutes.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions