scripting / Mastodon-API

I'm working on connecting to the Mastodon-API, getting help from friends who have been down this path.
MIT License
13 stars 0 forks source link

What does ActivityPub do, no bullshit please. #1

Open scripting opened 1 year ago

scripting commented 1 year ago

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. :smile:

Endpoints

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

1. 2. 3.

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

emk commented 1 year ago

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:

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

Other odd or curious bits

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 commented 1 year ago

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 commented 1 year ago

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

scripting commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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:

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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

scripting commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@Timothyjchambers -- exactly. ;-)

scripting commented 1 year ago

@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.

scripting commented 1 year ago

@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 commented 1 year ago

Sorry to hear it.

Do you know anyone who's running a server?

scripting commented 1 year ago

@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.

scripting commented 1 year ago

No spam. Stay on topic. Thanks.

scotthansonde commented 1 year ago

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

scripting commented 1 year ago

Thank you @scotthansonde! You’re incredible.

Could you invite @emk too?

scotthansonde commented 1 year ago

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

scripting commented 1 year ago

https://github.com/scripting/reallySimpleActivityPub/tree/main/scriptingglue

BTW, no pull requests. If you have code to add, send it to me and I will add it.

And please try to stick to coding conventions. I will have to reformat otherwise.

I think we have a very workable way to do this.

Eric, Scott and I have been working toward this kind of collaboration, he's been working on the Chromebook version of Electric Drummer, which I think you would like, time-willing of course.

Scott, Eric is a longtime Scripting News hanger-on. He shows up every once in a while when we're doing something that interests him and often makes a big contribution. His biggest has been the C++ implementation of XML-RPC which was very widely used, and really helped push forward the standard.

The goal here is to build a glue scripts table for Drummer parallel to the one for Twitter, except for Mastodon. Where ever possible I want to use the same verb names and interface.

Dave

PS: I'm going to put this (edited) in a new thread on the repo.

On Tue, Nov 15, 2022 at 9:07 AM Scott Hanson @.***> wrote:

@scripting https://github.com/scripting I'll prepare an invite for @emk https://github.com/emk as well

— Reply to this email directly, view it on GitHub https://github.com/scripting/reallySimpleActivityPub/issues/1#issuecomment-1315358690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAM32O6AGGGRAREXUI345VTWIOKJJANCNFSM6AAAAAARYPR2K4 . You are receiving this because you were mentioned.Message ID: @.***>