0 Nightly Fedibird の絵文字リアクション機能
tateisu edited this page 2021-05-19 17:40:48 +09:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Nightly fedibird の絵文字リアクション機能

対応サーバの見分け方

GET https://nightly.fedibird.com/api/v1/instance

  • fedibird_capabilities[] に "emoji_reaction" が含まれるなら対応サーバ

Status エンティティに追加されるデータ

"emoji_reactioned" :boolean?

自分がリアクション済みなら真

"emoji_reactions": Array

[
	{
		"name": "👍",
		"count": 1, // 後述する理由で、0の場合にパーサは対応すること
		"me": false // 自分がリアクションしたなら真
	},
	{
		"name": "zzzsushi",
		"count": 1,
		"me": true,
		"url": "https://files-nightly.fedibird.com/custom_emojis/images/000/002/352/original/zzzsushi.png",
		"static_url": "https://files-nightly.fedibird.com/custom_emojis/images/000/002/352/static/zzzsushi.png",
		"domain": null // リモートの絵文字ならdomainが設定される
	}
]

リアクションの追加

リアクションの削除

userストリームのnotificationイベント

  • userストリームに通知イベントがくる。
  • 通知タイプは emoji_reaction
  • クライアントはそれを通知TLに表示する他、各種TLに出ている投稿のリアクション内容を更新する。
  • ステータスの投稿者に送られる。
  • 自分でリアクションした時は通知は来ない
  • リアクション解除した時は通知は来ない
  • Notificationオブジェクト直下のemoji_reactionはcount=0,me=falseになる。絵文字の種別のみが有効な情報である。
{
	"stream": ["user"],
	"event": "notification",
	"payload": "..." 下記
}
payload (notification entity)
{
	"id":"27804",
	"type": "emoji_reaction",
	"created_at": "2021-05-16T16:26:47.440Z",
	"account": {...},
	"status":{
		"account":{...},
		...
		"emojis":[],
		"emoji_reactioned":true,
		"emoji_reactions":[
			{"name":"zzzsushi","count":1,"me":true,
				"url":"https://files-nightly.fedibird.com/custom_emojis/images/000/002/352/original/zzzsushi.png",
				"static_url":"https://files-nightly.fedibird.com/custom_emojis/images/000/002/352/static/zzzsushi.png",
				"domain":null
			},
			{"name":"🎆","count":1,"me":false}
		],
		...
	},
	"emoji_reaction":{
		"name":"🎆",
		"count":0,
		"me":false
	}
}

userストリームの emoji_reaction イベント

  • userストリームに emoji_reaction イベントが来る。
  • 「サーバ上で処理されたリアクション全て」が送られてくる。
  • 自分が投げたリアクションに対しても発生する。
  • reaction entity中にstatus_idが含まれる。
  • meは設定されない。 読込済ステータスのリアクション集合とは適切にマージを行う必要がある。

以下がどの順序で発生してもUIに問題がでないように作ること

  • 追加/削除APIへの応答
  • 自分の投稿についたリアクションの通知
  • emoji_reactionイベント

例えばAPIの応答が返る前にemoji_reactionイベントが来るかもしれないし、自分の投稿についたリアクションの通知の前後にemoji_reactionイベントが来るかもしれない。

{
	"stream": ["user"],
	"event": "emoji_reaction",
	"payload": "…" // 下記
}
payload (reaction entity)
{
	"name":"majikayo",
	"count":1, // リアクション削除時は0になる
	"url":"https://files-nightly.fedibird.com/cache/custom_emojis/images/000/003/843/original/a436fd4f7d99b3b7.png",
	"static_url":"https://files-nightly.fedibird.com/cache/custom_emojis/images/000/003/843/static/a436fd4f7d99b3b7.png",
	"domain":"misskey.io",
	"status_id":"106256591712106765"
}

WebPush

購読APIの data.alerts[] に "emoji_reaction" を追加することでプッシュ通知を受け取れる。

自分がリアクションした投稿の一覧