ソーシャルネットワークで使われるそのほかの機能の実現方法
ここまでで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自体の仕様は大きいので、
さて、


