barely working
This commit is contained in:
@@ -479,10 +479,6 @@ async function insertContact(userUsername, receiverUsername, read) {
|
||||
((SELECT user_id FROM Accounts WHERE username = $1),
|
||||
(SELECT user_id FROM Accounts WHERE username = $2),
|
||||
$3,
|
||||
CURRENT_TIMESTAMP),
|
||||
((SELECT user_id FROM Accounts WHERE username = $2),
|
||||
(SELECT user_id FROM Accounts WHERE username = $1),
|
||||
$3,
|
||||
CURRENT_TIMESTAMP)
|
||||
ON CONFLICT DO NOTHING;
|
||||
`;
|
||||
@@ -515,22 +511,21 @@ async function getContacts(userUsername) {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteContact(userUsername, contactUsername) {
|
||||
async function deleteContact(user_id, contact_id) {
|
||||
const query = `
|
||||
DELETE FROM Contacts
|
||||
WHERE (user_id = $1 AND contact_user_id = $2)
|
||||
OR (user_id = $2 AND contact_user_id = $1);
|
||||
WHERE (user_id = $1 AND contact_id = $2)
|
||||
`;
|
||||
|
||||
try {
|
||||
const result = await client.query(query, [userUsername, contactUsername]);
|
||||
const result = await client.query(query, [user_id, contact_id]);
|
||||
if (result.rowCount === 0) {
|
||||
console.log("No matching contact found with:", {
|
||||
userUsername,
|
||||
contactUsername,
|
||||
user_id,
|
||||
contact_id,
|
||||
});
|
||||
} else {
|
||||
console.log("Successfully deleted contact for: ", contactUsername);
|
||||
console.log("Successfully deleted contact for: ", user_id);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to remove contact ", e);
|
||||
|
||||
Reference in New Issue
Block a user