-
Notifications
You must be signed in to change notification settings - Fork 8
Add flag to db #410
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
base: bl4ze/dev
Are you sure you want to change the base?
Add flag to db #410
Conversation
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.
Pull Request Overview
This PR updates flag submission handling by recording all submitted flags in the userChallenges DB and modifies responses accordingly.
- Adds detailed error checking after updating user challenge tries.
- Saves both correct and incorrect flag submissions in the database.
- Enhances API responses to include the submitted flag field.
Reviewed Changes
Copilot reviewed 4 out of 9 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
api/submit.go | Implements flag saving in both correct and incorrect cases and adds extra error checking. |
api/response.go | Adds a new JSON field for the flag in flag submission responses. |
api/info.go | Includes the flag in the submission information sent to clients. |
Files not reviewed (5)
- api/docs/swagger.json: Language not supported
- api/docs/swagger.yaml: Language not supported
- api/docs/swagger/swagger.json: Language not supported
- api/docs/swagger/swagger.yaml: Language not supported
- go.mod: Language not supported
Comments suppressed due to low confidence (1)
api/submit.go:229
- [nitpick] Consider renaming 'UserChallengesEntry' to 'userChallengesEntry' for consistency with Go naming conventions.
UserChallengesEntry := database.UserChallenges{
@@ -215,29 +226,27 @@ func submitFlagHandler(c *gin.Context) { | |||
} | |||
} else { | |||
if challenge.Flag != flag { | |||
UserChallengesEntry := database.UserChallenges{ | |||
CreatedAt: time.Time{}, |
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.
The 'CreatedAt' field is initialized with time.Time{}, which results in a zero timestamp; consider using time.Now() to record the actual submission time.
CreatedAt: time.Time{}, | |
CreatedAt: time.Now(), |
Copilot uses AI. Check for mistakes.
Anything to fix here ? |
Yes. Please make the change suggested by copilot. |
@v1bh475u, is there anything else to add other than copilot fixes? |
Nope. All good to go! |
Add all the flags submitted by the user to the userChallenges DB.