Drop meta key _event_bridge_for_activitypub_is_remote_cached
All checks were successful
PHP Code Checker / PHP Code Checker (pull_request) Successful in 47s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m6s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Successful in 1m3s
All checks were successful
PHP Code Checker / PHP Code Checker (pull_request) Successful in 47s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m6s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Successful in 1m3s
always use _event_bridge_for_activitypub_event_source instead
This commit is contained in:
parent
963ae48784
commit
f1572798a8
6 changed files with 31 additions and 36 deletions
|
@ -10,9 +10,8 @@
|
||||||
namespace Event_Bridge_For_ActivityPub\ActivityPub\Transmogrifier;
|
namespace Event_Bridge_For_ActivityPub\ActivityPub\Transmogrifier;
|
||||||
|
|
||||||
use Activitypub\Activity\Extended_Object\Event;
|
use Activitypub\Activity\Extended_Object\Event;
|
||||||
use DateTime;
|
use Event_Bridge_For_ActivityPub\ActivityPub\Model\Event_Source;
|
||||||
use Event_Bridge_For_ActivityPub\ActivityPub\Collection\Event_Sources;
|
use Event_Bridge_For_ActivityPub\ActivityPub\Collection\Event_Sources;
|
||||||
use Exception;
|
|
||||||
use WP_Error;
|
use WP_Error;
|
||||||
|
|
||||||
use function Activitypub\sanitize_url;
|
use function Activitypub\sanitize_url;
|
||||||
|
@ -33,6 +32,13 @@ abstract class Base {
|
||||||
*/
|
*/
|
||||||
protected $activitypub_event;
|
protected $activitypub_event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current Event object.
|
||||||
|
*
|
||||||
|
* @var Event_Source
|
||||||
|
*/
|
||||||
|
protected $event_source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal function to actually save the event.
|
* Internal function to actually save the event.
|
||||||
*
|
*
|
||||||
|
@ -54,6 +60,7 @@ abstract class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->activitypub_event = $activitypub_event;
|
$this->activitypub_event = $activitypub_event;
|
||||||
|
$this->event_source = $event_source;
|
||||||
|
|
||||||
$post_id = $this->save_event();
|
$post_id = $this->save_event();
|
||||||
|
|
||||||
|
@ -67,7 +74,6 @@ abstract class Base {
|
||||||
'event_bridge_for_activitypub_write_log',
|
'event_bridge_for_activitypub_write_log',
|
||||||
array( "[ACTIVITYPUB] Processed incoming event {$event_id} from {$event_source_activitypub_id}" )
|
array( "[ACTIVITYPUB] Processed incoming event {$event_id} from {$event_source_activitypub_id}" )
|
||||||
);
|
);
|
||||||
update_post_meta( $post_id, '_event_bridge_for_activitypub_is_remote_cached', true );
|
|
||||||
update_post_meta( $post_id, '_event_bridge_for_activitypub_event_source', absint( $event_source_post_id ) );
|
update_post_meta( $post_id, '_event_bridge_for_activitypub_event_source', absint( $event_source_post_id ) );
|
||||||
update_post_meta( $post_id, 'activitypub_content_visibility', constant( 'ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL' ) ?? '' );
|
update_post_meta( $post_id, 'activitypub_content_visibility', constant( 'ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL' ) ?? '' );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -96,7 +96,7 @@ class The_Events_Calendar extends Base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $post_id && get_post_meta( $post_id, '_event_bridge_for_activitypub_is_remote_cached', true ) ) {
|
if ( $post_id && get_post_meta( $post_id, '_event_bridge_for_activitypub_event_source', true ) ) {
|
||||||
$result = tribe_venues()->where( 'id', $post_id )->set_args( $this->get_venue_args( $location ) )->save();
|
$result = tribe_venues()->where( 'id', $post_id )->set_args( $this->get_venue_args( $location ) )->save();
|
||||||
if ( array_key_exists( $post_id, $result ) && $result[ $post_id ] ) {
|
if ( array_key_exists( $post_id, $result ) && $result[ $post_id ] ) {
|
||||||
return $post_id;
|
return $post_id;
|
||||||
|
@ -105,7 +105,7 @@ class The_Events_Calendar extends Base {
|
||||||
$post = tribe_venues()->set_args( $this->get_venue_args( $location ) )->create();
|
$post = tribe_venues()->set_args( $this->get_venue_args( $location ) )->create();
|
||||||
if ( $post ) {
|
if ( $post ) {
|
||||||
$post_id = $post->ID;
|
$post_id = $post->ID;
|
||||||
update_post_meta( $post_id, '_event_bridge_for_activitypub_is_remote_cached', true );
|
update_post_meta( $post_id, '_event_bridge_for_activitypub_event_source', $this->event_source->get__id() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,32 +90,6 @@ class Event_Sources {
|
||||||
if ( ! $event_plugin_integration instanceof Feature_Event_Sources && $event_plugin_integration instanceof Event_Plugin_Integration ) {
|
if ( ! $event_plugin_integration instanceof Feature_Event_Sources && $event_plugin_integration instanceof Event_Plugin_Integration ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
\register_post_meta(
|
|
||||||
$event_plugin_integration::get_post_type(),
|
|
||||||
'_event_bridge_for_activitypub_is_remote_cached',
|
|
||||||
array(
|
|
||||||
'type' => 'string',
|
|
||||||
'single' => false,
|
|
||||||
'sanitize_callback' => function ( $value ) {
|
|
||||||
return sanitize_url( $value );
|
|
||||||
},
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$location_post_type = $event_plugin_integration::get_location_post_type();
|
|
||||||
if ( $location_post_type ) {
|
|
||||||
\register_post_meta(
|
|
||||||
$location_post_type,
|
|
||||||
'_event_bridge_for_activitypub_is_remote_cached',
|
|
||||||
array(
|
|
||||||
'type' => 'string',
|
|
||||||
'single' => false,
|
|
||||||
'sanitize_callback' => function ( $value ) {
|
|
||||||
return sanitize_url( $value );
|
|
||||||
},
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
\register_post_meta(
|
\register_post_meta(
|
||||||
$event_plugin_integration::get_post_type(),
|
$event_plugin_integration::get_post_type(),
|
||||||
|
@ -126,6 +100,21 @@ class Event_Sources {
|
||||||
'sanitize_callback' => 'absint',
|
'sanitize_callback' => 'absint',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$location_post_type = $event_plugin_integration::get_location_post_type();
|
||||||
|
if ( $location_post_type ) {
|
||||||
|
\register_post_meta(
|
||||||
|
$location_post_type,
|
||||||
|
'_event_bridge_for_activitypub_event_source',
|
||||||
|
array(
|
||||||
|
'type' => 'string',
|
||||||
|
'single' => false,
|
||||||
|
'sanitize_callback' => function ( $value ) {
|
||||||
|
return sanitize_url( $value );
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +194,7 @@ class Event_Sources {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function is_cached_external_event_post( $post ): bool {
|
public static function is_cached_external_event_post( $post ): bool {
|
||||||
if ( get_post_meta( $post->ID, '_event_bridge_for_activitypub_is_remote_cached', true ) ) {
|
if ( get_post_meta( $post->ID, '_event_bridge_for_activitypub_event_source', true ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ final class GatherPress extends Event_Plugin_Integration implements Feature_Even
|
||||||
WHERE {$wpdb->prefix}posts.post_type = 'gatherpress_event'
|
WHERE {$wpdb->prefix}posts.post_type = 'gatherpress_event'
|
||||||
AND {$wpdb->prefix}posts.post_status = 'publish'
|
AND {$wpdb->prefix}posts.post_status = 'publish'
|
||||||
AND {$wpdb->prefix}gatherpress_events.datetime_end_gmt <= %s
|
AND {$wpdb->prefix}gatherpress_events.datetime_end_gmt <= %s
|
||||||
AND {$wpdb->prefix}postmeta.meta_key = '_event_bridge_for_activitypub_is_remote_cached'
|
AND {$wpdb->prefix}postmeta.meta_key = '_event_bridge_for_activitypub_event_source'
|
||||||
",
|
",
|
||||||
$ends_before_time_string
|
$ends_before_time_string
|
||||||
),
|
),
|
||||||
|
@ -129,7 +129,7 @@ final class GatherPress extends Event_Plugin_Integration implements Feature_Even
|
||||||
if ( $post && 'gatherpress_event' === $post->post_type ) {
|
if ( $post && 'gatherpress_event' === $post->post_type ) {
|
||||||
// Add your custom logic here to decide whether to force the link.
|
// Add your custom logic here to decide whether to force the link.
|
||||||
// For example, force it only if a specific meta field exists.
|
// For example, force it only if a specific meta field exists.
|
||||||
if ( get_post_meta( $post->ID, '_event_bridge_for_activitypub_is_remote_cached', true ) ) {
|
if ( get_post_meta( $post->ID, '_event_bridge_for_activitypub_event_source', true ) ) {
|
||||||
return true; // Force the online event link.
|
return true; // Force the online event link.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ final class The_Events_Calendar extends Event_plugin_Integration implements Feat
|
||||||
*/
|
*/
|
||||||
public static function add_is_activitypub_remote_cached_to_query( $schema_entry ) {
|
public static function add_is_activitypub_remote_cached_to_query( $schema_entry ) {
|
||||||
$schema_entry['meta_query']['is-remote-cached'] = array(
|
$schema_entry['meta_query']['is-remote-cached'] = array(
|
||||||
'key' => '_event_bridge_for_activitypub_is_remote_cached',
|
'key' => '_event_bridge_for_activitypub_event_source',
|
||||||
'compare' => 'EXISTS',
|
'compare' => 'EXISTS',
|
||||||
);
|
);
|
||||||
return $schema_entry;
|
return $schema_entry;
|
||||||
|
|
|
@ -96,7 +96,7 @@ final class VS_Event_List extends Event_Plugin_Integration implements Feature_Ev
|
||||||
'meta_query' => array(
|
'meta_query' => array(
|
||||||
'relation' => 'AND',
|
'relation' => 'AND',
|
||||||
array(
|
array(
|
||||||
'key' => '_event_bridge_for_activitypub_is_remote_cached',
|
'key' => '_event_bridge_for_activitypub_event_source',
|
||||||
'compare' => 'EXISTS',
|
'compare' => 'EXISTS',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
|
Reference in a new issue