Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Basically, I've added two endpoints for our Discord bot to call. That's a temporary fix for banning users. Later on a report button will be added to the frontend, so people don't have to be on Discord in order for them to report someone.
The API endpoint identifies the requestor as a bot, because they share the same token. Therefore, it's only possible for our bot to perform a ban on someone. Additionally, only users with the role of a Moderator on our Discord can interact with the bot at all.
To the endpoints, there's the
ban
endpoint, which takes a username to get the full User object and then inserts the userId as well as the githubId in the "Banned" table. Also, the user itself has a column namedisBanned
, which will be set to true during the api call.Then, there's a
delete-stories
endpoint. All it does, it deletes all the stories from the given user. It's especially for users, that post porn for instance.Related Issue
Temporary fix for report button next to heart
Motivation and Context
Since gif stories is currently a work in progress and last time gif stories was a thing, it got abused, there need to be a report system. Also, we are getting reports on our Discord server, which need to be fixed asap.
How Has This Been Tested?
Postman Test
After setting up the endpoints like they are now, I've opened Postman to check if everything is alright and each endpoint is responding how it should be. Also, tried removing the
bot-access-token
header to see if there's a difference.Extension Test
In order to see if the isAuth() change is working as expected, I created a story, while not having the isBanned check implemented, then uncommented it and tried to like my own story. It was responding with an error message on the bottom right and it displayed the
You are banned! If you think the ban isn't rightful, then you can challenge the ban on our Discord server. https://discord.gg/ABpGdRxvaA
text. Everything worked out.Final Bot Test
For the ultimate test, I've called both endpoints via messaging the bot on Discord. After calling the ban endpoint, the
Banned
table had the correct ids inserted and the user in the user table also got updated correctly (isBanned --> true). Thedelete-stories
endpoint was also doing fine, but GifStory.delete() threw an error. Luckily that's no problem since the gifStory table doesn't exist yet.