LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
12.98k stars 863 forks source link

Better federation for Peertube content #3837

Open K4LCIFER opened 11 months ago

K4LCIFER commented 11 months ago

Requirements

Is your proposal related to a problem?

Currently it seems that Peertube federation is rather lacking -- comments, and likes do not appear to be federated, and the videos only show up as links instead of watchable videos from Lemmy.

Describe the solution you'd like.

I propose that better federation support for Peertube content to be added so that likes, and comments are properly federated, and that you can watch peertube content from within Lemmy. An example of the current state of federation can be seen here.

Describe alternatives you've considered.

none

Additional context

The videos themselves being viewable from within lemmy may be a duplicate of #2318

andrea3x commented 10 months ago

I think this is an important feature to have, especially for likes and comments. If I want to reply to a comment on a PeerTube video, I should open an account there, in contrast to the principles of Fediverse

Nutomic commented 9 months ago

Lemmy federates according to FEP-1b12, so Peertube would be responsible to forwarding votes and comments to followers. Maybe its not implemented on their side.

K4LCIFER commented 9 months ago

Lemmy federates according to FEP-1b12, so Peertube would be responsible to forwarding votes and comments to followers. Maybe its not implemented on their side.

It's not only comments, and likes, though -- all the videos of the user that was mentioned in the post only show up as links. This PeerTube user seem's to have playable videos, but they also suffer from no federated likes, or comments.

paulo-roger commented 7 months ago

Hola @Nutomic,

Regarding showing the Peertube videos embeded on lemmy topic, is it possible?

Nutomic commented 6 months ago

Embeds are currently broken in lemmy-ui. The backend correctly populates post.embed_video_url (example), but for some reason lemmy-ui doesnt show that.

paulo-roger commented 6 months ago

Embeds are currently broken in lemmy-ui. The backend correctly populates post.embed_video_url (example), but for some reason lemmy-ui doesnt show that.

It worked perfect on my end! Amazing! Thanks for your work!

Chocobozzz commented 6 months ago

Lemmy federates according to FEP-1b12, so Peertube would be responsible to forwarding votes and comments to followers. Maybe its not implemented on their side.

PeerTube channels are Group because we plan in the future to have multiple accounts that can manage a channel. But they are not a forum, so we don't accept likes/notes. However I'm not against forwarding these activities if it can help Lemmy use cases.

Don't hesitate to create an issue on https://github.com/Chocobozzz/PeerTube so we can discuss about this :)

paulo-roger commented 6 months ago

@Chocobozzz I will create the issue, thanks! We talked in mastodon briefly, I was at grandma for christmas and away from my computer.

Issue: #6142

Nutomic commented 6 months ago

PeerTube channels are Group because we plan in the future to have multiple accounts that can manage a channel. But they are not a forum, so we don't accept likes/notes. However I'm not against forwarding these activities if it can help Lemmy use cases.

@Chocobozzz One problem is that Lemmy doesnt know that other users arent allowed to create posts (videos) in the Peertube channel. Lemmy has a custom federation attribute postingRestrictedToMods which has the same effect, you can see it on this group. If Peertube can set the same or similar attribute for its groups, then we can disable posting from Lemmy.

For comments and votes, its like FEP-1b12 describes, the group should Announce them to its followers. So it would be great if Peertube groups could do the same (or does Peertube have any existing mechanism for that?)

Chocobozzz commented 6 months ago

I have some difficulties to test Lemmy & PeerTube federation on my local computer because Lemmy complains about missing fields/invalid data

2024-01-12T13:54:26.581980Z  WARN Error encountered while processing the incoming HTTP request: lemmy_server::root_span_builder: Unknown: Failed to parse object http://peertube.localhost:9001/videos/watch/8fb3bcb9-20bd-490e-9afa-2582b12a595a with content {"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"RsaSignature2017":"https://w3id.org/security#RsaSignature2017"},{"pt":"https://joinpeertube.org/ns#","sc":"http://schema.org/","Hashtag":"as:Hashtag","uuid":"sc:identifier","category":"sc:category","licence":"sc:license","subtitleLanguage":"sc:subtitleLanguage","sensitive":"as:sensitive","language":"sc:inLanguage","identifier":"sc:identifier","isLiveBroadcast":"sc:isLiveBroadcast","liveSaveReplay":{"@type":"sc:Boolean","@id":"pt:liveSaveReplay"},"permanentLive":{"@type":"sc:Boolean","@id":"pt:permanentLive"},"latencyMode":{"@type":"sc:Number","@id":"pt:latencyMode"},"Infohash":"pt:Infohash","tileWidth":{"@type":"sc:Number","@id":"pt:tileWidth"},"tileHeight":{"@type":"sc:Number","@id":"pt:tileHeight"},"tileDuration":{"@type":"sc:Number","@id":"pt:tileDuration"},"originallyPublishedAt":"sc:datePublished","uploadDate":"sc:uploadDate","hasParts":"sc:hasParts","views":{"@type":"sc:Number","@id":"pt:views"},"state":{"@type":"sc:Number","@id":"pt:state"},"size":{"@type":"sc:Number","@id":"pt:size"},"fps":{"@type":"sc:Number","@id":"pt:fps"},"commentsEnabled":{"@type":"sc:Boolean","@id":"pt:commentsEnabled"},"downloadEnabled":{"@type":"sc:Boolean","@id":"pt:downloadEnabled"},"waitTranscoding":{"@type":"sc:Boolean","@id":"pt:waitTranscoding"},"support":{"@type":"sc:Text","@id":"pt:support"},"likes":{"@id":"as:likes","@type":"@id"},"dislikes":{"@id":"as:dislikes","@type":"@id"},"shares":{"@id":"as:shares","@type":"@id"},"comments":{"@id":"as:comments","@type":"@id"}}],"to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["http://peertube.localhost:9001/accounts/root/followers"],"type":"Video","id":"http://peertube.localhost:9001/videos/watch/8fb3bcb9-20bd-490e-9afa-2582b12a595a","name":"60fps_720p_small","duration":"PT2S","uuid":"8fb3bcb9-20bd-490e-9afa-2582b12a595a","views":0,"sensitive":false,"waitTranscoding":true,"state":1,"commentsEnabled":true,"downloadEnabled":true,"published":"2024-01-12T13:54:25.898Z","originallyPublishedAt":null,"updated":"2024-01-12T13:54:25.898Z","tag":[],"mediaType":"text/markdown","content":null,"support":null,"subtitleLanguage":[],"icon":[{"type":"Image","url":"http://peertube.localhost:9001/lazy-static/thumbnails/0b7f67fa-ac46-45a6-ad64-b2809c4e57ad.jpg","mediaType":"image/jpeg","width":280,"height":157},{"type":"Image","url":"http://peertube.localhost:9001/lazy-static/previews/2d858d98-8fde-4241-89de-f3169c48d6dc.jpg","mediaType":"image/jpeg","width":850,"height":480}],"preview":[{"type":"Image","rel":["storyboard"],"url":[{"mediaType":"image/jpeg","href":"http://peertube.localhost:9001/lazy-static/storyboards/359bf6f4-30b0-4ca5-9f16-29a8140cf21f.jpg","width":384,"height":108,"tileWidth":192,"tileHeight":108,"tileDuration":"PT1S"}]}],"url":[{"type":"Link","mediaType":"text/html","href":"http://peertube.localhost:9001/videos/watch/8fb3bcb9-20bd-490e-9afa-2582b12a595a"},{"type":"Link","mediaType":"video/mp4","href":"http://peertube.localhost:9001/static/web-videos/2dc5c0f4-d475-4af7-aaaf-8bc05b2a9d27-720.mp4","height":720,"size":276786,"fps":60},{"type":"Link","rel":["metadata","video/mp4"],"mediaType":"application/json","href":"http://peertube.localhost:9001/api/v1/videos/8fb3bcb9-20bd-490e-9afa-2582b12a595a/metadata/2","height":720,"fps":60},{"type":"Link","mediaType":"application/x-bittorrent","href":"http://peertube.localhost:9001/lazy-static/torrents/8d367db8-1088-454e-ae65-e70f2e4d87b6-720.torrent","height":720},{"type":"Link","mediaType":"application/x-bittorrent;x-scheme-handler/magnet","href":"magnet:?xs=http%3A%2F%2Fpeertube.localhost%3A9001%2Flazy-static%2Ftorrents%2F8d367db8-1088-454e-ae65-e70f2e4d87b6-720.torrent&xt=urn:btih:fd2479730d599715ac6958638a13c59b3fac0dd9&dn=60fps_720p_small&tr=http%3A%2F%2Fpeertube.localhost%3A9001%2Ftracker%2Fannounce&tr=ws%3A%2F%2Fpeertube.localhost%3A9001%2Ftracker%2Fsocket&ws=http%3A%2F%2Fpeertube.localhost%3A9001%2Fstatic%2Fweb-videos%2F2dc5c0f4-d475-4af7-aaaf-8bc05b2a9d27-720.mp4","height":720},{"type":"Link","name":"tracker-http","rel":["tracker","http"],"href":"http://peertube.localhost:9001/tracker/announce"},{"type":"Link","name":"tracker-websocket","rel":["tracker","websocket"],"href":"ws://peertube.localhost:9001/tracker/socket"}],"likes":"http://peertube.localhost:9001/videos/watch/8fb3bcb9-20bd-490e-9afa-2582b12a595a/likes","dislikes":"http://peertube.localhost:9001/videos/watch/8fb3bcb9-20bd-490e-9afa-2582b12a595a/dislikes","shares":"http://peertube.localhost:9001/videos/watch/8fb3bcb9-20bd-490e-9afa-2582b12a595a/announces","comments":"http://peertube.localhost:9001/videos/watch/8fb3bcb9-20bd-490e-9afa-2582b12a595a/comments","hasParts":"http://peertube.localhost:9001/videos/watch/8fb3bcb9-20bd-490e-9afa-2582b12a595a/chapters","attributedTo":[{"type":"Person","id":"http://peertube.localhost:9001/accounts/root"},{"type":"Group","id":"http://peertube.localhost:9001/video-channels/root_channel"}],"isLiveBroadcast":false,"liveSaveReplay":null,"permanentLive":null,"latencyMode":null}: missing field `actor` at line 1 column 5038
   0: lemmy_apub::activities::community::announce::receive
             at crates/apub/src/activities/community/announce.rs:153
   1: lemmy_server::root_span_builder::HTTP request
           with http.method=POST http.scheme="http" http.host=lemmy.localhost:8536 http.target=/inbox otel.kind="server" request_id=8619af57-c48a-4fc7-b9e6-08739147e389 http.status_code=400 otel.status_code="OK"
             at src/root_span_builder.rs:16
2024-01-12T13:54:26.327554Z  WARN Error encountered while processing the incoming HTTP request: lemmy_server::root_span_builder: Unknown: Failed to parse object http://peertube.localhost:9001/accounts/peertube with content {"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"RsaSignature2017":"https://w3id.org/security#RsaSignature2017"},{"pt":"https://joinpeertube.org/ns#","sc":"http://schema.org/","playlists":{"@id":"pt:playlists","@type":"@id"},"support":{"@type":"sc:Text","@id":"pt:support"},"icons":"as:icon"}],"type":"Application","id":"http://peertube.localhost:9001/accounts/peertube","following":"http://peertube.localhost:9001/accounts/peertube/following","followers":"http://peertube.localhost:9001/accounts/peertube/followers","playlists":"http://peertube.localhost:9001/accounts/peertube/playlists","inbox":"http://peertube.localhost:9001/accounts/peertube/inbox","outbox":"http://peertube.localhost:9001/accounts/peertube/outbox","preferredUsername":"peertube","url":"http://peertube.localhost:9001/accounts/peertube","name":"peertube","endpoints":{"sharedInbox":"http://peertube.localhost:9001/inbox"},"publicKey":{"id":"http://peertube.localhost:9001/accounts/peertube#main-key","owner":"http://peertube.localhost:9001/accounts/peertube","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBiwtN04ezPYIwRRf+T1MOxqhU\n66tt1M8e5LJ1j0CNA5VOIFC5cyC3CMDWmIywvamPHtqRAXhKc+xw8wQWR2vxTwga\nJqTKBV0uBoEakO/wPZKumarN8Kdpij19ur61Ti4nMEnSxJPpwXS56MDjTIMiUN1S\nENwCk0lAoxizSZzupQIDAQAB\n-----END PUBLIC KEY-----\n"},"published":"2024-01-12T13:44:59.690Z","summary":null}: data did not match any variant of untagged enum PersonOrGroup
2024-01-12T13:54:26.574495Z  WARN HTTP request{http.method=POST http.scheme="http" http.host=lemmy.localhost:8536 http.target=/inbox otel.kind="server" request_id=8619af57-c48a-4fc7-b9e6-08739147e389}:from_json:from_json: lemmy_utils: error in spawn: Unknown: Failed to parse object http://peertube.localhost:9001/video-channels/root_channel/outbox with content {"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"RsaSignature2017":"https://w3id.org/security#RsaSignature2017"}],"id":"http://peertube.localhost:9001/video-channels/root_channel/outbox","type":"OrderedCollection","totalItems":2,"first":"http://peertube.localhost:9001/video-channels/root_channel/outbox?page=1"}: missing field `orderedItems` at line 1 column 349

For comments and votes, its like FEP-1b12 describes, the group should Announce them to its followers

To be sure to understand the current federation issues:

Nutomic commented 6 months ago

I have some difficulties to test Lemmy & PeerTube federation on my local computer because Lemmy complains about missing fields/invalid data

Are you sending an activity Announce/Video (announce with object video) to Lemmy? Because Lemmy only supports Announce/Create/Video or similar, always with an activity as object for the announce.

The next one has "type":"Application", is that a normal user? Lemmy only supports that type for the instance actor.

We dont support pagination yet, but outbox is not required anyway.

Publication (videos) comments and likes are correctly federated between PeerTube and Lemmy?

Channels and videos yes, example. You just need to paste the channel id in the search field. Iirc videos are added correctly when the create activity is received. Not sure about comments and votes, those might be broken.

Group (Video channels) publications must be forbidden using postingRestrictedToMods

Correct

Group (Video channels) comments should be Announce by PeerTube origin server to group followers so all Lemmy instances are aware of another Lemmy comment

Yes, and also as Announce/Create/Note. Here is an example how it looks. Though comments belong to a post/video, not directly to the group.

I'm not sure to understand the votes concept: can we vote for groups in Lemmy?

No you can only Like/Dislike posts and comments.

This folder has test cases for parsing Peertube objects and activities. If you send me more examples then I can ensure that they are also parsed correctly.