feature/Make a new message is prepended to a previous one at table MappedConsent.note field

This commit is contained in:
Marko Milić 2025-07-15 21:23:06 +02:00
parent 3c4e6c4556
commit d4ce908f8b
2 changed files with 10 additions and 6 deletions

View File

@ -1139,13 +1139,14 @@ object Consent extends MdcLoggable {
By(MappedConsent.mConsumerId, consent.consumerId), // from the same TPP
).filterNot(_.consentId == consent.consentId) // Exclude current consent
.map{ c => // Set to terminatedByTpp
val note = s"|---> Changed status from ${c.status} to ${ConsentStatus.terminatedByTpp.toString} for consent ID: ${c.id}"
val message = s"|---> Changed status from ${c.status} to ${ConsentStatus.terminatedByTpp.toString} for consent ID: ${c.id}"
val newNote = s"$currentDate\n$message\n" + consent.note // Prepend to existing note if any
val changedStatus =
c.mStatus(ConsentStatus.terminatedByTpp.toString)
.mNote(s"$currentDate\n$note")
.mNote(newNote)
.mLastActionDate(new Date())
.save
if(changedStatus) logger.warn(note)
if(changedStatus) logger.warn(message)
changedStatus
}.forall(_ == true)
} else {

View File

@ -66,9 +66,10 @@ object ConsentScheduler extends MdcLoggable {
outdatedConsents.foreach { consent =>
Try {
val message = s"|---> Changed status from ${consent.status} to ${ConsentStatus.rejected} for consent ID: ${consent.id}"
val newNote = s"$currentDate\n$message\n" + consent.note // Prepend to existing note if any
consent
.mStatus(ConsentStatus.rejected.toString)
.mNote(s"$currentDate\n$message")
.mNote(newNote)
.mStatusUpdateDateTime(new Date())
.save
logger.warn(message)
@ -105,9 +106,10 @@ object ConsentScheduler extends MdcLoggable {
expiredConsents.foreach { consent =>
Try {
val message = s"|---> Changed status from ${consent.status} to ${ConsentStatus.expired} for consent ID: ${consent.id}"
val newNote = s"$currentDate\n$message\n" + consent.note // Prepend to existing note if any
consent
.mStatus(ConsentStatus.expired.toString)
.mNote(s"$currentDate\n$message")
.mNote(newNote)
.mStatusUpdateDateTime(new Date())
.save
logger.warn(message)
@ -136,9 +138,10 @@ object ConsentScheduler extends MdcLoggable {
expiredConsents.foreach { consent =>
Try {
val message = s"|---> Changed status from ${consent.status} to ${ConsentStatus.EXPIRED.toString} for consent ID: ${consent.id}"
val newNote = s"$currentDate\n$message\n" + consent.note // Prepend to existing note if any
consent
.mStatus(ConsentStatus.EXPIRED.toString)
.mNote(s"$currentDate\n$message")
.mNote(newNote)
.mStatusUpdateDateTime(new Date())
.save
logger.warn(message)