Making WordPress.org

Changeset 12116


Ignore:
Timestamp:
10/12/2022 07:39:00 AM (4 years ago)
Author:
dd32
Message:

API: Trac GitHub Integration: When we know the WordPress.org user whose comments we're syncing from GitHub, link to the WordPress.org user rather than the GitHub user.

See #6533.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/webhook.php

    r11544 r12116  
    134134            }
    135135
     136            $authorship = "[{$pr_data->user->url} {$pr_data->user->name}]";
     137            if ( $user_id ) {
     138                $user       = get_user_by( 'id', $user_id );
     139                $authorship = "[https://profiles.wordpress.org/{$user->user_nicename}/ @{$user->user_login}]";
     140            }
     141
    136142            $trac->update(
    137143                $pr_data->trac_ticket[1],
    138144                "''This ticket was mentioned in [{$pr_data->html_url} PR #{$pr_number}] " .
    139145                    "on [https://github.com/{$pr_repo}/ {$pr_repo}] " .
    140                     "by [{$pr_data->user->url} {$pr_data->user->name}].''" .
     146                    "by {$authorship}.''" .
    141147                    ( $pr_description ? "\n{$pr_description}" : '' ),
    142148                $attributes,  // Attributes changed
     
    201207        }
    202208
    203         $comment_template = "{{{#!comment\n%s\n}}}\n[%s %s] commented on [%s %s]:\n\n%s";
    204         $comment_author   = find_wporg_user_by_github( $payload->comment->user->login );
     209        $comment_template = "{{{#!comment\n%s\n}}}\n%s commented on [%s %s]:\n\n%s";
     210        $user_id          = find_wporg_user_by_github( $payload->comment->user->login, 'ID' );
     211        $authorship       = "[{$payload->comment->user->html_url} {$payload->comment->user->login}]";
     212        $comment_author   = '';
    205213        $comment_time     = new \DateTime( $payload->comment->created_at );
     214
     215        if ( $user_id ) {
     216            $user           = get_user_by( 'id', $user_id );
     217            $authorship     = "[https://profiles.wordpress.org/{$user->user_nicename}/ @{$user->user_login}]";
     218            $comment_author = $user->user_login;
     219        }
    206220
    207221        $comment_body = sprintf(
    208222            $comment_template,
    209223            $payload->comment->id,
    210             $payload->comment->user->html_url,
    211             $payload->comment->user->login,
     224            $authorship,
    212225            $payload->comment->html_url,
    213226            'PR #' . $payload->issue->number,
Note: See TracChangeset for help on using the changeset viewer.