PluginProbe
ActivityPub / 5.1.0
ActivityPub v5.1.0
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | integration/class-nodeinfo.php +11 -67 9.2.25.1.0 View file →
@@ -6,13 +6,11 @@
6 6 */
7 7
8 8 namespace Activitypub\Integration;
9 9
10 -use Activitypub\Webfinger;
11 -
10 +use function Activitypub\get_total_users;
12 11 use function Activitypub\get_active_users;
13 12 use function Activitypub\get_rest_url_by_path;
14 -use function Activitypub\get_total_users;
15 13
16 14 /**
17 15 * Compatibility with the NodeInfo plugin.
18 16 *
@@ -25,9 +23,9 @@
25 23 public static function init() {
26 24 \add_filter( 'nodeinfo_data', array( self::class, 'add_nodeinfo_data' ), 10, 2 );
27 25 \add_filter( 'nodeinfo2_data', array( self::class, 'add_nodeinfo2_data' ) );
28 26
29 - \add_filter( 'nodeinfo_discovery', array( self::class, 'add_wellknown_nodeinfo_data' ) );
27 + \add_filter( 'wellknown_nodeinfo_data', array( self::class, 'add_wellknown_nodeinfo_data' ), 10, 2 );
30 28 }
31 29
32 30 /**
33 31 * Extend NodeInfo data.
@@ -37,54 +35,21 @@
37 35 *
38 36 * @return array The extended array.
39 37 */
40 38 public static function add_nodeinfo_data( $nodeinfo, $version ) {
41 - $nodeinfo = \wp_parse_args(
42 - $nodeinfo,
43 - array(
44 - 'version' => $version,
45 - 'software' => array(),
46 - 'usage' => array(
47 - 'users' => array(
48 - 'total' => 0,
49 - 'activeMonth' => 0,
50 - 'activeHalfyear' => 0,
51 - ),
52 - ),
53 - 'protocols' => array(),
54 - 'services' => array(
55 - 'inbound' => array(),
56 - 'outbound' => array(),
57 - ),
58 - 'metadata' => array(),
59 - )
60 - );
61 -
62 - if ( \version_compare( $version, '2.1', '>=' ) ) {
63 - $nodeinfo['software']['homepage'] = 'https://wordpress.org/plugins/activitypub/';
64 - $nodeinfo['software']['repository'] = 'https://github.com/Automattic/wordpress-activitypub';
39 + if ( $version >= '2.0' ) {
40 + $nodeinfo['protocols'][] = 'activitypub';
41 + } else {
42 + $nodeinfo['protocols']['inbound'][] = 'activitypub';
43 + $nodeinfo['protocols']['outbound'][] = 'activitypub';
65 44 }
66 45
67 - $nodeinfo['protocols'][] = 'activitypub';
68 -
69 - $nodeinfo['services']['inbound'] = \array_merge(
70 - $nodeinfo['services']['inbound'],
71 - array( 'gnusocial' )
72 - );
73 - $nodeinfo['services']['outbound'] = \array_merge(
74 - $nodeinfo['services']['outbound'],
75 - array( 'friendica', 'gnusocial', 'mediagoblin', 'wordpress' )
76 - );
77 -
78 46 $nodeinfo['usage']['users'] = array(
79 47 'total' => get_total_users(),
80 - 'activeMonth' => get_active_users(),
81 - 'activeHalfyear' => get_active_users( 6 ),
48 + 'activeMonth' => get_active_users( '1 month ago' ),
49 + 'activeHalfyear' => get_active_users( '6 month ago' ),
82 50 );
83 51
84 - $nodeinfo['metadata']['federation'] = array( 'enabled' => true );
85 - $nodeinfo['metadata']['staffAccounts'] = self::get_staff();
86 -
87 52 return $nodeinfo;
88 53 }
89 54
90 55 /**
@@ -98,10 +63,10 @@
98 63 $nodeinfo['protocols'][] = 'activitypub';
99 64
100 65 $nodeinfo['usage']['users'] = array(
101 66 'total' => get_total_users(),
102 - 'activeMonth' => get_active_users(),
103 - 'activeHalfyear' => get_active_users( 6 ),
67 + 'activeMonth' => get_active_users( '1 month ago' ),
68 + 'activeHalfyear' => get_active_users( '6 month ago' ),
104 69 );
105 70
106 71 return $nodeinfo;
107 72 }
@@ -119,27 +84,6 @@
119 84 'href' => get_rest_url_by_path( 'application' ),
120 85 );
121 86
122 87 return $data;
123 - }
124 -
125 - /**
126 - * Get all staff accounts (admin users with the "activitypub" capability) and return them in WebFinger resource format.
127 - *
128 - * @return array List of staff accounts in WebFinger resource format.
129 - */
130 - private static function get_staff() {
131 - // Get all admin users with the cap activitypub.
132 - $admins = \get_users(
133 - array(
134 - 'role' => 'administrator',
135 - 'orderby' => 'ID',
136 - 'order' => 'ASC',
137 - 'cap' => 'activitypub',
138 - 'fields' => 'ID',
139 - )
140 - );
141 - $admins = \array_map( array( Webfinger::class, 'get_user_resource' ), $admins );
142 -
143 - return \array_values( \array_filter( $admins ) );
144 88 }
145 89 }