add actions pre running the http GET/POST requests

/cc @mattwiebe
This commit is contained in:
Matthias Pfefferle 2023-08-02 09:00:45 +02:00
parent 338c63d3e1
commit 3c0ee1aeba

View file

@ -20,6 +20,8 @@ class Http {
* @return array|WP_Error The POST Response or an WP_ERROR
*/
public static function post( $url, $body, $user_id ) {
do_action( 'activitypub_pre_http_post', $url, $body, $user_id );
$date = \gmdate( 'D, d M Y H:i:s T' );
$digest = Signature::generate_digest( $body );
$signature = Signature::generate_signature( $user_id, 'post', $url, $date, $digest );
@ -68,6 +70,8 @@ class Http {
* @return array|WP_Error The GET Response or an WP_ERROR
*/
public static function get( $url ) {
do_action( 'activitypub_pre_http_get', $url );
$date = \gmdate( 'D, d M Y H:i:s T' );
$signature = Signature::generate_signature( Users::APPLICATION_USER_ID, 'get', $url, $date );