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

Missing event subject #16142

Merged
merged 1 commit into from
May 21, 2024
Merged

Missing event subject #16142

merged 1 commit into from
May 21, 2024

Conversation

ncounter
Copy link
Contributor

@ncounter ncounter commented May 16, 2024

Every subscribable Event has its own subject (for RSS and Email) implementation.

@github-actions github-actions bot added the Frontend Things related to the OBS RoR app label May 16, 2024
@ncounter ncounter marked this pull request as ready for review May 16, 2024 09:41
Copy link
Member

@hennevogel hennevogel left a comment

Choose a reason for hiding this comment

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

You should check for which events we send emails/rss...

@ncounter
Copy link
Contributor Author

You should check for which events we send emails/rss...

I thought about that but still, I wouldn't mind to have a fallback already implemented.
It's part of the interface they should implement by default to me.
Does that harm?

@hennevogel
Copy link
Member

I thought about that but still, I wouldn't mind to have a fallback already implemented.
It's part of the interface they should implement by default to me.

What interface? There is no interface to those that requires a subject. Or you mean the interface that might or might not exist in some future?

Does that harm?

Sure. It's unused code without purpose. It will confuse people.

@ncounter
Copy link
Contributor Author

I thought about that but still, I wouldn't mind to have a fallback already implemented.
It's part of the interface they should implement by default to me.

What interface? There is no interface to those that requires a subject. Or you mean the interface that might or might not exist in some future?

Does that harm?

Sure. It's unused code without purpose. It will confuse people.

The whole module Event (e.g.: Event > Base > Build > BuildSuccess) behaves like a chain of interfaces or so, they just don't have implementation requirements.

Anyway, as long as it is not enforced, let's stick to the ones that are currently used only.

@saraycp
Copy link
Contributor

saraycp commented May 17, 2024

I thought about that but still, I wouldn't mind to have a fallback already implemented.

In such case, I'd propose implementing the subject method in the parent class without a message but with: raise AbstractMethodCalled.

As we already do in other STI parent classes like ScmPayload.

@ncounter
Copy link
Contributor Author

I thought about that but still, I wouldn't mind to have a fallback already implemented.

In such case, I'd propose implementing the subject method in the parent class without a message but with: raise AbstractMethodCalled.

As we already do in other STI parent classes like ScmPayload.

That works for me 👍

@hennevogel , @saraycp
After looking at how we send emails, in my understanding we do not filter events by any type in order to decide to send it or not. For instance, we do for web and RSS (see here), but there is nothing like that when sending email. So potentially all Events can become an email, even if they are just meant to be STI parent classes of more specific event types.
I initially implemented a fallback subject text for STI parents, but raising the missing implementation sounds even better to me: it doesn't require maintenance and it would warn us in case we misuse Event classes.

I adapted the code accordingly. Feel free to take a look again. Thank you

@hennevogel
Copy link
Member

So potentially all Events can become an email...

Nope, only the ones we allow to create subscriptions for...

src/api/app/models/event/build_unchanged.rb Outdated Show resolved Hide resolved
src/api/app/models/event/container_published.rb Outdated Show resolved Hide resolved
src/api/app/models/event/create_report.rb Outdated Show resolved Hide resolved
src/api/app/models/event/delete_package.rb Outdated Show resolved Hide resolved
src/api/app/models/event/delete_project.rb Outdated Show resolved Hide resolved
src/api/app/models/event/update_package.rb Outdated Show resolved Hide resolved
src/api/app/models/event/update_project.rb Outdated Show resolved Hide resolved
src/api/app/models/event/update_project_config.rb Outdated Show resolved Hide resolved
src/api/app/models/event/upload.rb Outdated Show resolved Hide resolved
src/api/app/models/event/version_change.rb Outdated Show resolved Hide resolved
@saraycp
Copy link
Contributor

saraycp commented May 17, 2024

@hennevogel what do you mean by "we don't allow subscriptions...". Is there any control/limitation in the code?
We don't create events for those classes but for their "children" classes, it seems it's a developer decision, I can't find the code that prevent us to do it.

I found it, sorry for the noise:

@ncounter
Copy link
Contributor Author

ncounter commented May 17, 2024

@hennevogel I addressed all your comments by dropping the undesired subject implementation. (cc @saraycp @eduardoj )
Please take a final round of review, thank you

src/api/app/models/event/relationship_create.rb Outdated Show resolved Hide resolved
src/api/app/models/event/relationship_delete.rb Outdated Show resolved Hide resolved
@ncounter ncounter force-pushed the events-subject branch 4 times, most recently from 054de73 to 63beb29 Compare May 20, 2024 09:38
@ncounter ncounter requested a review from hennevogel May 21, 2024 07:44
@@ -3,6 +3,10 @@ class ReportForPackage < Report
self.description = 'Report for a package created'
payload_keys :package_name, :project_name

def subject
Copy link
Member

Choose a reason for hiding this comment

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

I'd love to see by whom here but that needs some refactoring first...

@hennevogel hennevogel merged commit e12a64e into openSUSE:master May 21, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Things related to the OBS RoR app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants