Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #559 Permanent Deletion of consent records #560

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions internal/dataagreement_record/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,11 @@ func (darRepo *DataAgreementRecordRepository) GetByDataAgreementIdandIndividualI
}

// Deletes all the data agreement records of individual
func (darRepo *DataAgreementRecordRepository) DeleteAllRecordsForIndividual(individualId string) error {
func (darRepo *DataAgreementRecordRepository) DeleteAllRecordsForIndividual(individualId string, organisationId string) error {

filter := common.CombineFilters(darRepo.DefaultFilter, bson.M{"individualid": individualId})
filter := bson.M{"organisationid": organisationId, "individualid": individualId}

// Update to set IsDeleted to true
update := bson.M{
"$set": bson.M{
"isdeleted": true,
},
}

_, err := Collection().UpdateMany(context.TODO(), filter, update)
_, err := Collection().DeleteMany(context.TODO(), filter)

return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func ServiceDeleteIndividualDataAgreementRecords(w http.ResponseWriter, r *http.
darRepo := daRecord.DataAgreementRecordRepository{}
darRepo.Init(organisationId)

err := darRepo.DeleteAllRecordsForIndividual(individualId)
err := darRepo.DeleteAllRecordsForIndividual(individualId, organisationId)
if err != nil {
m := "Failed to delete data agreement records for individual"
common.HandleErrorV2(w, http.StatusInternalServerError, m, err)
Expand Down