Changeset 3375073
- Timestamp:
- 10/08/2025 12:04:36 PM (4 months ago)
- Location:
- autoblue
- Files:
-
- 14 edited
- 1 copied
-
tags/1.0.0 (copied) (copied from autoblue/trunk)
-
tags/1.0.0/autoblue.php (modified) (2 diffs)
-
tags/1.0.0/includes/Bluesky.php (modified) (4 diffs)
-
tags/1.0.0/includes/Bluesky/API.php (modified) (8 diffs)
-
tags/1.0.0/includes/ConnectionsManager.php (modified) (2 diffs)
-
tags/1.0.0/readme.txt (modified) (2 diffs)
-
tags/1.0.0/vendor/composer/installed.php (modified) (2 diffs)
-
tags/1.0.0/vendor/composer/platform_check.php (modified) (1 diff)
-
trunk/autoblue.php (modified) (2 diffs)
-
trunk/includes/Bluesky.php (modified) (4 diffs)
-
trunk/includes/Bluesky/API.php (modified) (8 diffs)
-
trunk/includes/ConnectionsManager.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/vendor/composer/platform_check.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
autoblue/tags/1.0.0/autoblue.php
r3276419 r3375073 8 8 * License: GPLv2 or later 9 9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 * Version: 0.0.610 * Version: 1.0.0 11 11 * Text Domain: autoblue 12 12 * Requires at least: 6.6 … … 21 21 require_once __DIR__ . '/vendor/autoload.php'; 22 22 23 define( 'AUTOBLUE_VERSION', ' 0.0.6' );23 define( 'AUTOBLUE_VERSION', '1.0.0' ); 24 24 define( 'AUTOBLUE_SLUG', 'autoblue' ); 25 25 define( 'AUTOBLUE_BASENAME', plugin_basename( __FILE__ ) ); -
autoblue/tags/1.0.0/includes/Bluesky.php
r3276419 r3375073 55 55 * @return array<string,mixed>|false 56 56 */ 57 private function upload_image( int $image_id, string $access_token ) {57 private function upload_image( int $image_id, string $access_token, string $did ) { 58 58 if ( ! $image_id || ! $access_token ) { 59 59 return false; … … 90 90 } 91 91 92 $blob = $this->api_client->upload_blob( $image_blob, $mime_type, $access_token );92 $blob = $this->api_client->upload_blob( $image_blob, $mime_type, $access_token, $did ); 93 93 94 94 if ( is_wp_error( $blob ) ) { … … 174 174 $image_blob = false; 175 175 if ( has_post_thumbnail( $post->ID ) ) { 176 $image_blob = $this->upload_image( get_post_thumbnail_id( $post->ID ), $connection['access_jwt'] ); // @phpstan-ignore argument.type176 $image_blob = $this->upload_image( get_post_thumbnail_id( $post->ID ), $connection['access_jwt'], $connection['did'] ); // @phpstan-ignore argument.type 177 177 } 178 178 … … 181 181 } 182 182 183 $response = $this->api_client->create_record( $body, $connection['access_jwt'] );183 $response = $this->api_client->create_record( $body, $connection['access_jwt'], $connection['did'] ); 184 184 185 185 if ( is_wp_error( $response ) ) { -
autoblue/tags/1.0.0/includes/Bluesky/API.php
r3211894 r3375073 120 120 121 121 /** 122 * @return string|\WP_Error 123 */ 124 private function resolve_pds_endpoint( string $did ) { 125 if ( ! $did ) { 126 return new \WP_Error( 'autoblue_invalid_did', __( 'Invalid DID.', 'autoblue' ) ); 127 } 128 129 $cache_key = 'autoblue_pds_endpoint_' . $did; 130 $cached = get_transient( $cache_key ); 131 132 if ( false !== $cached ) { 133 return $cached; 134 } 135 136 $response = wp_safe_remote_get( 'https://plc.directory/' . $did ); 137 138 if ( is_wp_error( $response ) ) { 139 return $response; 140 } 141 142 $code = wp_remote_retrieve_response_code( $response ); 143 144 if ( 200 !== $code ) { 145 return new \WP_Error( 'autoblue_did_resolve_error', __( 'Error resolving DID document.', 'autoblue' ) ); 146 } 147 148 $body = wp_remote_retrieve_body( $response ); 149 $did_doc = json_decode( $body, true ); 150 151 if ( ! $did_doc ) { 152 return new \WP_Error( 'autoblue_did_parse_error', __( 'Failed to parse DID document.', 'autoblue' ) ); 153 } 154 155 if ( ! isset( $did_doc['service'] ) || ! is_array( $did_doc['service'] ) ) { 156 return new \WP_Error( 'autoblue_did_no_service', __( 'No service found in DID document.', 'autoblue' ) ); 157 } 158 159 foreach ( $did_doc['service'] as $service ) { 160 if ( isset( $service['type'] ) && 'AtprotoPersonalDataServer' === $service['type'] && isset( $service['serviceEndpoint'] ) ) { 161 $endpoint = $service['serviceEndpoint']; 162 163 set_transient( $cache_key, $endpoint, DAY_IN_SECONDS ); 164 165 return $endpoint; 166 } 167 } 168 169 return new \WP_Error( 'autoblue_did_no_pds', __( 'No PDS service found in DID document.', 'autoblue' ) ); 170 } 171 172 /** 122 173 * @return array<string,mixed>|\WP_Error 123 174 */ … … 127 178 } 128 179 129 return $this->send_request( 180 $pds_endpoint = $this->resolve_pds_endpoint( $did ); 181 182 if ( is_wp_error( $pds_endpoint ) ) { 183 return $pds_endpoint; 184 } 185 186 $result = $this->send_request( 130 187 [ 131 188 'endpoint' => 'com.atproto.server.createSession', … … 135 192 'password' => $app_password, 136 193 ], 137 'base_url' => self::BASE_URL, 138 ] 139 ); 140 } 141 142 /** 143 * @return array<string,mixed>|\WP_Error 144 */ 145 public function refresh_session( string $refresh_jwt ) { 194 'base_url' => $pds_endpoint, 195 ] 196 ); 197 198 return $result; 199 } 200 201 /** 202 * @return array<string,mixed>|\WP_Error 203 */ 204 public function refresh_session( string $refresh_jwt, string $did ) { 146 205 if ( ! $refresh_jwt ) { 147 206 return new \WP_Error( 'autoblue_invalid_refresh_jwt', __( 'Invalid refresh JWT.', 'autoblue' ) ); 207 } 208 209 $pds_endpoint = $this->resolve_pds_endpoint( $did ); 210 211 if ( is_wp_error( $pds_endpoint ) ) { 212 return $pds_endpoint; 148 213 } 149 214 … … 156 221 'Authorization' => 'Bearer ' . $refresh_jwt, 157 222 ], 158 'base_url' => self::BASE_URL,223 'base_url' => $pds_endpoint, 159 224 ] 160 225 ); … … 165 230 * @return array<string,mixed>|\WP_Error 166 231 */ 167 public function create_record( array $record, string $access_token ) {232 public function create_record( array $record, string $access_token, string $did ) { 168 233 if ( ! $record || ! $access_token ) { 169 234 return new \WP_Error( 'autoblue_invalid_record_or_access_token', __( 'Invalid record or access token.', 'autoblue' ) ); 235 } 236 237 $pds_endpoint = $this->resolve_pds_endpoint( $did ); 238 239 if ( is_wp_error( $pds_endpoint ) ) { 240 return $pds_endpoint; 170 241 } 171 242 … … 178 249 ], 179 250 'body' => $record, 180 'base_url' => self::BASE_URL,181 ] 182 ); 183 } 184 185 /** 186 * @return array<string,mixed>|\WP_Error 187 */ 188 public function upload_blob( string $blob, string $mime_type, string $access_token ) {251 'base_url' => $pds_endpoint, 252 ] 253 ); 254 } 255 256 /** 257 * @return array<string,mixed>|\WP_Error 258 */ 259 public function upload_blob( string $blob, string $mime_type, string $access_token, string $did ) { 189 260 if ( ! $blob || ! $mime_type ) { 190 261 return new \WP_Error( 'autoblue_invalid_blob_or_mime_type', __( 'Invalid blob or MIME type.', 'autoblue' ) ); … … 193 264 if ( ! $access_token ) { 194 265 return new \WP_Error( 'autoblue_invalid_access_token', __( 'Invalid access token.', 'autoblue' ) ); 266 } 267 268 $pds_endpoint = $this->resolve_pds_endpoint( $did ); 269 270 if ( is_wp_error( $pds_endpoint ) ) { 271 return $pds_endpoint; 195 272 } 196 273 … … 204 281 ], 205 282 'body' => $blob, 206 'base_url' => self::BASE_URL,283 'base_url' => $pds_endpoint, 207 284 ] 208 285 ); -
autoblue/tags/1.0.0/includes/ConnectionsManager.php
r3211894 r3375073 97 97 98 98 update_option( self::OPTION_KEY, $filtered_connections ); 99 99 100 delete_transient( $this->get_transient_key( $did ) ); 101 delete_transient( 'autoblue_pds_endpoint_' . $did ); 100 102 101 103 $this->log->info( __( 'Connection with DID `{did}` deleted.', 'autoblue' ), [ 'did' => $did ] ); … … 156 158 } 157 159 158 $response = $this->api_client->refresh_session( $connection['refresh_jwt'] );160 $response = $this->api_client->refresh_session( $connection['refresh_jwt'], $did ); 159 161 160 162 if ( is_wp_error( $response ) ) { -
autoblue/tags/1.0.0/readme.txt
r3276483 r3375073 2 2 Contributors: danielpost 3 3 Tags: social, bluesky, auto, share, post 4 Stable tag: 0.0.64 Stable tag: 1.0.0 5 5 Requires at least: 6.6 6 6 Tested up to: 6.8 … … 47 47 == Changelog == 48 48 49 = 1.0.0 = 50 * Autoblue is now out of beta. 51 * Feature: Add support for self-hosted PDS 52 49 53 = 0.0.6 = 50 54 * Improvement: Autoblue settings page is now more mobile-friendly. -
autoblue/tags/1.0.0/vendor/composer/installed.php
r3276419 r3375073 2 2 'root' => array( 3 3 'name' => 'posty/autoblue', 4 'pretty_version' => 'v 0.0.6',5 'version' => ' 0.0.6.0',6 'reference' => ' 06a849712982c8d95813f990356a98e6be2d45eb',4 'pretty_version' => 'v1.0.0', 5 'version' => '1.0.0.0', 6 'reference' => '18678a3236123ada8746916c2d3a8fcb1d6ac2db', 7 7 'type' => 'project', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'posty/autoblue' => array( 23 'pretty_version' => 'v 0.0.6',24 'version' => ' 0.0.6.0',25 'reference' => ' 06a849712982c8d95813f990356a98e6be2d45eb',23 'pretty_version' => 'v1.0.0', 24 'version' => '1.0.0.0', 25 'reference' => '18678a3236123ada8746916c2d3a8fcb1d6ac2db', 26 26 'type' => 'project', 27 27 'install_path' => __DIR__ . '/../../', -
autoblue/tags/1.0.0/vendor/composer/platform_check.php
r3214602 r3375073 20 20 } 21 21 } 22 trigger_error( 23 'Composer detected issues in your platform: ' . implode(' ', $issues), 24 E_USER_ERROR 22 throw new \RuntimeException( 23 'Composer detected issues in your platform: ' . implode(' ', $issues) 25 24 ); 26 25 } -
autoblue/trunk/autoblue.php
r3276419 r3375073 8 8 * License: GPLv2 or later 9 9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 * Version: 0.0.610 * Version: 1.0.0 11 11 * Text Domain: autoblue 12 12 * Requires at least: 6.6 … … 21 21 require_once __DIR__ . '/vendor/autoload.php'; 22 22 23 define( 'AUTOBLUE_VERSION', ' 0.0.6' );23 define( 'AUTOBLUE_VERSION', '1.0.0' ); 24 24 define( 'AUTOBLUE_SLUG', 'autoblue' ); 25 25 define( 'AUTOBLUE_BASENAME', plugin_basename( __FILE__ ) ); -
autoblue/trunk/includes/Bluesky.php
r3276419 r3375073 55 55 * @return array<string,mixed>|false 56 56 */ 57 private function upload_image( int $image_id, string $access_token ) {57 private function upload_image( int $image_id, string $access_token, string $did ) { 58 58 if ( ! $image_id || ! $access_token ) { 59 59 return false; … … 90 90 } 91 91 92 $blob = $this->api_client->upload_blob( $image_blob, $mime_type, $access_token );92 $blob = $this->api_client->upload_blob( $image_blob, $mime_type, $access_token, $did ); 93 93 94 94 if ( is_wp_error( $blob ) ) { … … 174 174 $image_blob = false; 175 175 if ( has_post_thumbnail( $post->ID ) ) { 176 $image_blob = $this->upload_image( get_post_thumbnail_id( $post->ID ), $connection['access_jwt'] ); // @phpstan-ignore argument.type176 $image_blob = $this->upload_image( get_post_thumbnail_id( $post->ID ), $connection['access_jwt'], $connection['did'] ); // @phpstan-ignore argument.type 177 177 } 178 178 … … 181 181 } 182 182 183 $response = $this->api_client->create_record( $body, $connection['access_jwt'] );183 $response = $this->api_client->create_record( $body, $connection['access_jwt'], $connection['did'] ); 184 184 185 185 if ( is_wp_error( $response ) ) { -
autoblue/trunk/includes/Bluesky/API.php
r3211894 r3375073 120 120 121 121 /** 122 * @return string|\WP_Error 123 */ 124 private function resolve_pds_endpoint( string $did ) { 125 if ( ! $did ) { 126 return new \WP_Error( 'autoblue_invalid_did', __( 'Invalid DID.', 'autoblue' ) ); 127 } 128 129 $cache_key = 'autoblue_pds_endpoint_' . $did; 130 $cached = get_transient( $cache_key ); 131 132 if ( false !== $cached ) { 133 return $cached; 134 } 135 136 $response = wp_safe_remote_get( 'https://plc.directory/' . $did ); 137 138 if ( is_wp_error( $response ) ) { 139 return $response; 140 } 141 142 $code = wp_remote_retrieve_response_code( $response ); 143 144 if ( 200 !== $code ) { 145 return new \WP_Error( 'autoblue_did_resolve_error', __( 'Error resolving DID document.', 'autoblue' ) ); 146 } 147 148 $body = wp_remote_retrieve_body( $response ); 149 $did_doc = json_decode( $body, true ); 150 151 if ( ! $did_doc ) { 152 return new \WP_Error( 'autoblue_did_parse_error', __( 'Failed to parse DID document.', 'autoblue' ) ); 153 } 154 155 if ( ! isset( $did_doc['service'] ) || ! is_array( $did_doc['service'] ) ) { 156 return new \WP_Error( 'autoblue_did_no_service', __( 'No service found in DID document.', 'autoblue' ) ); 157 } 158 159 foreach ( $did_doc['service'] as $service ) { 160 if ( isset( $service['type'] ) && 'AtprotoPersonalDataServer' === $service['type'] && isset( $service['serviceEndpoint'] ) ) { 161 $endpoint = $service['serviceEndpoint']; 162 163 set_transient( $cache_key, $endpoint, DAY_IN_SECONDS ); 164 165 return $endpoint; 166 } 167 } 168 169 return new \WP_Error( 'autoblue_did_no_pds', __( 'No PDS service found in DID document.', 'autoblue' ) ); 170 } 171 172 /** 122 173 * @return array<string,mixed>|\WP_Error 123 174 */ … … 127 178 } 128 179 129 return $this->send_request( 180 $pds_endpoint = $this->resolve_pds_endpoint( $did ); 181 182 if ( is_wp_error( $pds_endpoint ) ) { 183 return $pds_endpoint; 184 } 185 186 $result = $this->send_request( 130 187 [ 131 188 'endpoint' => 'com.atproto.server.createSession', … … 135 192 'password' => $app_password, 136 193 ], 137 'base_url' => self::BASE_URL, 138 ] 139 ); 140 } 141 142 /** 143 * @return array<string,mixed>|\WP_Error 144 */ 145 public function refresh_session( string $refresh_jwt ) { 194 'base_url' => $pds_endpoint, 195 ] 196 ); 197 198 return $result; 199 } 200 201 /** 202 * @return array<string,mixed>|\WP_Error 203 */ 204 public function refresh_session( string $refresh_jwt, string $did ) { 146 205 if ( ! $refresh_jwt ) { 147 206 return new \WP_Error( 'autoblue_invalid_refresh_jwt', __( 'Invalid refresh JWT.', 'autoblue' ) ); 207 } 208 209 $pds_endpoint = $this->resolve_pds_endpoint( $did ); 210 211 if ( is_wp_error( $pds_endpoint ) ) { 212 return $pds_endpoint; 148 213 } 149 214 … … 156 221 'Authorization' => 'Bearer ' . $refresh_jwt, 157 222 ], 158 'base_url' => self::BASE_URL,223 'base_url' => $pds_endpoint, 159 224 ] 160 225 ); … … 165 230 * @return array<string,mixed>|\WP_Error 166 231 */ 167 public function create_record( array $record, string $access_token ) {232 public function create_record( array $record, string $access_token, string $did ) { 168 233 if ( ! $record || ! $access_token ) { 169 234 return new \WP_Error( 'autoblue_invalid_record_or_access_token', __( 'Invalid record or access token.', 'autoblue' ) ); 235 } 236 237 $pds_endpoint = $this->resolve_pds_endpoint( $did ); 238 239 if ( is_wp_error( $pds_endpoint ) ) { 240 return $pds_endpoint; 170 241 } 171 242 … … 178 249 ], 179 250 'body' => $record, 180 'base_url' => self::BASE_URL,181 ] 182 ); 183 } 184 185 /** 186 * @return array<string,mixed>|\WP_Error 187 */ 188 public function upload_blob( string $blob, string $mime_type, string $access_token ) {251 'base_url' => $pds_endpoint, 252 ] 253 ); 254 } 255 256 /** 257 * @return array<string,mixed>|\WP_Error 258 */ 259 public function upload_blob( string $blob, string $mime_type, string $access_token, string $did ) { 189 260 if ( ! $blob || ! $mime_type ) { 190 261 return new \WP_Error( 'autoblue_invalid_blob_or_mime_type', __( 'Invalid blob or MIME type.', 'autoblue' ) ); … … 193 264 if ( ! $access_token ) { 194 265 return new \WP_Error( 'autoblue_invalid_access_token', __( 'Invalid access token.', 'autoblue' ) ); 266 } 267 268 $pds_endpoint = $this->resolve_pds_endpoint( $did ); 269 270 if ( is_wp_error( $pds_endpoint ) ) { 271 return $pds_endpoint; 195 272 } 196 273 … … 204 281 ], 205 282 'body' => $blob, 206 'base_url' => self::BASE_URL,283 'base_url' => $pds_endpoint, 207 284 ] 208 285 ); -
autoblue/trunk/includes/ConnectionsManager.php
r3211894 r3375073 97 97 98 98 update_option( self::OPTION_KEY, $filtered_connections ); 99 99 100 delete_transient( $this->get_transient_key( $did ) ); 101 delete_transient( 'autoblue_pds_endpoint_' . $did ); 100 102 101 103 $this->log->info( __( 'Connection with DID `{did}` deleted.', 'autoblue' ), [ 'did' => $did ] ); … … 156 158 } 157 159 158 $response = $this->api_client->refresh_session( $connection['refresh_jwt'] );160 $response = $this->api_client->refresh_session( $connection['refresh_jwt'], $did ); 159 161 160 162 if ( is_wp_error( $response ) ) { -
autoblue/trunk/readme.txt
r3276483 r3375073 2 2 Contributors: danielpost 3 3 Tags: social, bluesky, auto, share, post 4 Stable tag: 0.0.64 Stable tag: 1.0.0 5 5 Requires at least: 6.6 6 6 Tested up to: 6.8 … … 47 47 == Changelog == 48 48 49 = 1.0.0 = 50 * Autoblue is now out of beta. 51 * Feature: Add support for self-hosted PDS 52 49 53 = 0.0.6 = 50 54 * Improvement: Autoblue settings page is now more mobile-friendly. -
autoblue/trunk/vendor/composer/installed.php
r3276419 r3375073 2 2 'root' => array( 3 3 'name' => 'posty/autoblue', 4 'pretty_version' => 'v 0.0.6',5 'version' => ' 0.0.6.0',6 'reference' => ' 06a849712982c8d95813f990356a98e6be2d45eb',4 'pretty_version' => 'v1.0.0', 5 'version' => '1.0.0.0', 6 'reference' => '18678a3236123ada8746916c2d3a8fcb1d6ac2db', 7 7 'type' => 'project', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'posty/autoblue' => array( 23 'pretty_version' => 'v 0.0.6',24 'version' => ' 0.0.6.0',25 'reference' => ' 06a849712982c8d95813f990356a98e6be2d45eb',23 'pretty_version' => 'v1.0.0', 24 'version' => '1.0.0.0', 25 'reference' => '18678a3236123ada8746916c2d3a8fcb1d6ac2db', 26 26 'type' => 'project', 27 27 'install_path' => __DIR__ . '/../../', -
autoblue/trunk/vendor/composer/platform_check.php
r3214602 r3375073 20 20 } 21 21 } 22 trigger_error( 23 'Composer detected issues in your platform: ' . implode(' ', $issues), 24 E_USER_ERROR 22 throw new \RuntimeException( 23 'Composer detected issues in your platform: ' . implode(' ', $issues) 25 24 ); 26 25 }
Note: See TracChangeset
for help on using the changeset viewer.