Giter VIP home page Giter VIP logo

Comments (5)

janboddez avatar janboddez commented on July 20, 2024

Right, so I got boosts to work but not undoing them. (What I tried was, when a Delete activity comes by for a "repost," to turn it into an "Undo" instead. Had a quick look at Pixelfed's source, couldn't readily see why it wouldn't work.)

I also skipped the part where I really should check whether the remote page even supports Activity Streams JSON.

Code is here, if someone ever wants to give it a go:

if ( 'activity' === $class && $post_or_comment instanceof \WP_Post ) {
// Might this be a repost?
$kind = get_post_meta( $post_or_comment->ID, '_indieblocks_kind', true );
$linked_url = get_post_meta( $post_or_comment->ID, '_indieblocks_linked_url', true );
if ( 'repost' === $kind && '' !== $linked_url ) {
if ( 'Delete' === $array['type'] ) {
error_log( '[Add-on for ActivityPub] Undoing a boost!' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
$orig = $array['object'];
// Replace Delete with Undo, rework `object`. Doesn't seem
// to work, though, although I don't quite know why.
// @link https://github.com/pixelfed/pixelfed/blob/dev/app/Transformer/ActivityPub/Verb/UndoAnnounce.php
$array['type'] = 'Undo';
$array['object'] = array(
'id' => $orig['id'],
'type' => 'Announce',
'actor' => isset( $orig['actor'] ) ? $orig['actor'] : $array['actor'],
'to' => $orig['to'],
'cc' => $orig['cc'],
'published' => $orig['published'],
'object' => $linked_url,
);
} else {
error_log( '[Add-on for ActivityPub] "Creating" a boost!' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
$array['type'] = 'Announce';
$array['object'] = $linked_url;
}
}
}

from addon-for-activitypub.

janboddez avatar janboddez commented on July 20, 2024

Looks like ... Friends does this? https://github.com/akirk/friends/blob/074292f7812eae7443f6585d8218fa142b1d8c46/feed-parsers/class-feed-parser-activitypub.php#L2031-L2047

from addon-for-activitypub.

janboddez avatar janboddez commented on July 20, 2024

So, the previous approach worked (but Undo did not). The Friends approach doesn't seem to work (for me).

But: we should be able to just do (after minor changes): https://github.com/Automattic/wordpress-activitypub/blob/f6b4783dedbc5ad07c42a9c49a275ecaed05a227/includes/class-activity-dispatcher.php#L92-L113

from addon-for-activitypub.

janboddez avatar janboddez commented on July 20, 2024

https://github.com/pixelfed/pixelfed/blob/dev/app/Transformer/ActivityPub/Verb/UndoAnnounce.php

from addon-for-activitypub.

janboddez avatar janboddez commented on July 20, 2024

OK, we got it working, and undo's too. The one thing that's weird, but that goes for "regular" posts, too, is that "undeleting" doesn't work. Meaning, this is just the plugin's behavior, I guess.

Oh, and another thing is that undoing a boost does not automatically "delete" the accompanying (in Mastodon) notification. Maybe we shouldn't "mention" users?

from addon-for-activitypub.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.