Plugin Directory

Changeset 3245135


Ignore:
Timestamp:
02/23/2025 06:36:14 AM (2 weeks ago)
Author:
akirk
Message:

enable-mastodon-apps 1.2.1

Location:
enable-mastodon-apps/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • enable-mastodon-apps/trunk/README.md

    r3245133 r3245135  
    77- Requires PHP: 7.4
    88- License: [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
    9 - Stable tag: 1.2.0
     9- Stable tag: 1.2.1
    1010
    1111Allow accessing your WordPress with Mastodon clients. Just enter your own blog URL as your instance.
     
    101101## Changelog
    102102
    103 ### 1.2.0
     103### 1.2.1
    104104- Fixed Boost, Like and Comment notifications ([#216])
    105105- Announce Initial and Changed App Settings ([#207], [#214])
  • enable-mastodon-apps/trunk/enable-mastodon-apps.php

    r3245133 r3245135  
    44 * Plugin author: Alex Kirk
    55 * Plugin URI: https://github.com/akirk/enable-mastodon-apps
    6  * Version: 1.2.0
     6 * Version: 1.2.1
    77 *
    88 * Description: Allow accessing your WordPress with Mastodon clients. Just enter your own blog URL as your instance.
     
    2121define( 'ENABLE_MASTODON_APPS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2222define( 'ENABLE_MASTODON_APPS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
    23 define( 'ENABLE_MASTODON_APPS_VERSION', '1.2.0' );
     23define( 'ENABLE_MASTODON_APPS_VERSION', '1.2.1' );
    2424
    2525require __DIR__ . '/vendor/bshaffer/oauth2-server-php/src/OAuth2/Autoloader.php';
  • enable-mastodon-apps/trunk/includes/class-comment-cpt.php

    r3245133 r3245135  
    237237        }
    238238
    239         return apply_filters( 'mastodon_api_account', null, $comment->comment_author_url, $request, null );
     239        $account = apply_filters( 'mastodon_api_account', null, $comment->comment_author_url, $request, null );
     240        if ( $account ) {
     241            return $account;
     242        }
     243
     244        $account = new Entity\Account();
     245        $account->id             = $comment->comment_author_url;
     246        $account->username       = $comment->comment_author;
     247        $account->display_name   = $comment->comment_author;
     248        $account->avatar         = get_avatar_url( $comment->comment_author_email );
     249        $account->avatar_static  = get_avatar_url( $comment->comment_author_email );
     250        $account->acct           = $comment->comment_author_url;
     251        $account->note           = '';
     252        $account->created_at     = new \DateTime( $comment->comment_date );
     253        $account->statuses_count = 0;
     254        $account->last_status_at = new \DateTime( $comment->comment_date );
     255        $account->url            = $comment->comment_author_url;
     256
     257        $account->source = array(
     258            'privacy'   => 'public',
     259            'sensitive' => false,
     260            'language'  => 'en',
     261            'note'      => 'Comment',
     262            'fields'    => array(),
     263        );
     264
     265        return Handler\Account::api_account_ensure_numeric_id( $account, $comment->comment_author_url );
    240266    }
    241267}
  • enable-mastodon-apps/trunk/includes/handler/class-account.php

    r3243595 r3245135  
    2828        add_filter( 'mastodon_api_account', array( $this, 'api_account' ), 10, 2 );
    2929        add_filter( 'mastodon_api_account', array( $this, 'api_account_ema' ), 10, 4 );
    30         add_filter( 'mastodon_api_account', array( $this, 'api_account_ensure_numeric_id' ), 100, 2 );
     30        add_filter( 'mastodon_api_account', array( get_called_class(), 'api_account_ensure_numeric_id' ), 100, 2 );
    3131    }
    3232
     
    9696    }
    9797
    98     public function api_account_ensure_numeric_id( $user_data, $user_id ) {
     98    public static function api_account_ensure_numeric_id( $user_data, $user_id ) {
    9999        if ( ! is_object( $user_data ) ) {
    100100            return $user_data;
  • enable-mastodon-apps/trunk/includes/handler/class-notification.php

    r3245133 r3245135  
    160160            foreach ( get_posts( $args ) as $post ) {
    161161                $comment_id = Comment_CPT::post_id_to_comment_id( $post->ID );
    162                 $account = apply_filters( 'mastodon_api_account', null, $post->post_author, null, $post );
    163162                switch ( get_comment_type( $comment_id ) ) {
    164163                    case 'like':
    165                         $type = 'like';
     164                        $type = 'favourite';
    166165                        $status  = apply_filters( 'mastodon_api_status', null, $post->post_parent, array() );
    167166                        break;
     
    174173                        $status  = apply_filters( 'mastodon_api_status', null, $post->ID, array() );
    175174                }
    176                 if ( $account && $status ) {
    177                     $notifications[] = $this->get_notification_array(
    178                         $type,
    179                         mysql2date( 'Y-m-d\TH:i:s.000P', $post->post_date, false ),
    180                         $account,
    181                         $status
    182                     );
     175                $account = apply_filters( 'mastodon_api_account', null, $post->post_author, null, $post );
     176                if ( $status ) {
     177                    $status->account = $account;
    183178                }
    184             }
    185         }
    186 
     179
     180                $notifications[] = $this->get_notification_array(
     181                    $type,
     182                    mysql2date( 'Y-m-d\TH:i:s.000P', $post->post_date, false ),
     183                    $account,
     184                    $status
     185                );
     186            }
     187        }
    187188        $min_id      = $request->get_param( 'min_id' );
    188189        $max_id      = $request->get_param( 'max_id' );
     
    245246     * @return array
    246247     */
    247     protected function get_notification_array( string $type, $date, \Enable_Mastodon_Apps\Entity\Account $account, \Enable_Mastodon_Apps\Entity\Status $status ): array {
     248    protected function get_notification_array( string $type, $date, ?\Enable_Mastodon_Apps\Entity\Account $account = null, ?\Enable_Mastodon_Apps\Entity\Status $status = null ): array {
    248249        $notification = array(
    249250            'id'         => preg_replace( '/[^0-9]/', '', $date ),
Note: See TracChangeset for help on using the changeset viewer.