steve icon indicating copy to clipboard operation
steve copied to clipboard

Add new notification features

Open juherr opened this issue 2 years ago • 7 comments

Add new notification feature about ChargePoint, User and OccpTag create/update/delete.

The pull request is not yet finished because I'd like to add some other notifications (see TODO).

I have some doubt about the naming too.

juherr avatar Jun 23 '22 19:06 juherr

thanks for this! i know it's a draft, but here is the one thing that occurred to me after glancing over it:

there are too many dumb data holder classes who share similar fields and their only reason for existence is for the listener to catch them by the class name. can we unify them? something like:

@Data
public class ChargePointOperation {
  private final int chargeBoxPk;
  private final String chargeBoxId;
  private final NotificationFeature type;
}

and then the listener can be:

@EventListener(condition = "#notification.type == NotificationFeature.ChargePointDeleted")
public void chargePointDeleted(ChargePointOperation notification) {
   // do some cool logic
}

or, if we want to reduce spring magic:

@EventListener
public void chargePointDeleted(ChargePointOperation notification) {
    if (notification.type == NotificationFeature.ChargePointDeleted) {
        // do some cool logic
    }
}

goekay avatar Jun 23 '22 20:06 goekay

You're right about the type of notifications.

All notifications on the same item share the same description because I don't know yet what is helpful to set. I don't like adding NotificationFeature type in the class because it will allow having a tag feature on a charging station notification.

But I will try the following:

  • a generic notification with NotificationFeature type + int pk (the type determines the reference of the pk)
  • custom notifications when needed

It's a draft because not ready for merge but open to remarks :) Do you have some others?

Fyi, my next PR will be to add a WebhookNotificationService for a Slack (or other) integration

juherr avatar Jun 24 '22 08:06 juherr

About naming, what is the difference between OcppStation and ChargePoint?

juherr avatar Jun 24 '22 08:06 juherr

Ping @goekay Please, advice

juherr avatar Jul 06 '22 16:07 juherr

sorry, it fell under the radar.

About naming, what is the difference between OcppStation and ChargePoint?

nothing. i am, or was, not consistent with the notions :) both are used interchangeably.

goekay avatar Jul 07 '22 13:07 goekay

update: not dead but less free time on my side ;)

juherr avatar Sep 05 '22 19:09 juherr

Hi @juherr, I've experimented with adding webhooks that were called from NotificationService. It's a hack since the WebhookService was called from methods of MailService instead of NotificationService. I also got a chance to add some columns to the MySQL database for storing a single webhook link along with enable/disable flags. I need to clean it up and refactor it in a manner suitable for adding to SteVe's master. But, similarly, not dead but less free time :/

anirudh-ramesh avatar Sep 14 '22 12:09 anirudh-ramesh