GoToSocial Hack

I’ve heavily modified the code where the posts are first created (before being saved to the database and converted into ActivityPub API objects and shoved in the outbox).

My website, from a user POV has (currently) 3 sections: Blog, Notes (microblog), Bookmarks (linkblog).

Obviously, the way i prefer to create blog posts and microblog posts is completely different. For the blog, I want to write on a computer, in a nice editor. For the microblog I would mostly want to type them out quickly on my phone, in an app designed for such things. For linkblog entries… well, from anywhere I bookmark anything.

Federating blog articles

I’m maintaining the articles of my blog in the standard way: Write markdown posts in content/blog, push to GitHub, triggering a build and publish.

This doesn’t create an ActivityPub object in GoToSocial (I could possibly do something with the build pipeline to create one, but it gets difficult when dealing with draft posts. I’ll likely revisit this later).

For lack of another solution, and since the cadence of blog posts is very low and I want to write them in any editor I feel like using at the time, I am allowing a manual step in the system here. I post to GoToSocial the Url of the published blog article (and nothing but the Url), My hack of GoToSocial detects if a new post contains nothing but a URL pointing to my blog and does the following:

  • Changes the post content to include a summary / description as well as the link to the article (It gets this summary by visiting the Url and fetching it from there).
  • Sets the URL property of the ActivityPub object to be the blog article Url instead of the GoToSocial post e.g. changes from https://mywebsite.url/@user/ActivityPubId to https://mywebsite.url/blog/title/

This last bit is key, and fundamental to the whole idea that is described more here. It means the the real post, the single source of truth, is actually the page on my blog, the ActivityPub status is just a wrapper / a card / a pointer to the actual post. If someone sees the summary post in their mastodon timeline and they click the timestamp, it’s the blog post on my website that will appear, not a GoToSocial view of the post.

Federating microblog posts

The microblog is managed differently due to the higher cadence of posts and how I’d like to write them (i.e. in a microblogging app, such as Tusky).

To allow for this, I have modified GoToSocial so that whenever any new post is attempted (and it isn’t detect as a blog post as described above) it will post the status as normal with 3 modifications.

  1. It creates a markdown version of the post and pushes it into the note folder of my GitHub repo, which triggers the build and deployment of the site.
  2. As with the Blog system above, It changes the URL property of ActivityPub object to be that of the new note on the website (at this point the website won’t have had time to deploy, so the Url won’t exist, but we know what the Url will be when it does).
  3. Any attachments are copied from GoToSocial asset storage to the websites asset storage. This is instead of sending to GitHub with the markdown file just to save time and bandwidth.

Note that, unlike when posting a blog article, the content of the ActivityPub object is unaltered. Only the Url property is changed.

GoToSocial post creation flow

This is a flowchart that shows the new logic when GoToSocial creates a new post.

flowchart TD
	A["Post to GoToSocial
	e.g. with Tusky"] --> B{Is a blog Url?}
    B -->|"Yes, 
    create post that links to existing blog"| C["Set post Url 
    to the blog page Url"]
    C --> D[Fetch article description from Url]
    D --> E["Add article description 
    to the post content"]
    E ---> F[Post saved]
    B -->|"No, 
    create new note using post content"| G["Set post url to what we know
     the microblog page will be"]
    G --> H[Create markdown version of post]
    H --> I[Push markdown to GitHub]
    I --> J[Build Hugo site]
    J --> K[Deploy to website]
    I --> L["Copy any attachments 
    to website"]
    L --> F
    
  

Linkblog curation

The linkblog is not something I care to federate. However, I do want to be able to add to the linkblog from as many different sources as possible (e.g. staring an article in an RSS reader or ReadItLater app, clicking a bookmarklet in a web browser, a sharing intent in a mobile browser, etc, etc, etc).

To that end, when I bookmark a post in GoToSocial, I’d like to add that post as an entry to the linkblog (and if the bookmark is removed, remove the linkblog entry).