Join diaspora and slowly posting a wordpress RSS/atom feed

Diaspora is a social network that appears to similar to Facebook in its behaviour: you get a web UI with a feed, and what ends up in that feed comes from your friends and your groups and what hashtags you filter for.

Diaspora differs from Facebook in that it is not under corporate control. Diaspora, according to its wikipedia entry, is a non-profit, user-owned, distributed social network. Diaspora’s software is free software (GNU AGPL-3.0) and written i ruby on rails.

To start using Diaspora, one first have to decide on which “pod” (i.e. Diaspora instance), to join. In principle you can see everything posted by any user in the Diaspora fediverse, but there may be limitations in what the pod owner allows. I didn’t do much searching, I found a pod with a .no address and registered there. The first thing I was asked to do was to create a “Here I am” posting with a lot of hashtags referring to my interests.

I did that, and received several welcome replies. So that was kind of friendly.

If you want to see the postings described in this article, add steinarb@diasporapod.no to your contacts.

I then started the process of posting the RSS feed of this blog to diaspora.

Ideally I would have liked to post the feed entries in chronological order, with the original posted date they were posted.

However, the REST API of diaspora doesn’t allow setting the date of a post. The date you post is the date you get. So posting with the original date was out.

Next best would be to post the wordpress feed entries in blog post chronological order at a slowed rate, perhaps 1 post a day, so I wouldn’t bee seen to flood the diaspora feeds. So this is what I set out to do.

The first thing I had to do was to adjust the RSS feeds on wordpress, to get everything to the start of the feed. WordPress was set up to only show the 10 most recent blog posts in the feed. The feed was also set up to contain the entire bodies of the blog posts, and that was a little too much for this use case. So I adjusted the feeds to list only the blog post summaries.

I googled for a tool to do the posting, found this list on the diaspora wiki. The python script pod_feeder_v2 was at the start of the list, so that’s the one I tried first and that’s the one I stayed with.

Installing the pod_feeder_v2 was done by doing the following commands, logged in as root, on a debian system:

  1. First installed python3 pip

    Listing 1.

    apt install python3-pip
    
  2. Then installed pod_feeder_v2

    Listing 1.

    pip3 install pod-feeder-v2
    

The way pod_feeder_v2 works is that it first reads all posts from the RSS feed it listens to, and then stores all entries it hasn’t seen before into a sqlite table (identified by the feed entry GUID). It then traverses the sqlite table in chronological order and posts the unposted entries, marking entries in the table as they are posted, so they won’t be posted more than once.

The time stamp in the sqlite table entries, is the time the entries are written in the table. Since the wordpress feeds post the newest entries first, pod_feeder_v2 on initial read puts the entries in the wrong order, with (more or less) the same time stamp.

So what I tried to do, was to first fill up the database with the existing posts, and then semi-manually correct the time stamp of each post in the database (34 posts, stretching back to 2012) and then start posting from the table 1 post per day.

Luckily pod_feeder_v2 has a command line option –fetch-only, that allows reading the feed and updating the sqlite table, but not posting. So I ran this command to populate the table in the feed.db (I ran this command logged in with my regular user account, not as root):

Listing 1.

pod-feeder --feed-id steinarblog --category-tags --ignore-tag uncategorized --feed-url https://steinar.bang.priv.no/feed/atom/ --pod-url https://diasporapod.no --fetch-only

This adds both the wordpress category and the wordcloud tags as hashtags in the post. I removed the tag uncategorized from the hashtags.

To manipulate the database table I installed the sqlite command line tool, by doing the following command, logged in as root:

Listing 1.

apt install sqlite3

I started the sqlite3 command line tool logged in as my own user account (“feed.db” is the file holding the sqlite database. It is created in the home directory of the user running pd-feeder):

Listing 1.

sqlite3 feed.db

I listed the available GUIDs:

Listing 1.

SELECT guid FROM feeds WHERE feed_id == 'steinarblog';

I took the GUIDs into an emacs SQL buffer, and manipulated them to become update lines, setting the time stamp to be at the time of the update. Then I reversed the lines in the buffer, so that the oldest was first:

Listing 1.

update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=1';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=7';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=14';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=23';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=26';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=33';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=44';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=46';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=53';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=63';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=60';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=66';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=83';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=165';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=171';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=191';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=196';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=209';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=214';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=223';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=224';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=238';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=250';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=255';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=261';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=269';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=265';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=286';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=292';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=306';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=332';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=342';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=353';
update feeds set timestamp = CURRENT_TIMESTAMP where guid = 'https://steinar.bang.priv.no/?p=310';

I manually pasted each line into sqlite3, one line at a time, waiting a couple of seconds between each paste. It was only 34 lines to paste so this seemed the simplest way. I watched television as I was doing this.

The next bit to do was to post the articles in the database, one post per day.

I set up a cronjob to run once a day, posting from the database, and using “–limit 1” to ensure only one post was done each day:

Listing 1.

0 6 * * * /usr/local/bin/pod-feeder --feed-id --summary steinarblog --category-tags --ignore-tag uncategorized --feed-url https://steinar.bang.priv.no/feed/atom/ --limit 1 --pod-url https://diasporapod.no --username steinarb --password xxxxx --quiet

The pod-feeder will only attempt to post entries for 72 hours, so to avoid the unposted entries being forgotten, I added another cronjob bumping the timestamp of unposted articles with 24 hours:

Listing 1.

5 6 * * * /usr/bin/sqlite3 feed.db 'update feeds set timestamp = DATETIME(timestamp, "+1 day") where posted = 0;'

With this setup one article per day will be posted until the feed is empty. At that point I will change the pod-feeder cronjob to run more often than once a day and remove the job bumping the timestamps of unposted entries.

One thought on “Join diaspora and slowly posting a wordpress RSS/atom feed”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.