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: return email subscription data in User #951

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Oct 27, 2024

Toward https://github.com/snapshot-labs/workflow/issues/226

This PR returns email subscriptions data from envelop, directly from the hub, in the user(s) object.

Instead of sending an extra query to fetch user email subscription info, we can know get if from the hub with

query { 
  user(id: "0x91fd2c8d24767db4ece7069aa27832ffaf8590f3") {
    id
    name
    emailSubscription {
      status 
      subscriptions
    }
  }
}

Which will return something like

{
  "data": {
    "user": {
      "id": "0x91FD2c8d24767db4Ece7069AA27832ffaf8590f3",
      "name": "℞aphaël-Daniel de la Poubelle『⚡』",
      "emailSubscription": {
        "status": "VERIFIED",
        "subscriptions": [
          "summary"
        ]
      }
    }
  }
}

In case user is not subscribed, it will return

{
  "data": {
    "user": {
      "emailSubscription": {
        "status": "NOT_SUBSCRIBED",
        "subscriptions": []
      }
    }
  }
}

Returning email subscription data from the hub will avoid having to manage another read API on sx side.

A sister PR (snapshot-labs/snapshot.js#1081) will merge the write function inside sequencer.

NOTE

The envelop DB connection is optional, and will always return data as NOT_SUBSCRIBED if not present (useful for the testnet)

TODO

  • In prod, set ENVELOP_DATABASE_URL= to envelop mysql database url

@wa0x6e wa0x6e requested a review from ChaituVR October 27, 2024 20:07
@wa0x6e wa0x6e marked this pull request as ready for review October 27, 2024 20:07
Copy link

codecov bot commented Oct 27, 2024

Codecov Report

Attention: Patch coverage is 34.00000% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/graphql/operations/users.ts 0.00% 33 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

@bonustrack
Copy link
Member

Can we make the config var optional so we don't enable it on testnet hub?

@wa0x6e
Copy link
Contributor Author

wa0x6e commented Dec 8, 2024

Done, envelopDB connection is now optional

@ChaituVR
Copy link
Member

ChaituVR commented Dec 9, 2024

Done, envelopDB connection is now optional

I think we need to address snapshot-labs/snapshot-sequencer#470 first no?

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.

3 participants