Installing SemApps to bridge the SocialHub to the Fediverse

SemApps has a Discourse importer which allow to “semantize” discussion topics every night (using the Discourse API). The importer can also post ActivityPub Create activities when new topics are created. So it would be possible to create a small tool to do what you want. If anyone is interested in giving this a try, I would be happy to help them (the SemApps project is still lacking documentation to work alone…)

6 Likes

Oh, that is cool. So a kind of bridge that could stream forum activity, expose as an actor and show it on the timeline. I created a toot to see if there’s interest:

Also ping to @discourse team :slight_smile:

1 Like

Thanks @aschrijver !
Indeed it would be possible to a Discourse->ActivityPub bridge with SemApps. :slight_smile: I’ve been working on a ActivityPub->Mattermost bridge (so on the other direction) before summer. I should finish it by september. For information, until now it took me only 4 days to develop it.

2 Likes

That is interesting! (OT: AP → Mattermost goes in direction of forge federation or rather the broader scope that relates to it: FSDL)

1 Like

@srosset81 It would be awesome to be able to publish and interact with topics here and on the Fediverse. What would it take to setup a SemApps instance that would do this for the SocialHub?

1 Like

@how It would require a basic SemApps instance with a Fuseki triple store and a service which would look like this:

const urlJoin = require("url-join");
const { DiscourseImporterMixin } = require('@semapps/importer');
const QueueMixin = require("moleculer-bull");
const CONFIG = require('../config');

module.exports = {
  name: 'importer.discourse',
  mixins: [DiscourseImporterMixin, QueueMixin(CONFIG.QUEUE_SERVICE_URL)],
  settings: {
    source: {
      discourse: {
        baseUrl: 'https://socialhub.activitypub.rocks/',
        type: 'topics'
      },
    },
    dest: {
      containerUri: urlJoin(CONFIG.HOME_URL, 'topics')
    },
    activitypub: {
      actorUri: urlJoin(CONFIG.HOME_URL, 'bots', 'discourse-reposter'),
      activities: ['Create']
    },
    cronJob: {
      time: '0 0 4 * * *', // Every night at 4am
      timeZone: 'Europe/Paris'
    }
  },
  methods: {
    async transform(topic) {
     // We can use topic.category_id if we want to filter topics according to categories
      return({
        '@type': 'Note',
        'content': topic.title + ' ' + urlJoin(this.settings.source.discourse.baseUrl, 't', `${topic.id}`)
      })
    }
  }
};

It would generate AS activities like these:

{
  "type": "Create",
  "actor": "http://localhost:3000/bots/discourse-reposter",
  "object": "http://localhost:3000/notes/23r2rnwef434"
}

If we need to have the Note payload instead of its URI (note sure Mastodon parse URI ?), it would require some improvements in the importer service.

Note that the Discourse importer currently only synchronize topics. If we also wanted to synchronize posts, it would require some improvements also (but it’s totally possible).

3 Likes

I would certainly support making this happen, even in a non-optimal state. If a bunch of people are interested in setting this up we could organize a tmux session on the server.

@srosset81 I’m looking at SemApps installation. It recommends NodeJS version 12, which seems to be obsolete. Should I try version 16 instead? I’m planning on installing the next branch which would, I expect, provide what we need here.

I moved the discussion here to avoid spamming the Discourse team. And also because it’s not Discourse, but SemApps here, that provides a way out (to the Fediverse).

1 Like

Yes please use the next branch ! :slight_smile:
Some people have had issues with more recent of NodeJS, and we didn’t have time to investigate, that’s why we stuck with this old version. But feel free to give it a try.

Is Hello from SemApps | SemApps using the next branch? I suppose not.

Heading to git cloning…

The documentation for the next branch is located at https://dev.semapps.org
But these guides may not be up-to-date. We are in the process of updating the whole website.
A good way to start with SemApps is to give a try to Archipelago:

(You can run only the middleware without the frontend)

1 Like

My current experiments are failing. I’m not familiar with NodeJS. Some tmux session would be appreciated when you have the time.

@srosset81, @how have yall made any progress on this?

2 Likes

Considering there is now a Discourse ActivityPub plugin, I don’t think this is still useful.

1 Like