misskey-dev / misskey

🌎 A completely free and open interplanetary microblogging platform 🚀
https://misskey-hub.net/
GNU Affero General Public License v3.0
9.94k stars 1.35k forks source link

Funkwhale のActivityPub Objectのサポート #6231

Open u1-liquid opened 4 years ago

u1-liquid commented 4 years ago

Summary

現状 https://iro.moe/notes/859gijxzpd image

オブジェクト

{
    "id": "https://open.audio/federation/music/uploads/d2bc704b-f0f3-446e-81fd-386a7e622d55",
    "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1", "https://funkwhale.audio/ns", {
            "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
            "Hashtag": "as:Hashtag"
        }
    ],
    "content": "<p>Really happy with this one!</p>",
    "attributedTo": "https://open.audio/federation/actors/pulse",
    "image": null,
    "position": 1,
    "name": "2020-03-23",
    "album": "https://open.audio/federation/music/albums/4add5d87-d936-403a-8344-31c7836bb5ab",
    "to": "https://www.w3.org/ns/activitystreams#Public",
    "summary": "#Acoustic #Acoustic #guitar #guitar",
    "published": "2020-03-24T12:45:59.543613+00:00",
    "type": "Audio",
    "duration": 2957,
    "url": [{
            "type": "Link",
            "href": "https://open.audio/library/tracks/75433",
            "mediaType": "text/html"
        }, {
            "bitrate": 160000,
            "type": "Link",
            "href": "https://open.audio/api/v1/listen/58fbdd38-6a0f-4fa6-9515-a7a4d542b60f/?upload=d2bc704b-f0f3-446e-81fd-386a7e622d55&download=false",
            "mediaType": "audio/ogg",
            "size": 49084219
        }
    ],
    "tag": [{
            "name": "#Acoustic",
            "type": "Hashtag"
        }, {
            "name": "#Acoustic",
            "type": "Hashtag"
        }, {
            "name": "#guitar",
            "type": "Hashtag"
        }, {
            "name": "#guitar",
            "type": "Hashtag"
        }
    ],
    "license": "http://creativecommons.org/licenses/by-sa/4.0/",
    "mediaType": "text/html"
}

今のところ、urlに入ってる値はリンクテキストのみだという前提でparseしているようですが、 どうやらurlは元から複数のオブジェクトも入れるみたいです https://www.w3.org/TR/activitystreams-vocabulary/#dfn-url

とりあえずこれに対応できればFunkwhaleの楽曲をノートとして受け取ることができそうですね

あとFunkwhaleは固有実装したネームスペースファイルがあるようです https://funkwhale.audio/ns

{
  "@context": {
    "id": "@id",
    "type": "@type",
    "as": "https://www.w3.org/ns/activitystreams#",
    "schema": "http://schema.org#",
    "fw": "https://funkwhale.audio/ns#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "Album": "fw:Album",
    "Track": "fw:Track",
    "Artist": "fw:Artist",
    "Library": "fw:Library",
    "bitrate": {
      "@id": "fw:bitrate",
      "@type": "xsd:nonNegativeInteger"
    },
    "size": {
      "@id": "fw:size",
      "@type": "xsd:nonNegativeInteger"
    },
    "position": {
      "@id": "fw:position",
      "@type": "xsd:nonNegativeInteger"
    },
    "disc": {
      "@id": "fw:disc",
      "@type": "xsd:nonNegativeInteger"
    },
    "library": {
      "@id": "fw:library",
      "@type": "@id"
    },
    "track": {
      "@id": "fw:track",
      "@type": "@id"
    },
    "cover": {
      "@id": "fw:cover",
      "@type": "as:Link"
    },
    "album": {
      "@id": "fw:album",
      "@type": "@id"
    },
    "artists": {
      "@id": "fw:artists",
      "@type": "@id",
      "@container": "@list"
    },
    "released": {
      "@id": "fw:released",
      "@type": "xsd:date"
    },
    "musicbrainzId": "fw:musicbrainzId",
    "license": {
      "@id": "fw:license",
      "@type": "@id"
    },
    "copyright": "fw:copyright",
    "category": "sc:category",
    "language": "sc:inLanguage"
  }
}

こっちもAPタイプに加えてよろしいでしょうか?(正攻法としてnをparseしたほうが良さそうだけど)

agateblue commented 4 years ago

I will only be able to help in english, but feel free to ask if you have any question. You may encounter a similar issue with our Channel actors, since they have a list of URL too:

$ curl -k -L -H "Accept: application/activity+json" "https://channels.tests.funkwhale.audio/federation/actors/compositions"  | jq       

{
  "id": "https://channels.tests.funkwhale.audio/federation/actors/compositions",
  "outbox": "https://channels.tests.funkwhale.audio/federation/actors/compositions/outbox",
  "inbox": "https://channels.tests.funkwhale.audio/federation/actors/compositions/inbox",
  "preferredUsername": "compositions",
  "type": "Person",
  "name": "Compositions",
  "followers": "https://channels.tests.funkwhale.audio/federation/actors/compositions/followers",
  "following": "https://channels.tests.funkwhale.audio/federation/actors/compositions/following",
  "manuallyApprovesFollowers": false,
  "url": [
    {
      "type": "Link",
      "href": "https://channels.tests.funkwhale.audio/channels/compositions",
      "mediaType": "text/html"
    },
    {
      "type": "Link",
      "href": "https://channels.tests.funkwhale.audio/api/v1/channels/compositions/rss",
      "mediaType": "application/rss+xml"
    }
  ],
  "icon": {
    "type": "Image",
    "url": "https://channels.tests.funkwhale.audio/media/attachments/75/b4/f1/nosmile.jpeg",
    "mediaType": "image/jpeg"
  },
  "summary": "<p>I'm testing federation with the fediverse :)</p>",
  "attributedTo": "https://channels.tests.funkwhale.audio/federation/actors/demo",
  "category": "music",
  "tag": [
    {
      "type": "Hashtag",
      "name": "#funkwhale"
    },
    {
      "type": "Hashtag",
      "name": "#tests"
    }
  ],
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    "https://funkwhale.audio/ns",
    {
      "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
      "Hashtag": "as:Hashtag"
    }
  ],
  "publicKey": {
    "owner": "https://channels.tests.funkwhale.audio/federation/actors/compositions",
    "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv25u57oZfVLV3KltS+Hc\nsdSx9Op4MmzIes1J8Wu8s0KbdXf2zEwSsVqyHgs/XCbnzsR3FqyJTo46D2BVnvZc\nuU5srNcR2I2HMaqQ0oVdnATE4K6KdcgVN+98pMWo56B8LTgE1VpvqbsrXLi9jCTz\njrkebVMOP+ZVu+64v1qdgddseblYMnBZct0s7ONbHnqrWlTGf5wES1uIZTVdn5r4\nMduZG+Uenfi1opBS0lUUxfWdW9r0oF2byneZUyaUCbEroeKbqsweXCWVgnMarUOs\ngqC42KM4cf95lySSwTSaUtZYIbTw7s9W2jveU/rVg8BYZu5JK5obgBoxtlUeUoSs\nwwIDAQAB\n-----END PUBLIC KEY-----\n",
    "id": "https://channels.tests.funkwhale.audio/federation/actors/compositions#main-key"
  },
  "endpoints": {
    "sharedInbox": "https://channels.tests.funkwhale.audio/federation/shared/inbox"
  }
}
agateblue commented 4 years ago

(also, https://channels.tests.funkwhale.audio/ is a testing instance with the latest code changes. You can use it for all your Misskey federation tests, the login is demo and the password is demo).

mei23 commented 4 years ago

urlhttps://github.com/syuilo/misskey/pull/6234 で修正

@u1-liquid

あとFunkwhaleは固有実装したネームスペースファイルがあるようです https://funkwhale.audio/ns こっちもAPタイプに加えてよろしいでしょうか?(正攻法としてnをparseしたほうが良さそうだけど)

これは何を目的として何をすればいいです? AP typeを定義しても、DBに入れるところがないし、入れてもMisskeyに対応する機能がないです

u1-liquid commented 4 years ago

ノート扱いでリンクが見れるだけでいいと思います。 いまは例のオブジェクトがあるURLを検索欄に入れるとなぜかエラーメッセージも出さず検索ダイアログごと閉じられる微妙な挙動になってるので、せめて照会だけはできるといいなという意見でした。

mei23 commented 4 years ago

@u1-liquid

飛んでくるActivity / Outbox

type: Create
object:
  type: Audio

単体のObject 参照

object:
  type: Audio

みたいなNoteじゃなくてAudioみたいなObjectを、 今HubzillaのImage Objectでやってるように とりあえずリンクで参照できるようにする感じ?

そしてAudio以外には何があります?

u1-liquid commented 4 years ago

https://funkwhale.audio/ns に定義されてますけど、 Audio以外は Album, Track, Artist, Library があり、 propertyとしてbitrateやartistsなどがありますね

実際のオブジェクトの例はこちらです Album https://sound.iro.moe/library/albums/21/ Track https://sound.iro.moe/library/tracks/1117/ Artist https://sound.iro.moe/library/artists/30/ Library https://sound.iro.moe/library/fc2f3ef1-4a0d-46ec-83d3-bbbdff78747f/

mei23 commented 4 years ago

あっと、Audioは元々標準にあったのでサポートしてた。 Albumとかですね。

u1-liquid commented 4 years ago

あっと、Audioは元々標準にあったのでサポートしてた。 Albumとかですね。

はい、Audioは今のところうまく連合されてますね。 (ここのIssueのOpen時のようにリンクがきちんと解釈されてない問題はもう修正済みなので)

mei23 commented 4 years ago
Album:
  AP Object: https://open.audio/federation/music/albums/44c22b44-15aa-4814-b31b-75d2df6f7068
  artist: Artist[] を持ってる
  tracks: Track[] とかありそうでない

Track: https://open.audio/federation/music/tracks/6dd075c7-4683-4d7b-bc7e-3863d7761755
  artist: Artist[], album: Album を持ってる

Artist:
  AP Object: https://open.audio/federation/music/artists/e1738258-e70c-4f2d-9e81-a1f8e1527d9a
  albums: Album[], tracks: Track[], libraries: Library[] とかありそうでない (Webの方には該当する概念はある) 

Library:
  AP Object: https://open.audio/federation/music/libraries/28970d88-c672-4fa6-92dc-3672b73dd556
  Collectionの継承みたいな感じ、itemsはAudioなど
  ※ current, last プロパティの値が間違ってる気がする

オブジェクトの下のつながりとか考えるとめんどくさそうだけど、 単純にNoteの亜種としてリンクするくらいなら大丈夫そう。

u1-liquid commented 4 years ago

オブジェクトの下のつながりとか考えるとめんどくさそうだけど、

専用のUIを追加するほどでない限り(たぶんそれほどはいらない)オブジェクトの下の繋がりは無視してもいいかもしれませんね

単純にNoteの亜種としてリンクするくらいなら大丈夫そう。

はい、個人的には検索ボックスに入れてノートとして扱えるだけで十分だと思います。(引用リノートなどがしたいです)

mei23 commented 4 years ago

Library以外はActor (User)に紐付いてないから、DB上でNoteにすることが出来ない…

mei23 commented 4 years ago

Documentみたいに添付ファイル扱いにする? 添付ファイルもユーザーに紐付いてないと格納できない

u1-liquid commented 4 years ago

Documentみたいに添付ファイル扱いにする? 添付ファイルもユーザーに紐付いてないと格納できない

アルバムとトラックには "attributedTo":"https://sound.iro.moe/federation/actors/satsuki" みたい感じのアップローダーのActorが載ってるので、その人の添付ファイル扱いにするとか…

アーティストは(まぁ人ですし)ユーザー扱いするのが当然かもですけど、なんか微妙ですね…

mei23 commented 4 years ago

https://github.com/syuilo/misskey/issues/6231#issuecomment-616417404 の Album, Track は attributedTo: null だったりします

アーティストは(まぁ人ですし)ユーザー扱いするのが当然かもですけど、なんか微妙ですね…

鍵持ってたりActivity喋れるわけじゃないので Actor (IRemoteUser) じゃないんですよね。

noellabo commented 4 years ago
curl -XGET -H "Accept: application/json" https://sound.iro.moe/api/v1/instance/nodeinfo/2.0 | jq -r '.metadata.actorId'
curl -XGET -H "Accept: application/json" https://sound.iro.moe/federation/actors/service | jq

AP上の処理はService actorを使う手もあるけど、特別扱いしなきゃならないし、悩ましい……。

rinsuki commented 4 years ago

そもそも Funkwhale 側でアーティストをActorにするべきな気がする (何も知らないのでもしかしたら検討違いなことを言ってるかもしれない)

tamaina commented 4 years ago

なんも知らないからアレだけどこれMastodonはどう扱ってるんだろ

mei23 commented 4 years ago

なんも知らないからアレだけどこれMastodonはどう扱ってるんだろ

Audio以外の Album, Track, Artist, Library は全部表示されないです

そもそもこれら (Album以下) はActivityとして飛んでくるわけではなく AP ObjectのURLを調べて直打ちしないと参照できないのではないかと思われるので 対応してなくても実影響ないのではと思います。