• Stars
    star
    557
  • Rank 79,968 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An RSS to ActivityPub converter.

RSS to ActivityPub Converter

This is a server that lets users convert any RSS feed to an ActivityPub actor that can be followed by users on ActivityPub-compliant social networks like Mastodon.

This is based on my Express ActivityPub Server, a simple Node/Express server that supports a subset of ActivityPub.

As of the v2.0.0 release of this project, only users who are authenticated with a particular OAuth server can create feeds. Any federated user can still read the feeds. I implemented this because running this service in the open invited thousands of spammers to create feeds and overwhelm the service. With this new model, you can run this as an added bonus for people in a community like a Mastodon server, and as the person running it you are taking on only the moderation burden of the users you are already responsible for on your federated server.

Requirements

This requires Node.js v10.10.0 or above.

You also need beanstalkd running. This is a simple and fast queueing system we use to manage polling RSS feeds. Here are installation instructions. On a production server you'll want to install it as a background process.

You'll also need to control some kind of OAuth provider that you can regsiter this application on. This application was designed to work with Mastodon as that OAuth provider (see more on setting that up below), but any OAuth 2.0 provider should work. Many federated software packages besides Mastodon can act as OAuth providers, and if you want something standalone, Keycloak and ORY Hydra are two open source providers you could try.

Installation

Clone the repository, then cd into its root directory. Install dependencies:

npm i

Then copy config.json.template to config.json:

cp config.json.template config.json

Update your new config.json file:

{
  "DOMAIN": "mydomain.com",
  "PORT_HTTP": "3000",
  "PORT_HTTPS": "8443",
  "PRIVKEY_PATH": "/path/to/your/ssl/privkey.pem",
  "CERT_PATH": "/path/to/your/ssl/cert.pem",
  "OAUTH": {
    "client_id": "abc123def456",
    "client_secret": "zyx987wvu654",
    "redirect_uri": "https://rss.example.social/convert",
    "domain": "example.social",
    "domain_human": "Example Online Community",
    "authorize_path": "/oauth/authorize",
    "token_path": "/oauth/token",
    "token_verification_path": "/some/path/to/verify/token"
  }
}
  • DOMAIN: your domain! this should be a discoverable domain of some kind like "example.com" or "rss.example.com"
  • PORT_HTTP: the http port that Express runs on
  • PORT_HTTPS: the https port that Express runs on
  • PRIVKEY_PATH: point this to your private key you got from Certbot or similar
  • CERT_PATH: point this to your cert you got from Certbot or similar
  • OAUTH: this object contains properties related to OAuth login. See the section below on "Running with OAuth" for more details.
    • client_id: also known as the "client key". A long series of characters. You generate this when you register this application with an OAuth provider.
    • client_secret: Another long series of characters that you generate when you register this application with an OAuth provider.
    • redirect_uri: This is the URI that people get redirected to after they authorize the application on the OAuth server. Must point to the server where THIS service is running, and must point to the /convert page. This uri has to match what you put in the application info on the OAuth provider.
    • domain: The domain of the OAuth provider. Not necessarily the same as this server (for example, you could host this at rss.mydomain.com and then handle all OAuth through some other server you control, like a Mastodon server).
    • domain_human: The human-readable name of the OAuth provider. This will appear in various messages, so if you say "Example Online Community" here then the user will see a message like "Click here to log in via Example Online Community".
    • authorize_path: This will generally be /oauth/authorize/ but you can change it here if your OAuth provider uses a nonstandard authorization path.
    • token_path: This will generally be /oauth/token/ but you can change it here if your OAuth provider uses a nonstandard token path.
    • token_verification_path: This should be the path to any URL at the OAuth server that responds with an HTTP status code 200 when you are correctly logged in (and with a non-200 value when you are not). This is the path relative to the domain you set, so if your domain is example.social and you set token_verification_path to /foo/bar/ then the full path that this service will run a GET on to verify you are logged in is https://example.social/foo/bar.

Run the server!

node index.js

Go to https://whateveryourdomainis.com:3000/convert or whatever port you selected for HTTP, and enter an RSS feed and a username. If all goes well it will create a new ActivityPub user with instructions on how to view the user.

Sending out updates to followers

There is also a file called queueFeeds.js that needs to be run on a cron job or similar scheduler. I like to run mine once a minute. It queries every RSS feed in the database to see if there has been a change to the feed. If there is a new post, it sends out the new post to everyone subscribed to its corresponding ActivityPub Actor.

Running with OAuth

OAuth is unfortunately a bit underspecified so there are a lot of funky implementations out there. Here I will include an example of using a Mastodon server as the OAuth provider. This is how I have my RSS service set up: I run friend.camp as my Mastodon server, and I use my admin powers on friend.camp to register rss.friend.camp as an application. The steps for this, for Mastodon, are:

  • log in as an admin user
  • go to Preferences
  • select Development
  • select New Application
  • type in an application name, and the URL where this service is running
  • type in the redirect URI, which will be whatever base domain this service is running at with the /convert path appended. So something like https://rss.example.social/convert
  • uncheck all scopes, and check read:accounts (this is the minimum required access, simply so this RSS converter can confirm someone is truly logged in)
  • once you're done, save
  • you will now have access to a "client key" and "client secret" for this app.
  • open config.js in an editor
  • fill in client_id with the client key, and client_secret with the client secret.
  • set the redirect_uri to be identical to the one you put in Mastodon. It should look like https://rss.example.social/convert (the /convert part is important, this software won't work if you point to a different path)
  • set domain to the domain of your Mastodon server, and domain_human to its human-friendly name
  • leave authorize_path and token_path on their defaults
  • set token_verification_path to /api/v1/accounts/verify_credentials
  • cross your fingers and start up this server

Local testing

You can use a service like ngrok to test things out before you deploy on a real server. All you need to do is install ngrok and run ngrok http 3000 (or whatever port you're using if you changed it). Then go to your config.json and update the DOMAIN field to whatever abcdef.ngrok.io domain that ngrok gives you and restart your server.

Then make sure to manually run updateFeed.js when the feed changes. I recommend having your own test RSS feed that you can update whenever you want.

Database

This server uses a SQLite database stored in the file bot-node.db to keep track of all the data. To connect directly to the database for debugging, from the root directory of the project, run:

sqlite3 bot-node.db

There are two tables in the database: accounts and feeds.

accounts

This table keeps track of all the data needed for the accounts. Columns:

  • name TEXT PRIMARY KEY: the account name, in the form [email protected]
  • privkey TEXT: the RSA private key for the account
  • pubkey TEXT: the RSA public key for the account
  • webfinger TEXT: the entire contents of the webfinger JSON served for this account
  • actor TEXT: the entire contents of the actor JSON served for this account
  • apikey TEXT: the API key associated with this account
  • followers TEXT: a JSON-formatted array of the URL for the Actor JSON of all followers, in the form ["https://remote.server/users/somePerson", "https://another.remote.server/ourUsers/anotherPerson"]
  • messages TEXT: not yet used but will eventually store all messages so we can render them on a "profile" page

feeds

This table keeps track of all the data needed for the feeds. Columns:

  • feed TEXT PRIMARY KEY: the URI of the RSS feed
  • username TEXT: the username associated with the RSS feed
  • content TEXT: the most recent copy fetched of the RSS feed's contents

License

Copyright (c) 2018 Darius Kazemi. Licensed under the MIT license.

More Repositories

1

corpora

A collection of small corpuses of interesting data for the creation of bots and similar stuff.
JavaScript
4,914
star
2

express-activitypub

A very simple reference implementation of an ActivityPub server using Express.js
JavaScript
588
star
3

NaNoGenMo-2015

National Novel Generation Month, 2015 edition.
340
star
4

twitter-archiver

Make your own simple, public, searchable Twitter archive
JavaScript
299
star
5

NaNoGenMo-2014

National Novel Generation Month, 2014 edition.
257
star
6

examplebot

A simple example Twitter bot using NodeJS.
JavaScript
225
star
7

wordfilter

A small module meant for use in text generators that lets you filter strings for bad words.
Python
220
star
8

metaphor-a-minute

Metaphor a Minute! You too can write an annoying philosophy twitter bot.
JavaScript
210
star
9

NaNoGenMo

National Novel Generation Month. Because.
183
star
10

ja2

The source code for Jagged Alliance 2. I didn't write this; see the Strategy First license agreement for details. Supplementary material for the Jagged Alliance 2 Boss Fight Book.
C
114
star
11

rapbot

JavaScript
64
star
12

grunt-init-twitter-bot

A grunt init template for making Twitter bots, preloaded with some useful libs.
JavaScript
60
star
13

ea-thesaurus

The Edinburgh Associative Thesaurus (EAT) is a set of word association norms showing the counts of word association as collected from subjects.
45
star
14

sorting-bot

The Sorting Hat Bot (@SortingBot on Twitter)
JavaScript
40
star
15

twoheadlines

@twoheadlines
CSS
38
star
16

latourswag

Bruno Latour + #swag = Twitter bot!
JavaScript
33
star
17

gender-probability

Providing gender probabilities for US/UK names using Open Gender Tracker's [Global Name Data](https://github.com/OpenGenderTracking/globalnamedata) resource.
JavaScript
27
star
18

TheEthicalAdBlocker

This browser extension provides a 100% guaranteed ethical ad blocking experience.
JavaScript
25
star
19

gaunt

Simple, versatile, achingly beautiful.
JavaScript
24
star
20

spewer

A reverse part-of-speech tagger. Give it a list of tags and it spews out matching language.
JavaScript
23
star
21

gutencorpus

This is a simple tool that lets you search the top 100-ish Project Gutenberg ebooks for text.
JavaScript
21
star
22

projects

A listing of my projects.
JavaScript
20
star
23

reverseocr

A bot that attempts to draw words.
JavaScript
19
star
24

wordnik-bb

A node.js interface to the Wordnik API, which lets you get dictionary definitions, random words, pronunciation, and more!
JavaScript
18
star
25

bracket-meme-bot

A bot that make "bracket memes".
JavaScript
16
star
26

farewell

Employee farewell letter generator.
JavaScript
16
star
27

museumbot

Tweeting the Met.
JavaScript
16
star
28

roof-slapping-bot

*slaps roof of source code* this bad boy can fit so many bugs in it
JavaScript
12
star
29

painterly-textures

JavaScript
11
star
30

harpooneers

Code for "HARPOONEERS AND SAILORS", a novel I generated for NaNoGenMo 2015.
JavaScript
10
star
31

mastodon-autoreply

A bot that replies to new followers, ideally saying "I've moved! Follow me (here)."
JavaScript
10
star
32

grunt-init-textgen

A grunt-init template for text generating pages with twitter/link sharing.
JavaScript
10
star
33

outslide

A random slide generator. I'm sorry.
JavaScript
10
star
34

teamsnake-simple

Early network build of Team Snake.
JavaScript
8
star
35

tweetYourArchive

Set up a bot to tweet your twitter archive, on a delay.
JavaScript
8
star
36

cyberfiction

It was the best of cybertimes, it was the worst of cybertimes.
JavaScript
7
star
37

hottestStartups

Really hot startup ideas.
JavaScript
7
star
38

very-simple-whiteboard

Very simple whiteboard, tuned for a Chrome Pixel.
JavaScript
6
star
39

corpora-project

This is the NPM package to access the latest corpora data.
JavaScript
5
star
40

wordnik-hackathon

The Wordnik / Bot Summit Hackathon
5
star
41

overzealous-autocomplete

Overzealous autocomplete.
JavaScript
5
star
42

chum-corpus

Occasionally updated chumbox images and headlines.
4
star
43

youMustBe

Software, you must be a generator because you are a thing that generates output.
JavaScript
4
star
44

amen-chopper

This is a little toy that takes the Amen Break and chops it up into slices of different lengths and offsets, playing the slices in random order at a certain bpm and running the whole thing through a filter. You can get very different beats just by adjusting these few settings.
JavaScript
3
star
45

intersections

Venn Diagrams.
JavaScript
3
star
46

dialogue

Generative dialogue.
JavaScript
3
star
47

allthethings

Verb ALL the nouns!
JavaScript
3
star
48

slowtext

s l o w w w w t e x t
JavaScript
2
star
49

4myrealfriends

Source code for my real friends, real code for my source friends.
JavaScript
2
star
50

wolf3d

wolf3d hacks
JavaScript
2
star
51

lastwords

Last words of executed Texas death row inmates that contain "love".
JavaScript
2
star
52

pennyarcade

JavaScript
2
star
53

integers

29 Positive Integers Under 30
1
star
54

documentationPlayground

CSS
1
star
55

netboard-server

JavaScript
1
star
56

dariusbots

An account that RTs tweets from my twitter list that reach a certain number of favs+RTs.
JavaScript
1
star
57

netboard

JavaScript
1
star
58

fmk

Fuck, marry, or kill? A Twitter bot.
JavaScript
1
star
59

lmmtfy

Let Me Moogle That For You
JavaScript
1
star
60

TwineOnline

Web-based port of Twine
JavaScript
1
star
61

doctorwhat

Doctor Who speculation generator.
JavaScript
1
star
62

jqProclamations

everything is the jQuery of everything
JavaScript
1
star
63

ao3

God help me.
JavaScript
1
star
64

gengen

HTML
1
star
65

gqTest

gameQuery test project
1
star
66

generateShare

A template I can use for generators that has twitter sharing built in
JavaScript
1
star
67

ColorSprite

Grab colors from an image using Color Thief, create a sprite. Proof of concept.
JavaScript
1
star
68

spinny-machine

A spinny machine.
JavaScript
1
star
69

fuckvideogames

Fuck videogames.
JavaScript
1
star