Comments and suggestions on the Peertube ActivityPub implementation

I work for a company that have been hired by the French Ministry of Education to implement ActivityPub in Pod. Pod is a tool used by teachers to edit and upload videos. The goal between the AP implementation is to federate Pod instances with other Pod instances, and also with Peertube instances.

The implementation is still a messy draft, but I succeed to make a Peertube instance federate with a Pod instance. Pod videos can be read from a Peertube instance. That was not straightforward, mainly because I had to retro-engineer how Peertube implements AP so I could make Pod produce the data that would be compatible with Peertube.

I thought the experience is worth sharing, so the life would be easier for the next people who want to federate another service with Peertube. My suggestion is to ideally fix or otherwise document some behaviors of Peertube. I am well aware that some suggestions might not be trivial for retrocompatibility or complexity reasons, but let us open the discussion nonetheless.

This mainly concerns the AP Video object I created, if you find my feedback useful, I can also document the other AP objects. However I think the complexity mostly lies with Video.

If this is OK with you, I can open github tickets for those items.

tags

The tags attribute needs to exist, even if it is an empty array.

I suggest to also accept missing tags attribute.

attributedTo

A Group object, i.e. a channel, is needed to be associated to any video.
Pod channels are optional. I can work around this by building dynamic channels for all users, so there would be at least one channel to associate to any video.

I would make my life easier if channels were optional for Peertube videos.

url

A matching magnet URL is needed for every mp4 video URL. Peertube checks for the presence of a hash in the magnet URL. As Pod does not provide Magnet URL at all, I needed to build a fake URL for every mp4 to make everything work.

I suggest to accept videos without magnet links

sensitive

sensitive in mandatory for peertube, but there is no such attribute in Pod videos. I could work around this by always setting sensitive to false.

I suggest making this optional.

licence

Peertube expect licence identifiers to be integers that refer to its own mapping.
Pod use licence SPDX licence identifiers without the version number.
I could work around this by implementing a mapping between peertube licences and SPDX identifiers.

I think it would be more standard if licence identifiers were SPDX identifiers instead of integers. What do you think?

description

The only supported mimetype by Peertube for video descriptions is markdown.
Pod descriptions are HTML. I could work around this by using libraries that converts HTML in markdown.

I suggest to let Peertube accept text/html mimetypes in addition to markdown.

thumbnail

The only supported mimetype is image/jpeg. Pod also handle png thumbnails.

I suggest to accept other image formats.

likes, dislikes, shares, comments

All those parameters are needed AP Video objects, however they don’t look to me like a hard requirement to watch a video.
I suggest making those attributes optional, and in a more general way, any attribute that could be made optional.

debugging

I hard a hard time understanding what was going wrong with the data I provided to Peertube. For instance, this was not straightforward to understand that the expected UUID must be version 4 UUIDs:

I suggest to log a debug message when any of this condition is false, like it is done earlier on that function for some attributes, so when the whole block value is false, there is a little more details on which part is the cause.

1 Like

Hi,

First of all I’d like to apologize for the time you’ve spent retro-engineering peertube AP implementation. Refactoring validators to be more flexible is on my TODO since a long time :frowning:

Next time don’t hesitate to contact us before starting your development, so we can help and maybe do some work on peertube side to ease federation with other software :slight_smile:

Thank you very much for your detailed post. Below my answers

:+1:

Unfortunately we can’t make channels optional on peertube side as it’s a core concept of the software :confused: I know it’s a big limitation but I have no solution for now.

As a side note, if you can, I suggest using your pod account as the peertube channel because channels are the main publisher of the content and are highlighted in the peertube interface. You could use a fake meta account for the owner of the channel.

:+1:

:+1:

Agreed! What licences are available on Pod?

:+1: to support text/html. I think you can try to send your html using text/markdown as PeerTube supports some HTML tags when building the HTML from the markdown.

:+1:

See also Support more formats (PNG…) for thumbnail and preview image · Issue #1953 · Chocobozzz/PeerTube · GitHub

:+1:

I completely agree.


Thanks again for your post. I’ll work on some of these suggestions in the following weeks, and create issues for work I won’t have time to do.

No need for apologize :slight_smile: The work you achieved on Peertube is tremendous and I totally understand that sometimes the quick and rough way is the better, until there is an incentive to refactor and make things cleaner.

I wanted to hack a little and learn a bit about the subject before I came for help. Now here I am :slight_smile:

Basically the same CC licenses that are handled by Peertube.

Thank you for that. :heart: There is nothing blocking on my side as I could work around most of the items, except maybe the jpeg thumbnails.

1 Like

In case you are also interested by chats (provided by the livechat plugin) associated to (live) videos, here is the doc for what the livechat adds in AP:

And the associated FEP proposal:

Using this, you could display the chat of a peertube video on your Pod.
If there is also chat on Pod, and you want the livechat plugin to display it, we can talk to see how we could achieve this.
The underlying protocol is XMPP (with some websocket proxy for server-2-server communication, this is not fully standardized for now).

If you have a chat, but not using XMPP, we could also include an iframe.

Chat support is not planned at the moment but thank you for the links anyways, it might help people working on the project in the future.

Another subject,

I cannot precisely describe how, but after a few broken failed attempts to federate a Pod instance with a Peertube instance, the Peertube Followers counter appears broken:

$ curl -H "Accept: application/activity+json, application/ld+json" -s "http://peertube.localhost:9000/accounts/peertube/followers?page=1" | jq
{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    {
      "RsaSignature2017": "https://w3id.org/security#RsaSignature2017"
    }
  ],
  "id": "http://peertube.localhost:9000/accounts/peertube/followers?page=1",
  "type": "OrderedCollectionPage",
  "partOf": "http://peertube.localhost:9000/accounts/peertube/followers",
  "orderedItems": [
    "http://pod.localhost:8080/ap"
  ],
  "totalItems": 0
}

tolalItems is 0 but there is actually one item in the list.

Please let me know if this better belongs in github than discourse.

Yes it’s a bug I fixed a few days ago :slight_smile: Fix AP actor follows count · Chocobozzz/PeerTube@47ae6e8 · GitHub

You can use https://peertube2.cpy.re to get latest changes (updated nightly). I can create an account for your on this platform if you need it.

1 Like

One thing worth being mentioned in the documentation is that peertube send update activities on the sharedInbox AP endpoint (and not the inbox).