-
Notifications
You must be signed in to change notification settings - Fork 83
Handle quote comment deletion with Reject activity #2460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 33 commits
3afe849
a6b77d4
4b3b44d
f3a587c
2a8353b
960dfe1
f3e6cf9
5553a2a
d01494f
22be295
c011031
3893740
ad6d41a
007d4db
33839fe
3ff06ac
a1ebc93
79dcadd
f96fe1c
2eb2486
cfa6544
5d4187f
2e58dbe
9b20c10
7d4d27a
818ada9
34c58ed
adc9bc1
b646fcb
d4b193c
e8b42e8
62be0dc
b9a94b1
9213e0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: minor | ||
| Type: added | ||
|
|
||
| Added support for quote comments, improving detection and handling of quoted replies and links in post interactions. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,17 @@ public static function add( $activity, $recipients ) { | |
| $title = self::get_object_title( $activity->get_object() ); | ||
| $visibility = is_activity_public( $activity ) ? ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC : ACTIVITYPUB_CONTENT_VISIBILITY_PRIVATE; | ||
|
|
||
| /* | ||
| * For activities with an 'instrument' property (e.g., QuoteRequest), we store | ||
| * the instrument URL as the object_id. This allows efficient querying by instrument. | ||
| * For all other activities, we store the object URL as before. | ||
| */ | ||
| if ( $activity->has( 'instrument' ) && $activity->get_instrument() ) { | ||
| $object_id = object_to_uri( $activity->get_instrument() ); | ||
| } else { | ||
| $object_id = object_to_uri( $activity->get_object() ); | ||
| } | ||
|
Comment on lines
+91
to
+95
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a situation where
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe... I was not sure if we can simply always prioritize |
||
|
|
||
| $inbox_item = array( | ||
| 'post_type' => self::POST_TYPE, | ||
| 'post_title' => sprintf( | ||
|
|
@@ -96,7 +107,7 @@ public static function add( $activity, $recipients ) { | |
| 'post_status' => 'publish', | ||
| 'guid' => $activity->get_id(), | ||
| 'meta_input' => array( | ||
| '_activitypub_object_id' => object_to_uri( $activity->get_object() ), | ||
| '_activitypub_object_id' => $object_id, | ||
| '_activitypub_activity_type' => $activity->get_type(), | ||
| '_activitypub_activity_remote_actor' => object_to_uri( $activity->get_actor() ), | ||
| 'activitypub_content_visibility' => $visibility, | ||
|
|
@@ -371,6 +382,50 @@ public static function get_by_guid_and_recipient( $guid, $user_id ) { | |
| return $post; | ||
| } | ||
|
|
||
| /** | ||
| * Get an inbox item by activity type and object ID. | ||
| * | ||
| * This is useful for finding specific activity types (like QuoteRequest) | ||
| * by their object identifier. For QuoteRequest activities, the object_id | ||
| * is the instrument URL (the quote post). | ||
| * | ||
| * @param string $activity_type The activity type (e.g., 'QuoteRequest'). | ||
| * @param string $object_id The object identifier to search for. | ||
| * | ||
| * @return \WP_Post|\WP_Error The inbox item or WP_Error if not found. | ||
|
Comment on lines
+383
to
+393
|
||
| */ | ||
| public static function get_by_type_and_object( $activity_type, $object_id ) { | ||
| global $wpdb; | ||
|
|
||
| // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | ||
| $post_id = $wpdb->get_var( | ||
| $wpdb->prepare( | ||
| "SELECT p.ID | ||
| FROM {$wpdb->posts} p | ||
| INNER JOIN {$wpdb->postmeta} pm1 ON p.ID = pm1.post_id AND pm1.meta_key = '_activitypub_activity_type' | ||
| INNER JOIN {$wpdb->postmeta} pm2 ON p.ID = pm2.post_id AND pm2.meta_key = '_activitypub_object_id' | ||
| WHERE p.post_type = %s | ||
| AND pm1.meta_value = %s | ||
| AND pm2.meta_value = %s | ||
| ORDER BY p.ID DESC | ||
| LIMIT 1", | ||
| self::POST_TYPE, | ||
| $activity_type, | ||
| $object_id | ||
| ) | ||
| ); | ||
|
Comment on lines
+399
to
+414
|
||
|
|
||
| if ( ! $post_id ) { | ||
| return new \WP_Error( | ||
| 'activitypub_inbox_item_not_found', | ||
| \__( 'Inbox item not found', 'activitypub' ), | ||
| array( 'status' => 404 ) | ||
| ); | ||
| } | ||
|
|
||
| return \get_post( $post_id ); | ||
| } | ||
|
|
||
| /** | ||
| * Deduplicate inbox items with the same GUID. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider documenting the side effect of this change on existing code that may query
_activitypub_object_idmeta. For QuoteRequest activities, the_activitypub_object_idnow stores the instrument URL instead of the object URL. This is a breaking change in the meta structure. While this is necessary for the new feature, adding a note in the comment about backwards compatibility or migration considerations would be helpful. For instance, any existing code that queries by object URL for QuoteRequest activities will no longer find them.