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

feat: make card events compatible with webhook listener #6523

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

nicolashimmelmann
Copy link

  • Target version: main

Summary

This PR modifies the base class of the card events to make them compatible with the webhook_listeners (docs) app, that ships with the Nextcloud server. This is needed, to be able to build flows in Nextcloud Flow / Windmill that should get triggered when a card gets created/updated/deleted in a board.

Please let me know if tests or documentation are required.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Documentation (manuals or wiki) has been updated or is not required

@elzody
Copy link
Contributor

elzody commented Nov 19, 2024

thank you for working on this. it seems logical and looks like a pretty clean and simple solution. i only have one question regarding it, and maybe it's something also for @luka-nextcloud and @grnd-alt to chime in on:

  • for the lib/Event/CardUpdatedEvent.php, would this only return the serialized information for the updated card? it seems like it would not return serialized info on the card's old information as well. maybe it could then be overridden in the CardUpdatedEvent as well to return both. i think it makes sense to also give this information, what does everyone else think?

i'm also trying to think of the best way we can write tests for this. i'll see if some other apps have any reference material there for some ideas

@juliusknorr
Copy link
Member

would this only return the serialized information for the updated card? it seems like it would not return serialized info on the card's old information as well.

Iirc @blizzz worked on that in tables. Do you remember how we did it there?

@nicolashimmelmann
Copy link
Author

Thanks for the fast reply!

  • maybe it could then be overridden in the CardUpdatedEvent as well to return both.

You are right, from my experience building a flow using my current solution, it would have been handy to have the old information as well. However, then we should document it properly that the event payload differs in this case.

@blizzz
Copy link
Member

blizzz commented Nov 19, 2024

would this only return the serialized information for the updated card? it seems like it would not return serialized info on the card's old information as well.

Iirc @blizzz worked on that in tables. Do you remember how we did it there?

Please correct me if I mix up something.

The related PR in tables is nextcloud/tables#1101 and the specific commit is nextcloud/tables@2a6a338

I created the final, jsonserializable class OCA\Tables\Model\Public\Row (which is probably better called a Value Object or Data Transfer Object I suppose) which has the most basic Row information that is being serialized, and is otherwise decoupled from the rest of the logic. It contains both the current and the previous values.

This comment was marked as off-topic.

@elzody
Copy link
Contributor

elzody commented Dec 5, 2024

@nicolashimmelmann just checking to make sure everything is all good, did you need any help getting this finished up? no pressure, just wanted to check! :)

@nicolashimmelmann
Copy link
Author

nicolashimmelmann commented Dec 5, 2024

Sorry, I think it was a misunderstanding. I assumed you would first discuss internally about the best way to implement this to match the rest of the Nextcloud architecture. But if it is fine for you, I can pursue the implementation further based on the comment from blizzz above to match it to the tables implementation.

However, in that PR there was a check if the interface exists, to be able to support NC versions < 30. Should we adopt this approach for the Deck app as well?

EDIT: Nevermind, I see it is already at 31

@elzody
Copy link
Contributor

elzody commented Dec 9, 2024

Sounds good, sorry for the confusion there! Maybe it's possible I also did not understand. :) The check would probably be useful if we want this backported to previous versions, but odds are this will be released with 31 and therefore it won't need the check. Might change in the near future, but it would be easy to add the check in that case.

@nicolashimmelmann

Signed-off-by: nicolashimmelmann <[email protected]>
@nicolashimmelmann nicolashimmelmann force-pushed the feat/webhook-listener-compatible-events branch from 3caa656 to ac6a301 Compare December 9, 2024 23:51
@nicolashimmelmann
Copy link
Author

nicolashimmelmann commented Dec 9, 2024

Hi @elzody ,

I have now continued the implementation. Before I move on, it would be great if you could give me some quick feedback :)

  1. I left out the following fields compared to the DB model. Is that fine?

    • descriptionPrev: Will be replaced by a full previousVersion field in the CardUpdatedEvent
    • type: Left out since it is Marked as „for later use“ in documentation
    • attachments: Currently, no CardUpdatedEvent is fired for adding a new attachment. So no need to have them in the payload. User can call the API for attachments if needed.
    • attachmentCount: Same
    • notified: In the notification helper class it says this is used to be able to deliver due date notifications for users who have been added later to a board. So I assume this is only needed internally.
  2. Also, for consistency reasons all dates are returned as ISO8601. I did not like the mix between ISO and unix timestamps… Is that fine or should I use unix timestamps everywhere?

Thank you!

@juliusknorr
Copy link
Member

I left out the following fields compared to the DB model. Is that fine?

That sounds good 👍

Also, for consistency reasons all dates are returned as ISO8601. I did not like the mix between ISO and unix timestamps… Is that fine or should I use unix timestamps everywhere?

Yes, seems better with that.

Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me, just CI needs to pass then this would be good from my perspective

@stefan-niedermann
Copy link
Member

for consistency reasons all dates are returned as ISO8601. I did not like the mix between ISO and unix timestamps… Is that fine or should I use unix timestamps everywhere?

Just to be sure: Those changes do not affect the REST API model, correct?

@juliusknorr
Copy link
Member

Just to be sure: Those changes do not affect the REST API model, correct?

Yes, this model and separate json serialization is only used for the webhooks, no changes on the API side.

@elzody
Copy link
Contributor

elzody commented Jan 7, 2025

I would try running composer run cs:fix and it will probably fix whatever formatting errors it is complaining about. For the static analysis errors, you can run composer run psalm -- --no-cache and it will tell you what is happening.

Also looks good from me, just need to get the CI passing as Julius said.

@nicolashimmelmann
Copy link
Author

Thanks for your feedback. I will finish it soon and tag you when it's ready!

@nicolashimmelmann nicolashimmelmann force-pushed the feat/webhook-listener-compatible-events branch from 2179e03 to 40189e5 Compare January 10, 2025 23:51
@nicolashimmelmann nicolashimmelmann marked this pull request as draft January 10, 2025 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants