Open
Conversation
9a3dce7 to
98dfdc0
Compare
anhnh12
requested changes
Nov 14, 2022
Comment on lines
+212
to
+226
| //validate quest action | ||
| err_action := e.validateQuestAction(string(log.Action)) | ||
| // validate user | ||
| err_user := e.validateUser(log.UserID) | ||
|
|
||
| if err_action != nil && err_user == nil { | ||
| return err_action | ||
| } | ||
| if err_action == nil && err_user != nil { | ||
| return err_user | ||
| } | ||
| if err_action != nil && err_user != nil { | ||
| return errors.New(err_action.Error() + ", " + err_user.Error()) | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
why need to have 3 cases here?
Suggested change
| //validate quest action | |
| err_action := e.validateQuestAction(string(log.Action)) | |
| // validate user | |
| err_user := e.validateUser(log.UserID) | |
| if err_action != nil && err_user == nil { | |
| return err_action | |
| } | |
| if err_action == nil && err_user != nil { | |
| return err_user | |
| } | |
| if err_action != nil && err_user != nil { | |
| return errors.New(err_action.Error() + ", " + err_user.Error()) | |
| } | |
| if err := e.validateQuestAction(string(log.Action)); err != nil { | |
| return err | |
| } | |
| if err := e.validateUser(log.UserID); err != nil { | |
| return err | |
| } |
Contributor
Author
There was a problem hiding this comment.
To notify user when they failed to call the API due to invalid fields (action, user_id, quest_id) in their requests, instead of returning null or nothing.
Comment on lines
+356
to
+370
| //validate quest id | ||
| err_id := e.validateQuestID(listQ.QuestID) | ||
| // validate user | ||
| err_user := e.validateUser(*listQ.UserID) | ||
|
|
||
| if err_id != nil && err_user == nil { | ||
| return nil, err_id | ||
| } | ||
| if err_id == nil && err_user != nil { | ||
| return nil, err_user | ||
| } | ||
| if err_id != nil && err_user != nil { | ||
| return nil, errors.New(err_id.Error() + ", " + err_user.Error()) | ||
| } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Same as above, this endpoint will return data: null if user failed to call API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
- Get user quests list with invalid user_id

- Post user quest progress list with invalid user_id/action


- Post claim quest with invalid user_id/quest_id

