Plugin Directory

Changeset 3375073


Ignore:
Timestamp:
10/08/2025 12:04:36 PM (4 months ago)
Author:
danielpost
Message:

Update to version 1.0.0 from GitHub

Location:
autoblue
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • autoblue/tags/1.0.0/autoblue.php

    r3276419 r3375073  
    88 * License: GPLv2 or later
    99 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    10  * Version: 0.0.6
     10 * Version: 1.0.0
    1111 * Text Domain: autoblue
    1212 * Requires at least: 6.6
     
    2121require_once __DIR__ . '/vendor/autoload.php';
    2222
    23 define( 'AUTOBLUE_VERSION', '0.0.6' );
     23define( 'AUTOBLUE_VERSION', '1.0.0' );
    2424define( 'AUTOBLUE_SLUG', 'autoblue' );
    2525define( 'AUTOBLUE_BASENAME', plugin_basename( __FILE__ ) );
  • autoblue/tags/1.0.0/includes/Bluesky.php

    r3276419 r3375073  
    5555     * @return array<string,mixed>|false
    5656     */
    57     private function upload_image( int $image_id, string $access_token ) {
     57    private function upload_image( int $image_id, string $access_token, string $did ) {
    5858        if ( ! $image_id || ! $access_token ) {
    5959            return false;
     
    9090        }
    9191
    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 );
    9393
    9494        if ( is_wp_error( $blob ) ) {
     
    174174        $image_blob = false;
    175175        if ( has_post_thumbnail( $post->ID ) ) {
    176             $image_blob = $this->upload_image( get_post_thumbnail_id( $post->ID ), $connection['access_jwt'] ); // @phpstan-ignore argument.type
     176            $image_blob = $this->upload_image( get_post_thumbnail_id( $post->ID ), $connection['access_jwt'], $connection['did'] ); // @phpstan-ignore argument.type
    177177        }
    178178
     
    181181        }
    182182
    183         $response = $this->api_client->create_record( $body, $connection['access_jwt'] );
     183        $response = $this->api_client->create_record( $body, $connection['access_jwt'], $connection['did'] );
    184184
    185185        if ( is_wp_error( $response ) ) {
  • autoblue/tags/1.0.0/includes/Bluesky/API.php

    r3211894 r3375073  
    120120
    121121    /**
     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    /**
    122173     * @return array<string,mixed>|\WP_Error
    123174     */
     
    127178        }
    128179
    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(
    130187            [
    131188                'endpoint' => 'com.atproto.server.createSession',
     
    135192                    'password'   => $app_password,
    136193                ],
    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 ) {
    146205        if ( ! $refresh_jwt ) {
    147206            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;
    148213        }
    149214
     
    156221                    'Authorization' => 'Bearer ' . $refresh_jwt,
    157222                ],
    158                 'base_url' => self::BASE_URL,
     223                'base_url' => $pds_endpoint,
    159224            ]
    160225        );
     
    165230     * @return array<string,mixed>|\WP_Error
    166231     */
    167     public function create_record( array $record, string $access_token ) {
     232    public function create_record( array $record, string $access_token, string $did ) {
    168233        if ( ! $record || ! $access_token ) {
    169234            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;
    170241        }
    171242
     
    178249                ],
    179250                '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 ) {
    189260        if ( ! $blob || ! $mime_type ) {
    190261            return new \WP_Error( 'autoblue_invalid_blob_or_mime_type', __( 'Invalid blob or MIME type.', 'autoblue' ) );
     
    193264        if ( ! $access_token ) {
    194265            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;
    195272        }
    196273
     
    204281                ],
    205282                'body'     => $blob,
    206                 'base_url' => self::BASE_URL,
     283                'base_url' => $pds_endpoint,
    207284            ]
    208285        );
  • autoblue/tags/1.0.0/includes/ConnectionsManager.php

    r3211894 r3375073  
    9797
    9898        update_option( self::OPTION_KEY, $filtered_connections );
     99
    99100        delete_transient( $this->get_transient_key( $did ) );
     101        delete_transient( 'autoblue_pds_endpoint_' . $did );
    100102
    101103        $this->log->info( __( 'Connection with DID `{did}` deleted.', 'autoblue' ), [ 'did' => $did ] );
     
    156158        }
    157159
    158         $response = $this->api_client->refresh_session( $connection['refresh_jwt'] );
     160        $response = $this->api_client->refresh_session( $connection['refresh_jwt'], $did );
    159161
    160162        if ( is_wp_error( $response ) ) {
  • autoblue/tags/1.0.0/readme.txt

    r3276483 r3375073  
    22Contributors: danielpost
    33Tags: social, bluesky, auto, share, post
    4 Stable tag: 0.0.6
     4Stable tag: 1.0.0
    55Requires at least: 6.6
    66Tested up to: 6.8
     
    4747== Changelog ==
    4848
     49= 1.0.0 =
     50* Autoblue is now out of beta.
     51* Feature: Add support for self-hosted PDS
     52
    4953= 0.0.6 =
    5054* Improvement: Autoblue settings page is now more mobile-friendly.
  • autoblue/tags/1.0.0/vendor/composer/installed.php

    r3276419 r3375073  
    22    'root' => array(
    33        'name' => 'posty/autoblue',
    4         'pretty_version' => 'v0.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',
    77        'type' => 'project',
    88        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'posty/autoblue' => array(
    23             'pretty_version' => 'v0.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',
    2626            'type' => 'project',
    2727            'install_path' => __DIR__ . '/../../',
  • autoblue/tags/1.0.0/vendor/composer/platform_check.php

    r3214602 r3375073  
    2020        }
    2121    }
    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)
    2524    );
    2625}
  • autoblue/trunk/autoblue.php

    r3276419 r3375073  
    88 * License: GPLv2 or later
    99 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    10  * Version: 0.0.6
     10 * Version: 1.0.0
    1111 * Text Domain: autoblue
    1212 * Requires at least: 6.6
     
    2121require_once __DIR__ . '/vendor/autoload.php';
    2222
    23 define( 'AUTOBLUE_VERSION', '0.0.6' );
     23define( 'AUTOBLUE_VERSION', '1.0.0' );
    2424define( 'AUTOBLUE_SLUG', 'autoblue' );
    2525define( 'AUTOBLUE_BASENAME', plugin_basename( __FILE__ ) );
  • autoblue/trunk/includes/Bluesky.php

    r3276419 r3375073  
    5555     * @return array<string,mixed>|false
    5656     */
    57     private function upload_image( int $image_id, string $access_token ) {
     57    private function upload_image( int $image_id, string $access_token, string $did ) {
    5858        if ( ! $image_id || ! $access_token ) {
    5959            return false;
     
    9090        }
    9191
    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 );
    9393
    9494        if ( is_wp_error( $blob ) ) {
     
    174174        $image_blob = false;
    175175        if ( has_post_thumbnail( $post->ID ) ) {
    176             $image_blob = $this->upload_image( get_post_thumbnail_id( $post->ID ), $connection['access_jwt'] ); // @phpstan-ignore argument.type
     176            $image_blob = $this->upload_image( get_post_thumbnail_id( $post->ID ), $connection['access_jwt'], $connection['did'] ); // @phpstan-ignore argument.type
    177177        }
    178178
     
    181181        }
    182182
    183         $response = $this->api_client->create_record( $body, $connection['access_jwt'] );
     183        $response = $this->api_client->create_record( $body, $connection['access_jwt'], $connection['did'] );
    184184
    185185        if ( is_wp_error( $response ) ) {
  • autoblue/trunk/includes/Bluesky/API.php

    r3211894 r3375073  
    120120
    121121    /**
     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    /**
    122173     * @return array<string,mixed>|\WP_Error
    123174     */
     
    127178        }
    128179
    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(
    130187            [
    131188                'endpoint' => 'com.atproto.server.createSession',
     
    135192                    'password'   => $app_password,
    136193                ],
    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 ) {
    146205        if ( ! $refresh_jwt ) {
    147206            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;
    148213        }
    149214
     
    156221                    'Authorization' => 'Bearer ' . $refresh_jwt,
    157222                ],
    158                 'base_url' => self::BASE_URL,
     223                'base_url' => $pds_endpoint,
    159224            ]
    160225        );
     
    165230     * @return array<string,mixed>|\WP_Error
    166231     */
    167     public function create_record( array $record, string $access_token ) {
     232    public function create_record( array $record, string $access_token, string $did ) {
    168233        if ( ! $record || ! $access_token ) {
    169234            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;
    170241        }
    171242
     
    178249                ],
    179250                '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 ) {
    189260        if ( ! $blob || ! $mime_type ) {
    190261            return new \WP_Error( 'autoblue_invalid_blob_or_mime_type', __( 'Invalid blob or MIME type.', 'autoblue' ) );
     
    193264        if ( ! $access_token ) {
    194265            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;
    195272        }
    196273
     
    204281                ],
    205282                'body'     => $blob,
    206                 'base_url' => self::BASE_URL,
     283                'base_url' => $pds_endpoint,
    207284            ]
    208285        );
  • autoblue/trunk/includes/ConnectionsManager.php

    r3211894 r3375073  
    9797
    9898        update_option( self::OPTION_KEY, $filtered_connections );
     99
    99100        delete_transient( $this->get_transient_key( $did ) );
     101        delete_transient( 'autoblue_pds_endpoint_' . $did );
    100102
    101103        $this->log->info( __( 'Connection with DID `{did}` deleted.', 'autoblue' ), [ 'did' => $did ] );
     
    156158        }
    157159
    158         $response = $this->api_client->refresh_session( $connection['refresh_jwt'] );
     160        $response = $this->api_client->refresh_session( $connection['refresh_jwt'], $did );
    159161
    160162        if ( is_wp_error( $response ) ) {
  • autoblue/trunk/readme.txt

    r3276483 r3375073  
    22Contributors: danielpost
    33Tags: social, bluesky, auto, share, post
    4 Stable tag: 0.0.6
     4Stable tag: 1.0.0
    55Requires at least: 6.6
    66Tested up to: 6.8
     
    4747== Changelog ==
    4848
     49= 1.0.0 =
     50* Autoblue is now out of beta.
     51* Feature: Add support for self-hosted PDS
     52
    4953= 0.0.6 =
    5054* Improvement: Autoblue settings page is now more mobile-friendly.
  • autoblue/trunk/vendor/composer/installed.php

    r3276419 r3375073  
    22    'root' => array(
    33        'name' => 'posty/autoblue',
    4         'pretty_version' => 'v0.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',
    77        'type' => 'project',
    88        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'posty/autoblue' => array(
    23             'pretty_version' => 'v0.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',
    2626            'type' => 'project',
    2727            'install_path' => __DIR__ . '/../../',
  • autoblue/trunk/vendor/composer/platform_check.php

    r3214602 r3375073  
    2020        }
    2121    }
    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)
    2524    );
    2625}
Note: See TracChangeset for help on using the changeset viewer.