Skip to content

Commit

Permalink
Fix #559 Permanent Deletion of consent records
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa authored and georgepadayatti committed Nov 14, 2023
1 parent 993a4e9 commit 1550729
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
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

0 comments on commit 1550729

Please sign in to comment.