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

Ensure the Craft plugin's create/update/delete web hooks work with new plugin workflow/design (triggered by Canto) #31

Open
ericdrosas87 opened this issue Mar 27, 2023 · 4 comments

Comments

@ericdrosas87
Copy link
Contributor

Check out the controller class for context, should be much much more straightforward with the new approach.

@khalwat
Copy link
Collaborator

khalwat commented Apr 14, 2023

Specifically where do they need to hook in? I did look over the controller code, but can you explain what we're trying to accomplish here?

If an asset is deleted or added via Canto, we want to take some kind of action on our end?

Since we're not planning to sync them anymore, what action should be taken here?

@ericdrosas87
Copy link
Contributor Author

ericdrosas87 commented Apr 14, 2023

So currently there are create, update, and delete endpoints in the controller class. create is currently used by the damAsset modal for uploading a new image and embedding the data in the content and plugin metadata tables. delete is used for when a content creator choose to remove a damAsset or replaces it. Which is to say these endpoints are currently no longer called by the Canto webhook requestor.

I can see the update endpoint being used as a webhook endpoint to ensure that metadata such as alt text, descriptions, photo credits, etc. can be updated in Canto and the associated JSON metadata/URL can be updated accordingly. I also see the delete endpoint also being used as a webhook endpoint for removing Craft data when the associated Canto asset is deleted.

Does that help?

@khalwat
Copy link
Collaborator

khalwat commented Apr 19, 2023

So if I'm understanding you correctly... if an asset is modified in Canto (such as editing the alt text), you want it to execute a webhook that will cause any fields that use that asset to update the associated metadata?

So on our end, we'd need to search through all DAM Asset Picker fields to find ones that match the Canto Asset ID, and update them with the latest data.

I do have a question about this though... since it's a headless site, would you then also want to trigger a new build, or is this overkill for syncing the data with Canto?

If it's overkill, another option could be that whenever an entry is saved that has a DAM Asset Picker field in it, it always fetches the latest metadata.

This would lazily keep the data in the CMS in sync with the data in Canto, and while it requires an additional step, saving that Entry would presumably hook in to whatever build/deployment system you have then take care of that end of things.

Thoughts?

@ericdrosas87
Copy link
Contributor Author

Per our conversation via Google Meet:

The webhook endpoints may or may not be needed with the now workflow. If we move in the direction of server-side rendering with Next.js then retaining them may make sense, if we also explicitly trigger new builds upon receiving updates/deletes from Canto. Otherwise, it may make more sense to switch to a check-Canto-for-metadata-updates upon saving an entry workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants