Add/small improvements (#384)

* flush rewrite rules after migration

* some activity improvements

* equate usernames with and without `.`

Can we equate `@notiz.blog@notiz.blog` with `@notizblog@notiz.blog`?

* better NodeInfo compatibility check

* fix `extract_name_from_uri`

* reset user check

* re-added action

* fix check
This commit is contained in:
Matthias Pfefferle 2023-07-31 20:15:11 +02:00 committed by GitHub
parent 9d30c413f0
commit 3afed5b296
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 5 deletions

View file

@ -26,6 +26,7 @@ class Activity extends Base_Object {
'schema' => 'http://schema.org#', 'schema' => 'http://schema.org#',
'pt' => 'https://joinpeertube.org/ns#', 'pt' => 'https://joinpeertube.org/ns#',
'toot' => 'http://joinmastodon.org/ns#', 'toot' => 'http://joinmastodon.org/ns#',
'litepub' => 'http://litepub.social/ns#',
'value' => 'schema:value', 'value' => 'schema:value',
'Hashtag' => 'as:Hashtag', 'Hashtag' => 'as:Hashtag',
'featured' => array( 'featured' => array(
@ -36,6 +37,8 @@ class Activity extends Base_Object {
'@id' => 'toot:featuredTags', '@id' => 'toot:featuredTags',
'@type' => '@id', '@type' => '@id',
), ),
'discoverable' => 'toot:discoverable',
'sensitive' => 'as:sensitive',
), ),
); );

View file

@ -627,7 +627,7 @@ class Base_Object {
} }
// if value is empty, try to get it from a getter. // if value is empty, try to get it from a getter.
if ( ! isset( $value ) ) { if ( ! $value ) {
$value = call_user_func( array( $this, 'get_' . $key ) ); $value = call_user_func( array( $this, 'get_' . $key ) );
} }
@ -636,7 +636,7 @@ class Base_Object {
} }
// if value is still empty, ignore it for the array and continue. // if value is still empty, ignore it for the array and continue.
if ( isset( $value ) ) { if ( $value ) {
$array[ snake_to_camel_case( $key ) ] = $value; $array[ snake_to_camel_case( $key ) ] = $value;
} }
} }

View file

@ -216,7 +216,7 @@ class Activitypub {
); );
} }
if ( ! \class_exists( 'Nodeinfo' ) && true === (bool) \get_option( 'blog_public', 1 ) ) { if ( ! \class_exists( 'Nodeinfo_Endpoint' ) && true === (bool) \get_option( 'blog_public', 1 ) ) {
\add_rewrite_rule( \add_rewrite_rule(
'^.well-known/nodeinfo', '^.well-known/nodeinfo',
'index.php?rest_route=/' . ACTIVITYPUB_REST_NAMESPACE . '/nodeinfo/discovery', 'index.php?rest_route=/' . ACTIVITYPUB_REST_NAMESPACE . '/nodeinfo/discovery',

View file

@ -1,6 +1,7 @@
<?php <?php
namespace Activitypub; namespace Activitypub;
use Activitypub\Activitypub;
use Activitypub\Model\Blog_User; use Activitypub\Model\Blog_User;
use Activitypub\Collection\Followers; use Activitypub\Collection\Followers;
@ -135,6 +136,8 @@ class Migration {
} }
} }
} }
Activitypub::flush_rewrite_rules();
} }
/** /**

View file

@ -87,6 +87,7 @@ class Users {
'number' => 1, 'number' => 1,
'hide_empty' => true, 'hide_empty' => true,
'fields' => 'ID', 'fields' => 'ID',
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'meta_query' => array( 'meta_query' => array(
'relation' => 'OR', 'relation' => 'OR',
array( array(

View file

@ -23,6 +23,13 @@ class Blog_User extends User {
*/ */
protected $type = 'Group'; protected $type = 'Group';
/**
* Is Account discoverable?
*
* @var boolean
*/
protected $discoverable = true;
public static function from_wp_user( $user_id ) { public static function from_wp_user( $user_id ) {
if ( is_user_disabled( $user_id ) ) { if ( is_user_disabled( $user_id ) ) {
return new WP_Error( return new WP_Error(