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

Notifications sent twice on action #367

Open
kpsherva opened this issue Oct 2, 2023 · 2 comments
Open

Notifications sent twice on action #367

kpsherva opened this issue Oct 2, 2023 · 2 comments
Labels
bug Something isn't working question Further information is requested

Comments

@kpsherva
Copy link
Contributor

kpsherva commented Oct 2, 2023

  1. make a inclusion request
  2. go to request detail page
  3. try to accept the request
  4. add comment in "Additional comments" box
  5. Click accept

Bug:
the mail is sent twice, once for accept, the second time for the additional comment.

See:
Screenshot 2023-10-02 at 11 40 59

@kpsherva kpsherva added the bug Something isn't working label Oct 2, 2023
@rekt-hard
Copy link
Contributor

Current state

The current simplified service flow when executing an action is as follows (code):

  • get the specific request action
  • execute the request action
  • if there is additional data (assuming it is only for comments)
    • create a comment

Most notifications are registered when executing an action. The additional data is not available there though. This means we can send the action notification but after that another comment notification may be registered as well.

Possible solutions

Introduce an attribute on the base request action

Similar to the log_event attribute, an attribute such as create_comment can be introduced. This attribute will then be checked in the base execute_action of the requests service before creating a comment

  • Since we usually override the request action for a notification, we can also specify this attribute.
  • In the action, we still would not have the additional data but at least we would not send the action notification and the comment notification on one action.
  • If there is a comment, the user/guest could checkout the request timeline, if interested.

Impact

This will have a rather small impact on the general application.

  • Specify the attribute with a default value of True
  • Adapt it for the current actions with notifications.

Move the creation of a comment to the base request action

Creation of the comment could be moved from the service to the request action. Additionally, the attribute for create_comment can be introduced as well, to allow easy configuration for the base method logic.

  • Since we usually override the request action for a notification, we can also specify this attribute.
  • We are able to include the comment in the respective action notification - thus only sending one notification with all the information.
  • Moving the creation of the comment to the request action would allow to further customize the action in the future. If the provided additional data will not always be a comment, it can be dealt with accordingly on the specific action level, where we should have enough context. Thus providing a lot of flexibility for the future.

Impact

This will have a large impact on the general application.

  • Specify the attribute with a default value of True
  • Adapt it for the current actions with notifications.
  • An additional function parameter has to be added to the execute action (explicit data=None, implicit **kwargs) and adapted for every subclass.
  • Move implementation from service to request action
  • Adapt calls (e.g. RequestActions, RequestService )

@rekt-hard rekt-hard removed their assignment Oct 5, 2023
@zzacharo zzacharo added the question Further information is requested label Oct 5, 2023
@rekt-hard
Copy link
Contributor

A possible solution would be to go with the attribute only first, to have a quick solution for the general issue.
Then follow up with moving the comment creation to the request action as a next step, as it would probably lead to braking changes and a new major version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants