tbf-challenge / teamwork-be

This is the backend repository for teamwork
0 stars 0 forks source link

update feed endpoint to return flagged posts when query is passed #326

Closed jocrah closed 1 year ago

jocrah commented 1 year ago

Task Description

Building up on setting up the ability for posts to be flagged as inappropriate, we would like an admin to be able to see flagged posts to be able to take action on them.

Technical Considerations

  1. We will be allowing the existing /feed endpoint to take an isFlagged parameter which could either be false or true. For example, /feed?isFlagged=true
  2. The already existing/feed endpoint without the isFlagged query param is allowed to all authenticated users.
  3. Adding the isFlagged query parameter to the /feed endpoint is only accessible for admin users. That is, if the feed endpoint is called and has the isFlagged parameter, we should ensure the authenticated user is an admin. If they are not an admin, we return an unauthorized response.
  4. What counts as a flagged post? A flagged post is one which has a flagsCount of at least 1. This means we will be fetching such posts when the isFlagged query param is passed as true. If it is false, we fetch posts with flagsCount of 0