Skip to content
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

What does ActivityPub do, no bullshit please. #1

Open
scripting opened this issue Nov 6, 2022 · 26 comments
Open

What does ActivityPub do, no bullshit please. #1

scripting opened this issue Nov 6, 2022 · 26 comments

Comments

@scripting
Copy link
Owner

scripting commented Nov 6, 2022

The scenario

I have a server that receives twitter-like posts, and twitter-like posts emanate from it.

I have users who use my server, so there must be some way to do identity.

So it's --

  1. incoming posts
  2. outgoing posts
  3. users

What else is there? Correct answer is nothing. Or prove me wrong. 😄

Endpoints

I need a list of endpoints an ActivityPub server needs to support.

PS: Right now, to begin with I don't care about interop'ing with anyone. Let's get the basics right first.

@emk
Copy link

emk commented Nov 13, 2022

I have been digging into Mastodon this week, but not deeply enough to have figured out the endpoints yet. From what little I've seen of the tech stack, it seems like:

  • You can get a lot of public information via HTTP, JSON and RSS
  • But actually subscribing or sending messages looks complicated enough that I'd probably just use a pre-existing client library. I've heard people mention Megalodon (JS), but I haven't tried it.
  • I haven't read the spec yet, but I've head people say the intro is helpful.

Mostly I've just been trying to get a non-technical feel for things. Here are some interesting things I've run into.

Things Mastodon does right

  • Allowing people to host their own sites and run their own software is fantastic.
  • ActivityPub isn't just limited to microblogging. Some Mastodon instances allow users to use more than 500 characters. Regular Mastodon clients just hide the extra text behind "Read more".
    • There are ActivityPub sites that do photo-sharing, not microblogging.
  • There are a lot of tools for blocking and ignoring people.
  • You can tell your client things like "Don't show me posts containing the word ABC" or "Show me posts mentioning XYZ, but hide the text until I click on them."
  • Mastodon exports RSS. Just add ".rss" to anyone's profile URL.

Other odd or curious bits

  • The Mastodon software deliberately doesn't support quote tweeting (basically so people stop quote-Tweeting famous jerks to complain about them, etc). Either you publish your own thoughts, or you republish someone else's thoughts verbatim. Or you can write about something, and you include a regular link.
  • Search is limited to hashtags, in an effort discourage drive-by harassers. If you don't use a hashtag, you're harder to find.
    • To discover stuff, use hashtags. As of Monday's release, you'll be able to follow a hashtag.
    • To get discovered, use hashtags.
  • Mastodon posts come in two main forms: Simple text and Title plus folded body. The latter is useful for long digressions that might not interest all readers.

The vibe

Overall, I'm enjoying the experience. There are bunch of people posting on #BikeTooter, for example. The vibe is pretty chill and positive right now.

Possibilities

Based on my very limited understanding, it should be possible to implement an RSS-to-ActivityPub gateway. And people should be able to subscribe normally from Mastodon. And you have some flexibility about what you send—more than 500 characters, or even something more like PixelFed.

Anyway, I wish I had more technical details, but this is what I've had time to figure out so far.

@scripting
Copy link
Owner Author

Based on my very limited understanding, it should be possible to implement an RSS-to-ActivityPub gateway.

That's what I want. And I already have the RSS parser part of it, we just need a way to send the data in an RSS "packet" over an ActivityPub channel.

If you want to see what that looks like, here's the package I use to parse my feeds.

And here's a place you can parse a feed to see what you get back. Sorry it doesn't have a better UI. ;-)

http://feeder.scripting.com/returnjson?feedurl=https%3A%2F%2Frss.nytimes.com%2Fservices%2Fxml%2Frss%2Fnyt%2FTheater.xml

@jludington
Copy link

I think this project might handle RSS-to-ActivityPub posting. https://github.com/dariusk/rss-to-activitypub

@scripting
Copy link
Owner Author

scripting commented Nov 13, 2022

@jludington -- there's so much there -- i have no idea where to begin.

i need something that fits into my world.

i also am overloaded with a huge project, FeedLand, so I need something practically designed to plug into my world, which is this -- I generate and consume feeds in RSS.

Those have to make sense in the Mastodon environment.

I get that this project has something to do with that.

@scripting
Copy link
Owner Author

To be clear -- here's a feed.

http://data.feedland.org/feeds/davewiner.xml

When I post something to that feed, I want it to appear in a subscribable object in MastodonLand.

We support rssCloud, the native notification service of RSS 2.0.

So the items should appear in MastodonLand almost instantaneously.

@emk
Copy link

emk commented Nov 13, 2022

I can see at least two paths forward:

1. Easy: Use Megalodon to push content to an existing Mastodon server

This is probably the easiest approach, because you don't have to implement ActivityPub, handle subscriptions, or send messages to subscribers.

It looks pretty easy:

import generator, { Entity, Response } from 'megalodon'

const BASE_URL: string = 'https://mastodon.social'
const access_token: string = '...'
const toot: string = 'test toot'

const client = generator('mastodon', BASE_URL, access_token)
client.postStatus(toot)
  .then((res: Response<Entity.Status>) => {
    console.log(res.data)
  })

Of course, this assumes you have an account or a server somewhere. If you want to run your own, Masto.host had a nice $6 plan, but they're overwhelmed this week and there's a wait list. Or you could install Mastodon on a Linux server somewhere. One of my friends is doing that and he said it wasn't completely awful.

2. Harder: Implement ActivityPub

This requires a bunch of moving parts, and I'm still really vague on it all:

  • Implementing identity.
  • Doing some digital signature stuff, I think?
  • Handling subscriptions.
  • Forwarding messages to instances with subscribers. This is a key difference—ActivityPub pushes outbound data, instead of relying on scrapers or a notification service.
  • Maybe making a nice HTML profile page like Mastodon provides for the accounts on a server?

But I may be very wrong about these things, because I haven't read the spec yet.

I feel like (2) is simply too large at this point, until somebody writes a nice server library that implements all the hard bits.

@scripting
Copy link
Owner Author

@emk -- i was thinking of option #1, good to know you're thinking that way too.

can you help me set up a mastodon instance on digitalocean? i think the hard part is setting up the mail server connection. these days you have to jump through so many hoops.

@emk
Copy link

emk commented Nov 14, 2022

Sure, I can find an hour or two next week! Would screen sharing work for you?

This looks like the official Mastodon image for Digital Ocean. They say we'll need:

  • Domain name (the DNS records should already point to the droplet)
  • SMTP credentials for sending e-mails (this can be SparkPost, Sendgrid, Mailgun, etc)
  • Optional: Amazon S3 credentials for storing user-uploaded files (this can also be Wasabi or Minio)

For SMTP, do you already have a working email server? If so, we should just be able to use an account on that.

If you don't currently have your own email server, I've had good luck with Sendgrid (long ago). They have a free plan with 100 emails/day, which should be enough to run Mastodon. The advantage of using Sendgrid is that they'll jump through all the hoops needed to deliver email to GMail. I think you just need the email for things like sign-up confirmation and password reset?

Then we can log in, create a "bot" account, and grab the API token. After that, I think it's dead simple.

I'm actually pretty excited about having a microblogging API again. The world lost a lot of cool innovation when Twitter shut down most of their API.

@scripting
Copy link
Owner Author

@emk -- i use Amazon SES, but I don't want to use it for this purpose because if i get reports for spam (I don't control the software here so that could happen I imagine) it would create problems for the other applications i use it for.

Let's do this in a private thread.

@Newman5
Copy link

Newman5 commented Nov 14, 2022

"Mastodon exports RSS. Just add ".rss" to anyone's profile URL." That's what stands out for me. Thanks @emk . Thanks Dave!

@scripting
Copy link
Owner Author

@emk — twitter has an excellent api. I use it for lots of stuff. We’ve got a fairly complete scripting api for Twitter in drummer. I do all my communication with their api through a package called davetwitter, mit license. It would be a good interface for a mastodon api. Flatten out the diffs.

Here’s the recent blog post I wrote about this…

http://scripting.com/2022/11/10.html#a181757

and the docs for the twitter verbs in drummer, all done thru their api.

https://github.com/scripting/docServer/blob/main/docs/pages/twitter.md

@scotthansonde
Copy link

@scripting I set up a test Mastodon instance on Digital Ocean this week, and set up a new account at SendGrid to handle the mail. It was not a straightforward as I would have hoped, but I documented my steps and maybe it will save someone some time. 😃

After setting up the account, SendGrid wants you to set up a "Sender Identity". They have two choices... Domain Authentication or Single Sender Verification. For Single Sender Verification they wanted my physical address, so I backed out of that. For domain authentication they wanted me to add 3 CNAME entries to my DNS, which I did and the domain was authenticated.

After that is was easier. In the Setup Guide I went to "Send your first email", "Web API or SMTP Relay", picked "SMTP Relay", where I created an API Key and it showed the details for SMTP.

I then installed the Mastodon droplet on Digital Ocean and went through the install prompts on the first SSH connection. I first made the mistake of setting my Gmail address as the FROM address... SendGrid rejected it. The FROM address has to be on the authenticated domain (for me xxx@papascott.de).

@scripting
Copy link
Owner Author

scripting commented Nov 14, 2022

Thinking out loud..

Right now micro.blog is the only blogging site that supports inbound RSS that I know of. Which makes it an incredibly interesting place for FeedLand to peer with, because we are the hotspot for feeds. We bring them in and ship em out. And in the process you can categorize stuff, push it out with the click of the Like button and we also do categories very nicely and in a functional way that you end up actually using (this is something I've been trying to accomplish my whole freaking career).

I think this is the future. I call it Two-way RSS. The first way is the one we all know about, outbound. But inbound? well as far as the state of the art in 2022 is concerned, every inbound RSS app today is a feedreader. Except micro.blog. I think there will be an explosion of inbound RSS apps. I want WordPress to do it. Substack. And Mastodon. There should be a new address for a user. Here's an idea -- let DNS do it.

More thinking to do...

@thejeshgn
Copy link

There is no native support for it in WordPress (Self hosted version). But I have been using a plugin to pull the RSS feed and make it into a post. Its called WPeMatico (GitHub, WP Plugins). It works well.

In fact recently I added My Feedland Likes feed to be cross posted to my blog.

Its not native but works. I hope it becomes native.

@scripting
Copy link
Owner Author

@thejeshgn -- that's beautiful. your linkblog requires exactly one gesture, clicking the like icon. It can't get any simpler than that.

I've been emailing on and off with Matt this year, and I've asked him to do this.

@Timothyjchambers
Copy link

So what specifically would support for "two-way RSS" look like in Mastodon? Woudl be be akin to the rss-Mastodon bots that now exist but built into the platform itself?

For example of that: https://indieweb.social/web/@boingbot@mastodon.cloud

@scripting
Copy link
Owner Author

@Timothyjchambers -- exactly. ;-)

@scripting
Copy link
Owner Author

scripting commented Nov 14, 2022

@scotthansonde -- i got pretty far, up to the point where I could create a user account and it sent an email to verify, but when I clicked the link it was directed to http://url9896.scripting.com/, which I recognized as one of the domains used when I set up the sendgrid account.

I deleted the cnames after registering, figuring that they were just used to identify me, but apparently they serve some other purpose after setup?

I tried changing the url9896 to "masto" which is the address of the server but that didn't work either.

Repository owner deleted a comment from Agorise Nov 14, 2022
@scripting
Copy link
Owner Author

@scotthansonde @emk -- I tried starting over from scratch and hit a different problem this time.

This isn't a good job for me. I'll use someone else's Mastodon server.

@emk
Copy link

emk commented Nov 14, 2022

Sorry to hear it.

Do you know anyone who's running a server?

Repository owner deleted a comment from Agorise Nov 14, 2022
@scripting
Copy link
Owner Author

@emk -- yes @scotthansonde has gotten it working. He's much better at this kind of stuff than I am.

I will offer to pay for a server if one of you guys want to set it up and will do the DNS setup.

Repository owner deleted a comment from Agorise Nov 15, 2022
@scripting
Copy link
Owner Author

No spam. Stay on topic. Thanks.

@scotthansonde
Copy link

@scripting I'll be happy to invite you to my test Mastodon instance if you'd like to test the API.

@scripting
Copy link
Owner Author

Thank you @scotthansonde! You’re incredible.

Could you invite @emk too?

@scotthansonde
Copy link

@scripting I'll prepare an invite for @emk as well

@scripting
Copy link
Owner Author

scripting commented Nov 15, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants