android icon indicating copy to clipboard operation
android copied to clipboard

[FR] allow relative URL to /media file in clickAction (of notifications)

Open HIT2022 opened this issue 4 years ago • 15 comments

On Android, is it possible to click through a notification, to display a media file located within the /media directory? This could already be supported, but I haven't been able to do so successfully.

With, for example:

        "image": "/media/local/amazon_order_2021-08-03_XXXX.jpg",
        "clickAction": "/media/local/amazon_order_2021-08-03_XXXX.jpg"

The notification image displays fine, but a click leads to a 401: Unauth response (in the Companion app).

HIT2022 avatar Aug 09 '21 21:08 HIT2022

This is already supported and documented https://companion.home-assistant.io/docs/notifications/notification-attachments#media_source-recommended

For help reach out on forums or discord, there is also a troubleshooting section on the docs site as well.

dshokouhi avatar Aug 09 '21 22:08 dshokouhi

I did see that relative URLs to /media were already documented for use w/ image attachments -- but as I described, "/media/local/" is not working w/ tap to open a URL (via clickAction). I'll ask for input in the forums.

HIT2022 avatar Aug 10 '21 15:08 HIT2022

Re-opening this request per discussion in: https://community.home-assistant.io/t/how-to-open-media-image-via-relative-url-in-clickaction/328792

dshokouhi avatar Aug 17 '21 17:08 dshokouhi

Looks like /media does not like the authorization provided by the authenticated webview which is strange. Might need to add the auth header in this case unless its something that should be handled by HA core as the webview is already authenticated.

dshokouhi avatar Aug 17 '21 17:08 dshokouhi

Any further info on where this needs to be fixed?

brubaked avatar Dec 02 '21 03:12 brubaked

Any further info on where this needs to be fixed?

we need to either add the special kind of auth to the app here: https://github.com/home-assistant/android/blob/master/app/src/main/java/io/homeassistant/companion/android/util/NotificationActionContentHandler.kt

or determine if this is a core issue that should be resolved in HA core. IMHO authenticated webview should be good enough here.

dshokouhi avatar Dec 02 '21 03:12 dshokouhi

Looks like /media does not like the authorization provided by the authenticated webview which is strange. Might need to add the auth header in this case unless its something that should be handled by HA core as the webview is already authenticated.

I would like to respectfully suggest that /Media should not be the recommended location for storing notification images in the docs, since clickaction appears not to be functional for that directory. At least for me the docs are confusing because the /www location is claimed to be "open to the internet" but isnt this just a folder on my personal mobile device? My own HA instance isnt exposed to the net.

braddo99 avatar Jan 31 '24 02:01 braddo99

My own HA instance isnt exposed to the net.

The feature will never work in that case. Images need to be remotely accessible from the server.

The docs are fine as they also include iOS which does support it AFAIK. This is just a feature that needs to be implemented.

dshokouhi avatar Jan 31 '24 02:01 dshokouhi

Thanks for the response, appreciated. I respectfully disagree. It's a bug in the recommended method but you pointed out above that it is broken somehow. Bugs are normal and fine! I do think it raises the priority to either change the docs (there are already differences in behavior for iOS amd Android) or fix the bug.

Then on the feature not working in any case, you would be in the best position to know, but I've seen people reporting it does work and I dont know why it wouldn't. The file has already been sent to the device, so showing it could/should be straightforward and not involve the server.

braddo99 avatar Jan 31 '24 12:01 braddo99

With frigate's API allowing for accessing snapshots/clips it is noticeable when a generic camera device doesn't have the same functionality when it comes to accessing media. And since it seems that this works in iOS, would this then be classified as a fragmentation in functionality and therefore be a bug?

crowbarsolutions avatar Apr 16 '24 04:04 crowbarsolutions