-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add QuestyCaptcha WikiSettings to API #706
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.
Left some comments, there's one typo and I think ™️ we should have tests for the validation.
if (!is_string($answer)) { | ||
return false; | ||
} | ||
if (strlen($question) > 200) { |
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.
if (strlen($question) > 200) { | |
if (strlen($answer) > 200) { |
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.
Thanks! I'm a fool and clearly having validation tests for this would have caught my mistake.
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.
I'm actually even more of a fool; apparently I'd failed to push the right amended commit
@@ -0,0 +1,60 @@ | |||
<?php |
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.
Should we also have a test case for this Rule. I think it'd be pretty straight forward to set up and will help future generations in understanding what rules a set of questions is expected to adhere to.
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.
I was torn on whether or not the test coverage for the controller is sufficient or if it makes sense to also add a test for the rule. I could definitely be convinced but as I was writing tests for the rule it felt mostly like I was copy/pasting the controller tests so I've omitted it for now
Adds two new types of WikiSetting to the platform api to manage using QuestyCaptcha.
It adds a boolean setting for turning the feature on and off as well as a totally independent setting for the questions.
This enables wiki administrators to store and curate their questions even when the setting is disabled.
It does not provide any default questions; this has been done in the UI.
This follows the existing pattern for equivalent entities and therefore stores the settings map as JSON. This can be mildly confusing since there in then double encoded JSON in the payloads to and from this API.
Validation for the content of the questions is also minimal; there is no escaping of html content in the questions since, as I understand it, this is handled in MW[1].
This can be merged independently of wbstack/mediawiki#405 but if you care to test them then it may be easier to do in parallel.
[1] https://doc.wikimedia.org/mediawiki-core/1.27.1/php/classHtml.html#a1c74fee14762ec4d50e09a94c94327ef