Giter VIP home page Giter VIP logo

addon-for-activitypub's Introduction

ActivityPub Add-on

Somewhat modifies the ActivityPub plugin’s behavior. Probably not ready for production. 😆

All features can be switched on or off separately. All of this is subject to change. No warranties whatsoever.

Options

Local-only Category

Posts (of any post type, as long as it supports WordPress’ built-in categories) in this category will not get “federated” and remain “local-only.”

Unlisted Category

Posts in this category will appear “unlisted” (or “less public”) on various Fediverse instances. (Whether you also hide these posts on, e.g., your site’s homepage, is up to you!)

To instead use, e.g., a custom field or post format, to decide if a post should be “unlisted,” there’s this filter (which takes precedence over whatever category, if any, was selected):

add_filter( 'addon_for_activitypub_is_unlisted', function ( $is_unlisted, $post_or_comment ) {
  if ( $post_or_comment instanceof \WP_Post && has_post_format( 'aside', $post_or_comment ) ) {
    return true;
  }

  return $is_unlisted;
}, 10, 2 );

Unlisted Comments

Have (all) comments appear “unlisted.” (Not sure if this is in any way useful, but, “Why not?”)

Edit Notifications

Receive an email when an earlier “Fediverse” comment is modified.

Limit Updates

Don’t send Update activities when nothing’s changed. (Note that “nothing” is rather relative here. E.g., an Update might still get federated even if a post’s ActivityPub representation, which could contain only an excerpt, hasn’t actually changed, but the “real” post content did. Also, this whole thing might conflict with how you’ve set up ActivityPub, so beware.)

Enable “Replies”

While the ActivityPub plugin will “federate” your replies to “Fediverse” comments, it does not (yet) support outright replying to others’ posts.

This setting addresses that, but only for posts marked up as replies. (It will attempt to detect if the “target post” supports the ActivityPub protocol. If so, the target post’s author will receive a notification, and your reply will appear “correctly threaded” on other Fediverse instances, too.)

Enable “Reposts”

Similar to replies; This should translate “reposts” into “boosts” (or “reblogs”) on Mastodon and other Fediverse platforms.

Content Templates

This plugin also adds “post type templates.” There’s no separate setting for them.

Either one or more template files exist—or not.

Template files go in your (child) theme, and may be called, e.g., wp-content/themes/your-child-theme/activitypub/content-{$post->post_type}.php. Here’s one example called content-indieblocks_note.php, for a custom post type with an indieblocks_note slug:

<?php

if ( ! defined( 'ABSPATH' ) ) {
  exit;
}
?>

<?php echo apply_filters( 'the_content', $post->post_content ); ?>
<p><a href="<?php echo esc_url( get_permalink( $post ) ); ?>"><?php echo esc_html( get_permalink( $post ) ); ?></a></p>

The idea here is that you could append custom fields and whatnot.

User Profiles

These are somewhat like the “post type templates” above.

In this case, the plugin would look for a file called wp-content/themes/your-child-theme/activitypub/profile-user-{$user->ID}.php.

Big difference with “content templates” is that this file has to return an array, which can hold up to 4 fields.

Here’s one example called profile-user-3.php, for the user with ID 3:

<?php

// Prevent direct access.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

return array(
	'Blog'        => home_url(),
	'IndieBlocks' => 'https://indieblocks.xyz',
	'Feed Reader' => 'https://feedreader.site',
	'Location'    => '🇧🇪🇳🇱',
);

addon-for-activitypub's People

Contributors

janboddez avatar

Stargazers

 avatar  avatar

Watchers

 avatar

addon-for-activitypub's Issues

Implement "reply posts"

Look for a u-in-reply-to URL. If one is found, and it's a page on our very own site, set an inReplyTo property accordingly.

If it isn't, fetch the remote page in the background. If it supports ActivityPub, set an inReplyTo property accordingly.

In fact, the second approach should cover also pages on our own site, so maybe we should prioritize it.

(Author) profile "templates"?

Not sure how far along the main plugin is in this respect, but maybe we could have a simple associative array for the "profile fields," for instance?

return array(
  'Blog' => 'https://jan.boddez.net',
  'Location' => '🇧🇪🇳🇱',
); 

Boosts don't seem to federate to all followers

Could be me, but while boosts lead to a notification on the server of the person whose toot got boosted, I don't see them appear on another server (where I have an account that follows the blog).

Not super important, but ...

"Don't federate post" filter

There's a filter in the main plugin somewhere, but it doesn't prevent, e.g., Mastodon from GETting the post.

Requires some changes to the ActivityPub plugin, first. Unless it doesn't.

In general, the plugin needs "disabled" in three different places:

  • POST requests need stopped to disable "active" federation
  • "Content negotiation" (for GET requests) needs bypassed so as not to return JSON
  • "Local-only" posts need to be excluded from outboxes and "featured" collections

Implements likes

Like, not accept likes, but federate them, i.e., turn Like posts into ActivityPub Like activities with a (remote) URL as their object.

Oughta be very similar to reposts. Like, transform Create activity into Like ... and exclude from outbox etc. Deletion of a Like post should result in an Undo of the Like activity.

Completely remove IndieBlocks dependency

Anything microformats will be using php-mf directly, rather than depend on IB translating.

Going to be more difficult for the image store/cache. Not sure I want all that code duplicated across multiple plugins.

Unless I could somehow extract it out into an actual PHP library (i.e., a Composer package). But that would also mean getting rid of all the WP functions.

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.