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

Fix validateIcon function for federation_icon_url #605

Open
otech47 opened this issue Jan 30, 2025 · 3 comments
Open

Fix validateIcon function for federation_icon_url #605

otech47 opened this issue Jan 30, 2025 · 3 comments

Comments

@otech47
Copy link
Collaborator

otech47 commented Jan 30, 2025

I noticed this behavior for the federation_icon_url meta field which is nice because it displays a little image box if the url is valid

However there is a discrepancy with the meta fields because technically federation_icon_url is not in the list of meta fields defined by Fedimint the protocol: https://github.com/fedimint/fedimint/tree/master/docs/meta_fields

So for the Fedi app we wanted to use a lot more meta fields and followed the guidance to namespace them with a fedi: prefix to future-proof them against collisions by other third party extensions

but fedi:federation_icon_url does not trigger the image preview so when making recommendations on how to manage meta for the best in-app experience, this creates some slight confusion/discrepancy

Image

Image

So I have 2 ideas

  1. should federation_icon_url be officially defined by the Fedimint protocol @elsirion ?
  2. regardless of the above I think it'd be a nice improvement to instead of having the validation be triggered by a specific field name, it can simply detect if any Value field has an https:: prefix + a png/jpg/svg suffix and trigger the image preview box. this would be useful for any other potential use of images in these meta fields so maybe that approach is cleaner?
@elsirion
Copy link
Contributor

should federation_icon_url be officially defined by the Fedimint protocol @elsirion ?

Let's do that.

regardless of the above I think it'd be a nice improvement to instead of having the validation be triggered by a specific field name, it can simply detect if any Value field has an https:: prefix + a png/jpg/svg suffix and trigger the image preview box.

That would give a false sense of "success" for cases where an image URL isn't "valid", like e.g. for more complex meta fields like Fedi mods. In an ideal world we'd have a schema language to describe the meta fields and would automatically build UI from that. I wonder how hard that would be to do with JSON Schema? That way we could load different "extensions" for e.g. Fedi meta fields without coupling the definitions too tightly to the Fedimint UI.

@otech47
Copy link
Collaborator Author

otech47 commented Jan 31, 2025

Yeah that makes sense. The automatically built UI will still need to 1) check some condition on the key or value of the meta field and 2) if condition is met, fetch and display an image preview.

@dpc actually made a good point that the image url fetch leaks privacy which might be interesting to think about

I can't think of many use cases where an image preview wouldn't be useful. I don't think there's much validation logic that indicates success in those UI components right now it is pretty loose but haven't looked closely at the code

@elsirion
Copy link
Contributor

The automatically built UI will still need to 1) check some condition on the key or value of the meta field and 2) if condition is met, fetch and display an image preview.

We could e.g. add a custom field to the JSON schema that tells us if an URL is expected to point to an image. If so we fetch the image and show an error if e.g. it isn't an image.

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