Skip to content

Conversation

@uy-seng
Copy link
Contributor

@uy-seng uy-seng commented Mar 8, 2024

  • Subscribe to posting
  • Unsubscribe to posting
  • Get all subscriptions

uy-seng added 3 commits March 8, 2024 11:29
Team matching api functionality: Subscribe to posting
Team matching api functionality: Unsubscibe to posting
Team matching api functionality: Get all user's subscription
@uy-seng uy-seng self-assigned this Mar 8, 2024
@uy-seng uy-seng requested a review from a team as a code owner March 8, 2024 17:33
@vercel
Copy link

vercel bot commented Mar 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hackportal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 1, 2024 9:09pm

DedsecKnight
DedsecKnight previously approved these changes Mar 26, 2024
Copy link
Member

@DedsecKnight DedsecKnight left a comment

Choose a reason for hiding this comment

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

💯

Copy link
Contributor

@doanhtu07 doanhtu07 left a comment

Choose a reason for hiding this comment

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

Overall I think the PR is good. I have suggested one possible fix. I also have a few questions below.

  • Is subscription here the same concept as interest of a user for a posting?

  • About the data type, should we wait for everyone to finish so we can resolve all the type conflicts before merging?

    • In my PR, I have declared some types there. Can someone check it out and review my PR too if you're free?

});
}
snapshot.forEach((doc) => {
doc.ref.delete();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think delete returns a Promsie. Should we add await here? But since we are sure that this is a one-to-one relationship, we can take the first found doc and await for delete on that doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, i think that make sense, i have updated the file and added await and async for deleting the snapshot

Copy link
Contributor

Choose a reason for hiding this comment

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

@uy-seng

Can you change it one more time?
More information in this: https://masteringjs.io/tutorials/fundamentals/async-foreach
Generally, using async inside forEach is not the right way to handle promises

About my other questions, do you have any answers, or should we discuss them with Mike too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i updated it using Promise.all instead, and sorry i just saw the other question, i think we can you the types that you created instead but need Mike input on that.

Copy link
Contributor

@doanhtu07 doanhtu07 left a comment

Choose a reason for hiding this comment

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

LGTM now!

}

// delete one subscription for user that unsubscribe them to a post
async function deleteSubscription(req: NextApiRequest, res: NextApiResponse) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we'll need a way to verify whether request initiator matches user id provided in the request body.

const db = firestore();

// get all subscriptions for user
async function getSubscriptions(req: NextApiRequest, res: NextApiResponse) {
Copy link
Member

Choose a reason for hiding this comment

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

^

@uy-seng uy-seng closed this Apr 23, 2024
@uy-seng uy-seng deleted the team-matching-subscription-api branch April 23, 2024 19:31
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