-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Receiving Vouches #181
Receiving Vouches #181
Conversation
Vouch is very experimental and (as you said) there are only few who really send vouches, so I am not sure if we sould add this in such an early state. This might cause errors on verifications and might result in timeouts, because of the extra site that has to be parsed. I would prefer implementing async Webmentions first and/or implementing Vouch as a feature plugin or behind a feature toggle (so users can enable it using for example a constant). |
I am happy to put this behind a toggle and to merely start storing the vouch url by default. |
Cool. I think the best way to do so, is to encapsulate all in a if ( WEBMENTION_VOUCH === true ) {
require_once dirname( __FILE__ ) . '/includes/class-webmention-vouch.php';
} What do you think? |
@pfefferle How is this? |
nice, thanks! can you rename the |
@pfefferle Done if you want to review |
@@ -96,6 +133,15 @@ public static function register_meta() { | |||
'show_in_rest' => true, | |||
); | |||
register_meta( 'comment', 'webmention_response_code', $args ); | |||
|
|||
// Purpose of this is to store a vouch URL |
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.
Can you move this to the vouch class, otherwise it will load, if vouch is enabled or not...
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'd like to store the vouch URL whether or not vouch is enabled or not, in the event it becomes stable in future. Is that fine, or do you feel strongly it shouldn't store it unless enabled?
if ( ! $url ) { | ||
return; | ||
} | ||
$whitelist = get_option( 'webmention_approve_domains' ); |
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.
can you encapsulate this in some functions? For example get_webmention_approve_domains
and add_webmention_approve_domains
... (just example names, feel free to change them to a better/more readable version)
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.
Will do.
$whitelist = explode( "\n", $whitelist ); | ||
$host = wp_parse_url( $url, PHP_URL_HOST ); | ||
|
||
// strip leading www, if any |
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.
see comment above
@@ -387,6 +438,39 @@ public static function post( $request ) { | |||
return new WP_REST_Response( $return, 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.
should be also part of the vouch class?
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.
Back to the question I asked re storage.
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.
OK, will think about that, but then I have one more question: Why not directly set the comment-meta in line 318 and following and move it above the commentdata setter in line 316?
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.
Because there might not be a vouch parameter? It is optional.
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.
But this is what you also check in line 318...
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.
why not:
if ( isset( $params['vouch'] ) ) {
$comment_meta['vouch'] = esc_url_raw( urldecode( $params['vouch'] ) );
}
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 misunderstood...you are right.
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.
like you do with the date: https://github.com/pfefferle/wordpress-webmention/pull/181/files#diff-4a405db849c60f60b9e32bde3bfe0096R308
@pfefferle Requesting a re-review |
@pfefferle Can you merge and do a release then? |
This PR adds in the ability to add domains to the whitelist from the comment admin, as well as preliminary support for receiving vouches.
For now, the code, if there is a vouch parameter, verifies it. If it fails verification, it rejects the webmention. If it passes, it adds a parameter noting it passed. It also stores the vouch. It uses the approved domains list to determine acceptable sites for vouching, but I'd like to expand verification in future.
The next piece would be to add an admin setting to decide whether or not a successful vouch should be auto-approved, and to start getting some vouched webmentions.