Giter VIP home page Giter VIP logo

Comments (6)

davidacampos avatar davidacampos commented on May 26, 2024

Also, it would be great if we could replace to the thumbnail URL directly, instead of having to get the event ID, call, the API, then get the thumbnail image... same might apply to the image itself, as it seems the /api/events/{ID}/img is fairly slow compared to just pulling /storage/events/{GUID}.jpeg (understandable, as it's calling the DB and what not).

from last-watch-ai.

davidacampos avatar davidacampos commented on May 26, 2024

On second thought... another solution might be that instead of having randomly generated GUID used within /storage/events/GUID.jpeg, maybe using some simple hashing like MD5 or so based on the original file name (i.e. %image_file_name%), that way no need to call the API to get the storage location, as long as you already have the original filename

from last-watch-ai.

davidacampos avatar davidacampos commented on May 26, 2024

For anyone interested, for the comment above (about been able to get the direct image link, instead of a link that tries to "download" the image), I made a minor change in my local PayloadHelper.php and it's working great. I just added the following line before the "return $replaced;":

$replaced = str_replace('%image_path%', $event->imageFile->getPath(), $replaced);

This works great for my use case which is BI sending alert images to Last-Watch-AI, which then triggers a web-hook that triggers a push notification to a PWA. When the user clicks on the PWA's notification is a direct link to the Last-Watch_AI image that triggered the event. This is way faster than the /api/events/{ID}/img call

from last-watch-ai.

akmolina28 avatar akmolina28 commented on May 26, 2024

I actually have some changes in the dev branch to clean up the substitution variables and standardize them across the different automation types. The substitution code was pretty rushed so I'm not surprised that you found some gaps there. I'll see about adding some variables for direct jpg links for the event and the thumbnail rather than the resource url.

from last-watch-ai.

akmolina28 avatar akmolina28 commented on May 26, 2024

See acb73d2

Changed image_url to use the storage link instead of the resource link as you suggested. Added a new variable for the resource link which is still useful for embedding download links which retain the original file name.

I had already fixed the issues you described but I've been busy the last few weeks and haven't released it. Web request substitutions are fixed and tested, but I started adding substitutions for MQTT automations and I haven't written those tests yet. Once I write the tests for MQTT I'll do a new release. Until then you can pull dev if you want. I actually use the dev branch for my home automation and everything has been working fine.

Thanks for your support!

from last-watch-ai.

davidacampos avatar davidacampos commented on May 26, 2024

This is great, will pull the dev branch. Thanks!

from last-watch-ai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.