Misskey: Username link shows up as a card on Mastodon

Created on 28 Oct 2019  ·  15Comments  ·  Source: syuilo/misskey

💡 Summary

Also look: https://github.com/tootsuite/mastodon/issues/12149

🙂 Expected Behavior

Links in the username should look like this:
image
No card, and pale blue color

☹️ Actual Behavior

When mentioning Mastodon user from Misskey, it looks like this:
image
link

It shows a preview card, and color is bright blue.

I know that this is not a Misskey bug, but it would still be nice to get this fixed here because Mastodon claimed that they have no intention to fix this on their side.

📌 Environment

Misskey 11.34.0 -> Mastodon 3.0.1

⚠️bug?

Most helpful comment

core of this issue is that Misskey doesn't use the user's url for mention links.

If Misskey uses the user's URL as a mention link, Mastodon should no longer get (and show) the card.

https://github.com/tootsuite/mastodon/blob/9762fe382c76fdff5281a94f484191a92d09eac7/app/services/fetch_link_card_service.rb#L85-L88

however, this issue is difficult to (completely) solve because of a design issue of Misskey database.

Here is where Misskey converts mentions into links:
https://github.com/syuilo/misskey/blob/7a94117d902d98bb77da148249c1aeae30d9570d/src/mfm/toHtml.ts#L137-L139

mentionedRemoteUsers come from here:
https://github.com/syuilo/misskey/blob/7a94117d902d98bb77da148249c1aeae30d9570d/src/services/note/create.ts#L386-L390

but this is stored as a plain string to DB, cant resolve url from this object.

Adding a URL property here will resolve the mention of future posts, but it will require a very large migration to handle existing posts.

Since it is not realistic to deal with existing posts, considering a large-scale server, only new posts are corrected for the time being.


日本語版 / Japanese version

この問題の核心は、Misskeyがuser.urlをメンションのリンク先に使わないことです。

もしMisskeyがuser.urlをメンションのリンク先にしていれば、Mastodonはカードを表示しないはずです。

https://github.com/tootsuite/mastodon/blob/9762fe382c76fdff5281a94f484191a92d09eac7/app/services/fetch_link_card_service.rb#L85-L88

ですが、この問題を(完璧に)解決するにはMisskeyのデータベースの設計の問題により困難です。

ここでMisskeyはリンクをHTMLに変換しています:
https://github.com/syuilo/misskey/blob/7a94117d902d98bb77da148249c1aeae30d9570d/src/mfm/toHtml.ts#L137-L139

このmentionedRemoteUsersはここから来ます:
https://github.com/syuilo/misskey/blob/7a94117d902d98bb77da148249c1aeae30d9570d/src/services/note/create.ts#L386-L390

ですが、ここではただの文字列としてDBに保存されているため、ここからURLを取ってくるのは困難です。

新しい投稿のメンションのリンク先をurlにするのは簡単ですが、既存の投稿に対応するにはとても大きいマイグレーションが必要になります。

既存の投稿に対応するのは大規模のサーバーのことを考えると現実的ではないので、ひとまず修正後に作られる新しい投稿にのみ対応します。

All 15 comments

Card fix is here and temporary fix for bright blue link is here.

For the second fix, Mastodon expects the link in the username to be in https://host/@username form. Relevant code here.

MEMO: link color issue is related to #2467

core of this issue is that Misskey doesn't use the user's url for mention links.

If Misskey uses the user's URL as a mention link, Mastodon should no longer get (and show) the card.

https://github.com/tootsuite/mastodon/blob/9762fe382c76fdff5281a94f484191a92d09eac7/app/services/fetch_link_card_service.rb#L85-L88

however, this issue is difficult to (completely) solve because of a design issue of Misskey database.

Here is where Misskey converts mentions into links:
https://github.com/syuilo/misskey/blob/7a94117d902d98bb77da148249c1aeae30d9570d/src/mfm/toHtml.ts#L137-L139

mentionedRemoteUsers come from here:
https://github.com/syuilo/misskey/blob/7a94117d902d98bb77da148249c1aeae30d9570d/src/services/note/create.ts#L386-L390

but this is stored as a plain string to DB, cant resolve url from this object.

Adding a URL property here will resolve the mention of future posts, but it will require a very large migration to handle existing posts.

Since it is not realistic to deal with existing posts, considering a large-scale server, only new posts are corrected for the time being.


日本語版 / Japanese version

この問題の核心は、Misskeyがuser.urlをメンションのリンク先に使わないことです。

もしMisskeyがuser.urlをメンションのリンク先にしていれば、Mastodonはカードを表示しないはずです。

https://github.com/tootsuite/mastodon/blob/9762fe382c76fdff5281a94f484191a92d09eac7/app/services/fetch_link_card_service.rb#L85-L88

ですが、この問題を(完璧に)解決するにはMisskeyのデータベースの設計の問題により困難です。

ここでMisskeyはリンクをHTMLに変換しています:
https://github.com/syuilo/misskey/blob/7a94117d902d98bb77da148249c1aeae30d9570d/src/mfm/toHtml.ts#L137-L139

このmentionedRemoteUsersはここから来ます:
https://github.com/syuilo/misskey/blob/7a94117d902d98bb77da148249c1aeae30d9570d/src/services/note/create.ts#L386-L390

ですが、ここではただの文字列としてDBに保存されているため、ここからURLを取ってくるのは困難です。

新しい投稿のメンションのリンク先をurlにするのは簡単ですが、既存の投稿に対応するにはとても大きいマイグレーションが必要になります。

既存の投稿に対応するのは大規模のサーバーのことを考えると現実的ではないので、ひとまず修正後に作られる新しい投稿にのみ対応します。

まずここには2つの問題が記述されていて

問題1: メンションでカードが表示されてしまう
→ u-url を付ければなおる
https://github.com/tootsuite/mastodon/blob/9762fe382c76fdff5281a94f484191a92d09eac7/app/services/fetch_link_card_service.rb#L85-L88

問題2: メンションの色がブルーになってしまう
https://github.com/tootsuite/mastodon/blob/master/app/javascript/mastodon/components/status_content.js#L49


この問題の核心は、Misskeyがuser.urlをメンションのリンク先に使わないことです。
もしMisskeyがuser.urlをメンションのリンク先にしていれば、Mastodonはカードを表示しないはずです。

カードを表示しないようにするだけならば1に対応してu-urlを付けるだけでいいように思えます
Mastodon側でMisskey側で対応してと言ってるのも問題1だけです


問題2については

この問題の核心は、Misskeyがuser.urlをメンションのリンク先に使わないことです。

が仕様上問題があるとも思えないので
(mentionがuriだとメンション扱いのUIに出来ないのはMastodonの構造上の都合と思われる)
のでスキーマを変えてまで対応しなくていいのではと思います。

メンションの色がブルーになるだけじゃなく、WebUI内でプロフィールを開けない問題もあるので直したい気持ちが強い

URIはActivityPubだとhttpsなURLなはずだし、Mastodon側でURIでもmentionリンクとして処理すればいいというアレもあるかもしれないけど、それはそれとしてリンク先のhrefにはurlを用いたほうが親切な気がする (urlA link to the actor's "profile web page", if not equal to the value of id. なので https://www.w3.org/TR/activitypub/#as2-actor-properties )

メンションの色がブルーになるだけじゃなく、WebUI内でプロフィールを開けない問題もあるので直したい気持ちが強い

この問題は、今はAP用URLの場合はAccepts見てリダイレクトするようになってるのでなおってます
https://github.com/syuilo/misskey/issues/2467#issuecomment-547122578

あーっそうじゃなくて、(Mastodon側でリンクがメンションで認識されないと)MastodonのWebUI内のプロフィールページで開けないという話

urlを用いたほうが親切

それはある

検索バーで url が入力された場合 (ap/show API) に、1回フェッチして再度DB探索する必要がなくなるというのもある
https://github.com/syuilo/misskey/blob/245b08b624573cf4f6cb3192995d5d4f319cbce2/src/server/api/endpoints/ap/show.ts#L97-L102

あーっそうじゃなくて、(Mastodon側でリンクがメンションで認識されないと)MastodonのWebUI内のプロフィールページで開けないという話

あー

https://docs.joinmastodon.org/api/entities/#status
API Entityのmentionsの中にハッシュタグやunhandledLinkを混ぜて返して
正当なメンションURLと発生するかもわからないunhandledLinkを判別するために
urlとだけマッチしてるMastodonが手抜きな気もするけど…
→あまりmentionsにメンション以外が入ってるパターン観測できないので過去互換?

スキーマを変えてまで対応しなくていいのでは

このスキーマがDBのスキーマのことを指しているのであれば、mentionedRemoteUsersただの文字列としてDBに保存されているので、新規投稿への対応だけだったらTypeScript側のinterfaceにちょっとurl?: stringみたいなのを付け足して保存処理でurlが取れたら付けるようにするぐらいで行ける

保存処理でurlが取れたら付けるようにするぐらいで行ける

可能なら取得して添付する部分はやっちゃっていいと思います
(カード自体には関係ないですが)

メンション扱いになればカードも取られなくなるはず

https://github.com/tootsuite/mastodon/blob/9762fe382c76fdff5281a94f484191a92d09eac7/app/services/fetch_link_card_service.rb#L85-L88

mention_link?(a)がtrueになればカードの対象から外されて、そのmention_link?(a)hrefのリンク先がmentionsのどれかのアカウントのurlと一致したら (要はMastodonのWebUIのメンションリンク判定とやってること一緒) trueを返すので

はい
Mastodonがデファクトスタンダードなのがいまいち気に食わないってだけなので両方やればいいとおもいます

Person.urlって格納してたんですね...
Note.urlの方は格納してなかったのでそっちと勘違いしてました…

Was this page helpful?
0 / 5 - 0 ratings

Related issues

2vg picture 2vg  ·  3Comments

tamaina picture tamaina  ·  3Comments

ibrokemypie picture ibrokemypie  ·  3Comments

syuilo picture syuilo  ·  3Comments

ne-moni picture ne-moni  ·  3Comments