Skip to content
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

Merged
merged 1 commit into from
Jan 3, 2024
Merged

Add QuestyCaptcha WikiSettings to API #706

merged 1 commit into from
Jan 3, 2024

Conversation

tarrow
Copy link
Contributor

@tarrow tarrow commented Dec 12, 2023

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

@tarrow tarrow changed the title WIP: Questy to API Add QuestyCaptcha WikiSettings to API Dec 21, 2023
@tarrow tarrow marked this pull request as ready for review December 21, 2023 08:42
Copy link
Contributor

@m90 m90 left a 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (strlen($question) > 200) {
if (strlen($answer) > 200) {

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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

app/Rules/SettingCaptchaQuestions.php Outdated Show resolved Hide resolved
@tarrow tarrow merged commit a7e7912 into main Jan 3, 2024
5 checks passed
@tarrow tarrow deleted the addQuesty branch January 3, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants