Add ProofRequiredError Exception and submit-challenge command #320
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.
This is still entirely untested since I would need a ProofRequiredError to do so. I am not currently commited enough to try and trigger one for my Signal account, but anyone who has one, please try. Or if you find obvious mistakes without testing, let me know.
I've noticed that ProofRequiredError rarely comes in the SendMessageResult, but usually as a ResponseError, so I created another ProofRequiredException in errors.py. I didn't know how to reconcile the two, since SendMessageResult probably wouldn't work with an Exception instead of a SerializableAttrs, but I also needed to inherit from ResponseError.
When portal.handle_matrix_message() encounters a ProofRequiredError, it should store a token in the respective user, so the user won't have to copy&paste that. Since tokens are temporary in nature and I don't know how to work with databases, it's not stored in the database. I suppose that's fine.
The user can then use the submit-challenge command with just a captcha token to complete the challenge. I currently don't handle PUSH_CHALLENGE. So far, I have only encountered RECAPTCHA, I would prefer to first handle that and then worry about the other (probably just two lines, but still).