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

✨ Add WebFinger / ActivityPub avatar provider #140

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

networkException
Copy link

@networkException networkException commented Jun 23, 2023

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 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 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.

image

image

image

@YtvwlD
Copy link
Member

YtvwlD commented Jun 27, 2023

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.)

@networkException
Copy link
Author

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.
@networkException networkException force-pushed the webfinger-activitypub-avatars branch 2 times, most recently from 0daf3ae to 0ed9176 Compare July 6, 2023 10:53
@networkException networkException changed the title ✨ Add webfinger / activitypub based avatars ✨ Add WebFinger / ActivityPub avatar provider Jul 6, 2023
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.
@networkException
Copy link
Author

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?

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

Successfully merging this pull request may close these issues.

None yet

2 participants