ソーシャルネットワークで使われるそのほかの機能の実現方法
ここまででFediverseに参加するために必要な最小限の機能は実装できていますが、
ブースト(リツイート)
通常の短文投稿ではCreateオブジェクトを作成しますが、Announce
オブジェクトを作成します。
{
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://actub.ub32.org/argrath/456/activity",
"type": "Announce",
"actor": "https://actub.ub32.org/argrath",
"published": "2018-03-03T09:54:50Z",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://actub.ub32.org/argrath/followers"
],
"object": "https://example.com/users/foobar/123"
}
object
属性にはブーストする短文のIDを設定します。そのあと通常の投稿と同様にこのオブジェクトをフォロワーに通知します。
お気に入り(いいね)
お気に入りに指定する場合、Like
オブジェクトを作成し、
{
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://example.com/users/foobar#likes/1",
"type": "Like",
"actor": "https://example.com/users/foobar",
"object": "https://actub.ub32.org/argrath/123"
}
ここでもobject
属性にはお気に入りに指定する短文のIDを設定します。
ハッシュタグ
ハッシュタグに関する詳細は、Note
オブジェクトを示します。
{
"@context": [
"https://www.w3.org/ns/activitystreams",
{
"Hashtag": "as:Hashtag"
}
],
"id": "https://actub.ub32.org/argrath/123",
"type": "Note",
"url": "https://actub.ub32.org/argrath/123",
"published": "2018-03-03T09:54:50Z",
"content": "はいさーい #test",
"attributedTo": "https://actub.ub32.org/argrath",
"tag": [
{
"type": "Hashtag",
"name": "#test",
"href": "https://actub.ub32.org/tags/test"
}
],
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://actub.ub32.org/argrath/followers"
]
}
まずActivityPubに含まれていない属性を使うために、@context
属性にHashtag
クラスに関する定義を追加します。そして、tag
属性としてtype
属性に固定文字列Hashtag
、name
属性にタグ文字列、href
属性にこのタグを含む短文の一覧が表示されるHTMLへのリンクを指定します。content
属性の短文にハッシュタグを含めただけではハッシュタグとは認識されず、tag
属性に設定する必要があることに注意してください。
画像の添付
画像を添付するには、Note
オブジェクトを作成するときに次のようなattachment
属性を追加します。
"attachment": [
{
"type": "Document",
"mediaType": "image/png",
"url": "https://example.com/media/1234.png"
}
]
プロフィール情報
アクターの表示名、
"name": "表示名",
"summary": "プロフィールです",
"icon": {
"type": "Image",
"mediaType": "image/png",
"url": "https://example.com/media/1234.png"
}
name
属性に表示名、summary
属性にプロフィール、icon
属性にアイコンの情報を指定します。
まとめ
ActivityPub自体の仕様は大きいので、
さて、