Skip to content

Instantly share code, notes, and snippets.

@alexruimy
Last active December 27, 2022 19:26
Show Gist options
  • Save alexruimy/39c3f3451fee6f2fa6c05502b58614c1 to your computer and use it in GitHub Desktop.
Save alexruimy/39c3f3451fee6f2fa6c05502b58614c1 to your computer and use it in GitHub Desktop.
sample email data

Message Data for User1 (uid1)

[
    {
        "messageId": "mid1",
        "timestamp": 1609459200,
        "preview": "Hey, just wanted to check in on the project",
        "subject": "Project update",
        "to": "uid1",
        "from": "uid2",
        "threadId": "threadId1"
    },
    {
        "messageId": "mid2",
        "timestamp": 1609545600,
        "preview": "Looks good to me, let's move forward",
        "subject": "Re: Project update",
        "to": "uid2",
        "from": "uid1",
        "threadId": "threadId1"
    },
    {
        "messageId": "mid3",
        "timestamp": 1609632000,
        "preview": "Thanks for getting back to me. I've attached the updated proposal",
        "subject": "Re: Project update",
        "to": "uid1",
        "from": "uid2",
        "threadId": "threadId1"
    }
]

Email data for User2 (uid2)

(note the mid field)

[
    {
        "messageId": "mid9",
        "timestamp": 1609459200,
        "preview": "Hey, just wanted to check in on the project",
        "subject": "Project update",
        "to": "uid1",
        "from": "uid2",
        "threadId": "threadId1"
    },
    {
        "messageId": "mid10",
        "timestamp": 1609545600,
        "preview": "Looks good to me, let's move forward",
        "subject": "Re: Project update",
        "to": "uid2",
        "from": "uid1",
        "threadId": "threadId1"
    },
    {
        "messageId": "mid11",
        "timestamp": 1609632000,
        "preview": "Thanks for getting back to me. I've attached the updated proposal",
        "subject": "Re: Project update",
        "to": "uid1",
        "from": "uid2",
        "threadId": "threadId1"
    }
]

Both users' data represented in Firestore

Collection EmailThreads:
    [Subcollection threadId1]
        [Array participants]: ['uid1', 'uid2']
        [Array uid1]: ['mid1', 'mid2', 'mid3']
        [Array uid2]: ['mid9', 'mid10', 'mid11']
        [Map subject]: {
            'default': 'Project update',
            'uid1': 'Custom Subject',
            // uid2 did not change their subject, so they get default
        }
        [Subcollection MetaMessages]: (we'll deal with this later)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment