-
Notifications
You must be signed in to change notification settings - Fork 40
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
✨ Add WebFinger / ActivityPub avatar provider #140
base: main
Are you sure you want to change the base?
✨ Add WebFinger / ActivityPub avatar provider #140
Conversation
1c577e3
to
cef80ca
Compare
Interesting idea, but I'm not sure this "fetch webfinger first, if it doeesn't exist, fetch gravatar" logic is understandable from the UI. It would also be nice if you could update the tests to include this change. :) (If you want to update the API documentation, it's here, but I could do this as well.) |
hm I don't quite know how to improve the UI, do you think a radio button to select the avatar provider would be good? |
This patch updates the database schema in preparation for supporting more avatar providers. It adds a new per user avatar_provider column and renames the email column to avatar to allow more generic input which will be interpreted depending on the provider.
This patch starts preparing the user interface for supporting multiple avatar providers by adding the ability to edit these values in the edit form and updating the user overview page. It also introduces an avatar provider enum currently only containing gravatar.
0daf3ae
to
0ed9176
Compare
This patch introduces a new avatar provider based on the changes from the previous two commits. The WebFinger / ActivityPub provider ("webfinger" internally) interprets the avatar field in a user either as an RFC 7565 acct URI or, if it does not contain an "@" symbol, a RFC 3986 host string. Based on this it will contact the host and query the WebFinger endpoint. If the WebFinger response contains an avatar relation, the link contained in that relation will used. In most cases howeve, for example when querying a Mastodon, Akkoma or Calckey user, the WebFinger response will not contain such a link. Then, the provider will look for an ActivityPub actor using an "application/activity+json" link in the WebFinger response. This patch implements two strategies for obtaining an URL for the avatar image of an ActivityPub actor: With no additional information given, mete will try to contact the hosting server directly. This might fail for various reasons such as missing request authentication or signature. Given a Mastodon client access token, mete will contact the according Mastodon server and ask it for the profile picture of the actor. Note that depending on the server's settings, this might cause the profile picture to be fetched from the server's cache instead of the actor's server directly. The results of these lookups will be cached for one day and can be invalidated by updating the user from the UI.
0ed9176
to
20a2112
Compare
In addition to the UI changes we discussed last time, I've basically rewritten the entire fetching to be a lot more robust and support for having a mastodon server fetch the user on behalf of us. With that comes an access token and url that need to be configured, I've done my best to implement this but I don't think it actually works in production - how would I implement such a config value properly? |
Thanks for putting this much work into it – and sorry for taking so long to look at it. The first two commits look great. And, most importantly: This breaks the API (and the tests checking the API). |
This pull request introduces a new avatar provider system and a new provider.
The WebFinger / ActivityPub provider (
webfinger
internally) interprets the avatar field in a user either as an RFC 7565 acct URI or, if it does not contain an@
symbol, a RFC 3986 host string.Based on this it will contact the host and query the WebFinger endpoint.
If the WebFinger response contains an avatar relation, the link contained in that relation will used.
In most cases however, for example when querying a Mastodon, Akkoma or Calckey user, the WebFinger response will not contain such a link. Then, the provider will look for an ActivityPub actor using an
application/activity+json
link in the WebFinger response.This pull request implements two strategies for obtaining an URL for the avatar image of an ActivityPub actor:
With no additional information given, mete will try to contact the hosting server directly. This might fail for various reasons such as missing request authentication or signature.
Given a Mastodon client access token, mete will contact the according Mastodon server and ask it for the profile picture of the actor. Note that depending on the server's settings, this might cause the profile picture to be fetched from the server's cache instead of the actor's server directly.
The results of these lookups will be cached for one day and can be invalidated by updating the user from the UI.