Skip to content

Commit

Permalink
Fix #597
Browse files Browse the repository at this point in the history
  • Loading branch information
duogenesis committed Jan 5, 2025
1 parent 0ecae9a commit 7343ebd
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 21 deletions.
26 changes: 23 additions & 3 deletions migrations.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
-- TODO: Delete
CREATE INDEX IF NOT EXISTS idx__messaged__object_person_id__subject_person_id__created_at
ON messaged(object_person_id, subject_person_id, created_at);
UPDATE
person
SET
verification_level_id =
CASE
WHEN
EXISTS (
SELECT
1
FROM
photo
WHERE
person_id = person.id
AND
verified
)
THEN
3

DROP INDEX IF EXISTS idx__messaged__object_person_id__subject_person_id;
ELSE
2
END
WHERE
verification_level_id <> 1
1 change: 1 addition & 0 deletions service/person/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ def delete_profile_info(req: t.DeleteProfileInfo, s: t.SessionInfo):
if files_params:
with api_tx() as tx:
tx.executemany(Q_DELETE_PROFILE_INFO_PHOTO, files_params)
tx.executemany(Q_UPDATE_VERIFICATION_LEVEL, files_params)

if audio_files_params:
with api_tx() as tx:
Expand Down
36 changes: 34 additions & 2 deletions test/functionality1/profile-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ test_verification_loss_ethnicity () {
where uuid = '$USER_UUID' and not verified_ethnicity")" -eq 1 ]]
}
test_verification_loss_photo () {
test_verification_loss_photo_changed () {
jc PATCH /profile-info \
-d "{
\"base64_file\": {
Expand Down Expand Up @@ -271,6 +271,37 @@ test_verification_loss_photo () {
where uuid = '$USER_UUID' and verification_level_id = 2")" -eq 1 ]]
}
test_verification_loss_photo_removed () {
jc PATCH /profile-info \
-d "{
\"base64_file\": {
\"position\": 1,
\"base64\": \"${img1}\",
\"top\": 0,
\"left\": 0
}
}"
q "update photo set verified = TRUE"
q "
update person
set verified_age = true,
verified_gender = true,
verification_level_id = 3"
[[ "$(q "select COUNT(*) from photo where verified")" -eq 1 ]]
[[ "$(q "
select COUNT(*) from person \
where uuid = '$USER_UUID' and verification_level_id = 3")" -eq 1 ]]
jc DELETE /profile-info -d '{ "files": [1] }'
[[ "$(q "select COUNT(*) from photo where verified")" -eq 0 ]]
[[ "$(q "
select COUNT(*) from person \
where uuid = '$USER_UUID' and verification_level_id = 2")" -eq 1 ]]
}
test_set name "Jeff"
test_set about "I'm a bad ass motherfuckin' DJ / This is why I walk and talk this way"
test_set gender Woman
Expand Down Expand Up @@ -309,4 +340,5 @@ test_theme
test_verification_loss_gender
test_verification_loss_ethnicity
test_verification_loss_photo
test_verification_loss_photo_changed
test_verification_loss_photo_removed
16 changes: 0 additions & 16 deletions test/functionality2/photo-triggers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ jc PATCH /profile-info \
[[ "$(q "select count(*) from onboardee_photo")" == "0" ]]
[[ "$(q "select count(*) from undeleted_photo")" == "1" ]]

echo Delete the first photo
jc DELETE /profile-info -d '{ "files": [1] }'

[[ "$(q "select count(*) from photo")" == "3" ]]
[[ "$(q "select count(*) from person where has_profile_picture_id = 1")" == "2" ]]
[[ "$(q "select count(*) from onboardee_photo")" == "0" ]]
[[ "$(q "select count(*) from undeleted_photo")" == "2" ]]

echo Change and delete photos during onboarding
q "delete from banned_person"
q "delete from duo_session"
Expand Down Expand Up @@ -105,14 +97,6 @@ jc PATCH /onboardee-info \
[[ "$(q "select count(*) from onboardee_photo")" == "2" ]]
[[ "$(q "select count(*) from undeleted_photo")" == "1" ]]

echo Delete the first onboardee photo
jc DELETE /onboardee-info -d '{ "files": [1] }'

[[ "$(q "select count(*) from photo")" == "2" ]]
[[ "$(q "select count(*) from person where has_profile_picture_id = 1")" == "1" ]]
[[ "$(q "select count(*) from onboardee_photo")" == "1" ]]
[[ "$(q "select count(*) from undeleted_photo")" == "2" ]]

echo Self-deleted account
q "delete from banned_person"
q "delete from duo_session"
Expand Down

0 comments on commit 7343ebd

Please sign in to comment.