Skip to content

Commit

Permalink
Fix #571 Normalise the usage purpose before checking if it exists to …
Browse files Browse the repository at this point in the history
…avoid duplication
  • Loading branch information
albinpa authored and georgepadayatti committed Nov 15, 2023
1 parent fbc0aae commit d8e742d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"strings"

"github.com/bb-consent/api/internal/common"
"github.com/bb-consent/api/internal/config"
Expand Down Expand Up @@ -274,7 +275,7 @@ func ConfigCreateDataAgreement(w http.ResponseWriter, r *http.Request) {
darepo := dataagreement.DataAgreementRepository{}
darepo.Init(organisationId)

count, err := darepo.CountDocumentsByPurpose(dataAgreementReq.DataAgreement.Purpose)
count, err := darepo.CountDocumentsByPurpose(strings.TrimSpace(dataAgreementReq.DataAgreement.Purpose))
if err != nil {
m := "Failed to count data agreement by purpose"
common.HandleErrorV2(w, http.StatusNotFound, m, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"strings"

"github.com/bb-consent/api/internal/common"
"github.com/bb-consent/api/internal/config"
Expand Down Expand Up @@ -167,7 +168,7 @@ func ConfigUpdateDataAgreement(w http.ResponseWriter, r *http.Request) {
daRepo := dataagreement.DataAgreementRepository{}
daRepo.Init(organisationId)

count, err := daRepo.CountDocumentsByPurposeExeptOneDataAgreement(dataAgreementReq.DataAgreement.Purpose, dataAgreementId)
count, err := daRepo.CountDocumentsByPurposeExeptOneDataAgreement(strings.TrimSpace(dataAgreementReq.DataAgreement.Purpose), dataAgreementId)
if err != nil {
m := "Failed to count data agreements by purpose"
common.HandleErrorV2(w, http.StatusNotFound, m, err)
Expand Down

0 comments on commit d8e742d

Please sign in to comment.