Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mentions of Pleroma users do not maintain domain #108

Closed
trwnh opened this issue Sep 3, 2019 · 9 comments
Closed

Mentions of Pleroma users do not maintain domain #108

trwnh opened this issue Sep 3, 2019 · 9 comments

Comments

@trwnh
Copy link

trwnh commented Sep 3, 2019

Both in display and during "select and copy". Mastodon users consistently have full username maintained. Pleroma users consistently drop domain.

Presumably this might be because of the form of the URL in the a href? Mastodon and Pleroma both use /users/username for ActivityPub id, but Mastodon uses /@username for url and in mention links.

@tateisu
Copy link
Owner

tateisu commented Sep 3, 2019

ST restore full acct from mention's href="..." link. ST support and test for Mastodon and Misskey, but currently I don't use Pleroma. PRs are welcome.

@tateisu
Copy link
Owner

tateisu commented Sep 3, 2019

(1) Resolving full acct by fetching user URL requires some network cost. I want to avoid extra network request in most case.

(2)also Mastodon 3.x will have some restricted mode for AP request from non-allowed host. current AP is Server-to-Server protocol.
I think we may have to use search API to resolve full acct from user URL to support foreigners in fediverse. this is rare case and can be skipped if user URL is known style.

@trwnh
Copy link
Author

trwnh commented Sep 4, 2019

OK, if it is done with href, then href should probably recognize more than just @. Or it should be generic maybe? Just use the domain part and assume the content inside <a> is the username?

Or maybe can use acct from API response, since this usually already comes in form of username or username@remote. There should be a mentions in the API response, I think... is there any downside to just using this directly? Just append @ and acct together directly. Server should be able to parse Webfinger correctly when you post the status.

@tateisu
Copy link
Owner

tateisu commented Sep 4, 2019

the mentions metadata can't be used to resolve acct in this case. if a toot has mentions such as "@tateisu@a @tateisu@b @tateisu@c @tateisu@a" , mentions metadata has only 3 entry.

I think mention link href only indicates the user's instance, but its url format is not regulated.

also, in a message sent from misskey to mastodon, no guarantee url host is same to user's instance, because misskey may clones public user page, such as https://misskey-site/@user@other-instance.
this url can't be used in search API because it is not AP id. ST supports Misskey and check this style URL.

of course ST should detect most user URL from federated service.

  • (1) check some regexp to skip extra HTTP request,
  • (2) if failed then use search API to resolve full acct
  • (3) if failed then just add url host as instance.

2,3 is not implemented currently.

@trwnh
Copy link
Author

trwnh commented Sep 4, 2019

hmm. in activitypub the Mention indicates name text which should be replaced with the href. API response does not do this, it only provides acct. But this still might be enough...

  1. Use cached Status-Source (API response for Status entity)
  2. Check mention url and search through Status content for this value
  3. Should be found as href of an <a>, in which case replace contents of <a> with mention acct

Example: https://mastodon.social/api/v1/statuses/102732717380497594

"content":
"<p><span class=\"h-card\"><a href=\"https://nulled.red/@flussence\" class=\"u-url mention\">@<span>flussence</span></a></span> <span class=\"h-card\"><a href=\"https://nulled.red/@amic\" class=\"u-url mention\">@<span>amic</span></a></span> <span class=\"h-card\"><a href=\"https://be.cutewith.me/users/alayna\" class=\"u-url mention\">@<span>alayna</span></a></span> yes</p>",
[...]
"mentions":[
{"id":"419781","username":"flussence","url":"https://nulled.red/@flussence","acct":"flussence@nulled.red"},
{"id":"482403","username":"amic","url":"https://nulled.red/@amic","acct":"amic@nulled.red"},
{"id":"869022","username":"alayna","url":"https://be.cutewith.me/users/alayna","acct":"alayna@be.cutewith.me"}
]
  • Extract a tags and compare href to mentions > index > href
  • If match, replace contents of a with "@" + {acct} concatenated

so:

  • <a href=\"https://nulled.red/@flussence\" class=\"u-url mention\">@<span>flussence</span></a> finds mentions url https://nulled.red/@flussence, so gets acct flussence@nulled.red and displays @flussence@nulled.red
  • <a href=\"https://nulled.red/@amic\" class=\"u-url mention\">@<span>amic</span></a> finds mentions url https://nulled.red/@amic, so gets acct amic@nulled.red and displays @amic@nulled.red
  • <a href=\"https://be.cutewith.me/users/alayna\" class=\"u-url mention\">@<span>alayna</span></a> finds mentions url https://be.cutewith.me/users/alayna (note the Pleroma format of link), so gets acct alayna@be.cutewith.me and displays @alayna@be.cutewith.me

@trwnh
Copy link
Author

trwnh commented Sep 4, 2019

misskey-to-mastodon actually should not matter, right? https://mastodon.social/api/v1/statuses/100305188921872645

content: "<p><a href=\"https://mastodon.social/users/trwnh\" rel=\"nofollow noopener\" target=\"_blank\">@trwnh@mastodon.social</a> <br><a href=\"https://glitch.social/users/KitRedgrave\" rel=\"nofollow noopener\" target=\"_blank\">@KitRedgrave@glitch.social</a> <br><a href=\"https://misskey.xyz/@KitRedgrave@misskey.xyz\" rel=\"nofollow noopener\" target=\"_blank\">@KitRedgrave@misskey.xyz</a> poll test direct<br></p><p><a href=\"https://misskey.xyz/notes/5b3a1f260aa4e96bf11c3187\" rel=\"nofollow noopener\" target=\"_blank\">【Misskeyで投票を見る】</a></p>"

Note that misskey authors outgoing mention as <a href=\"https://mastodon.social/users/trwnh\" rel=\"nofollow noopener\" target=\"_blank\">@trwnh@mastodon.social</a> which still includes mention url https://mastodon.social/@trwnh

@tateisu
Copy link
Owner

tateisu commented Sep 4, 2019

misskey changes behavior in between v10 ages. but ST supports some old age.

@trwnh
Copy link
Author

trwnh commented Sep 4, 2019 via email

@tateisu
Copy link
Owner

tateisu commented Sep 5, 2019

please wait until I finished my other job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants