Skip to content

Commit

Permalink
PIN-4727: Add notification for agreement upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
galales committed Mar 21, 2024
1 parent b2f376a commit d31cfcc
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import it.pagopa.interop.commons.utils.errors.ComponentError
import it.pagopa.interop.notifier.model.{AgreementPayload, MessageId, NotificationObjectType, NotificationPayload}
import it.pagopa.interop.notifier.service.impl.DynamoNotificationResourcesService
import cats.syntax.all._
import it.pagopa.interop.agreementmanagement.model.agreement.Draft
import it.pagopa.interop.notifier.service.converters.agreementsPartition

import scala.concurrent.{ExecutionContext, Future}
Expand Down Expand Up @@ -47,8 +48,10 @@ object AgreementEventsConverter {
}

private[this] def getEventNotificationPayload(event: Event): Option[NotificationPayload] = event match {
// Agreements are created with status Draft, and should not be notified
case _: AgreementAdded => None
// This event is emitted both on Draft creation and upgrade.
// Draft creation should not be notified
case AgreementAdded(a) if a.state != Draft =>
AgreementPayload(agreementId = a.id.toString(), eventType = EventType.ADDED.toString()).some
case AgreementUpdated(a) =>
AgreementPayload(agreementId = a.id.toString(), eventType = EventType.UPDATED.toString()).some
// Only agreements that have never been active can be deleted
Expand Down

0 comments on commit d31cfcc

Please sign in to comment.