-
Notifications
You must be signed in to change notification settings - Fork 16
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
Migrated notifications to Firebase #37
Migrated notifications to Firebase #37
Conversation
.gitignore
Outdated
@@ -4,6 +4,8 @@ dist | |||
build | |||
.env | |||
|
|||
# Firebase service account | |||
firebase.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make it so we don't need firebase.json
file but instead rely on .env file?
@@ -0,0 +1 @@ | |||
v16.17.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to force v16 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to keep dev env consistent across the repos. Updated the same for Snapshot UI repo as well.
src/helpers/firebase.ts
Outdated
const messaging = getMessaging(firebaseApp); | ||
const hubURL = process.env.HUB_URL || 'https://hub.snapshot.org'; | ||
|
||
const getUserSpaces = async user => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use this format for all the functions and add types to it?
const getUserSpaces = async user => { | |
async function getUserSpaces(user: string) { |
src/helpers/firebase.ts
Outdated
credential: cert({ | ||
projectId: FIREBASE_PROJECT_ID, | ||
clientEmail: FIREBASE_CLIENT_EMAIL, | ||
privateKey: FIREBASE_PRIVATE_KEY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this change the env var wont work because it include new lines
privateKey: FIREBASE_PRIVATE_KEY | |
privateKey: (FIREBASE_PRIVATE_KEY || '').replace(/\\n/g, '\n') |
src/api.ts
Outdated
} | ||
}); | ||
|
||
router.post('/subscription', async (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This route assume the user join / leave a space using snapshot.org but he may activate notification on snapshot.org but actually join or leave from another integration that wont trigger this route. Also this has no authentication anyone could exploit this route and subscribe any user to a specific space. We should instead use the code that replay the messages from the hub to check when there is a new follow or unfollow action. Similar than what we do to populate proposal events.
Fixes: #23
Changes:
How to test and review this PR?
firebase.json
service credential at the root of the project