Skip to content

Commit

Permalink
PI-2774 Remove user check when looking up referrals (#4591)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl authored Jan 28, 2025
1 parent c549d07 commit 89962ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ class Event(
)

interface ReferralRepository : JpaRepository<Referral, Long> {
fun findByPersonIdAndCreatedByUserIdAndExternalReference(
personId: Long,
createdByUserId: Long,
externalRef: String
): Referral?
fun findByPersonIdAndExternalReference(personId: Long, externalRef: String): Referral?

@Query(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ class ReferralService(
val rTeam = teamRepository.getUnallocatedTeam(ap.probationArea.code)
val rStaff = staffRepository.getByCode(details.bookedBy.staffMember.staffCode)
val findReferral = {
referralRepository.findByPersonIdAndCreatedByUserIdAndExternalReference(
person.id,
ServiceContext.servicePrincipal()!!.userId,
EXT_REF_BOOKING_PREFIX + details.bookingId
)
referralRepository.findByPersonIdAndExternalReference(person.id, EXT_REF_BOOKING_PREFIX + details.bookingId)
}
findReferral() ?: run {
eventRepository.findForUpdate(event.id)
Expand Down Expand Up @@ -229,11 +225,7 @@ class ReferralService(
}

fun findReferral(person: Person, externalReference: String): Referral? =
referralRepository.findByPersonIdAndCreatedByUserIdAndExternalReference(
person.id,
ServiceContext.servicePrincipal()!!.userId,
externalReference
)
referralRepository.findByPersonIdAndExternalReference(person.id, externalReference)

fun getReferralDetails(crn: String, bookingId: String): ReferralDetail =
referralRepository.findReferralDetail(crn, EXT_REF_BOOKING_PREFIX + bookingId)?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,13 +593,8 @@ internal class ApprovedPremisesServiceTest {
null,
EXT_REF_BOOKING_PREFIX + bookingId,
)
whenever(
referralRepository.findByPersonIdAndCreatedByUserIdAndExternalReference(
person.id,
UserGenerator.AUDIT_USER.id,
EXT_REF_BOOKING_PREFIX + bookingId
)
).thenReturn(ref)
whenever(referralRepository.findByPersonIdAndExternalReference(person.id, EXT_REF_BOOKING_PREFIX + bookingId))
.thenReturn(ref)
return ref
}
}

0 comments on commit 89962ee

Please sign in to comment.