When users delete (burn) their dating profiles, their likes and matches stay in the system, causing problems because this left-over data creates confusion in the platform.
contract SoulboundProfileNFT {
function burnProfile() external {
uint256 tokenId = profileToToken[msg.sender];
require(tokenId != 0, "No profile found");
require(ownerOf(tokenId) == msg.sender, "Not profile owner");
_burn(tokenId);
delete profileToToken[msg.sender];
delete _profiles[tokenId];
emit ProfileBurned(msg.sender, tokenId);
}
}
contract LikeRegistry {
mapping(address => mapping(address => bool)) public likes;
mapping(address => address[]) public matches;
}
contract LikeRegistry {
SoulboundProfileNFT public profileNFT;
event LikeHistoryCleared(address indexed user);
event MatchCleared(address indexed user1, address indexed user2);
function clearProfileHistory(address burnedProfile) external {
require(msg.sender == address(profileNFT), "Only NFT contract");
for(uint i = 0; i < matches[burnedProfile].length; i++) {
address likedUser = matches[burnedProfile][i];
likes[burnedProfile][likedUser] = false;
if(likes[likedUser][burnedProfile]) {
likes[likedUser][burnedProfile] = false;
removeFromMatches(burnedProfile, likedUser);
removeFromMatches(likedUser, burnedProfile);
emit MatchCleared(burnedProfile, likedUser);
}
}
delete matches[burnedProfile];
emit LikeHistoryCleared(burnedProfile);
}
function removeFromMatches(address user1, address user2) internal {
address[] storage userMatches = matches[user1];
for(uint i = 0; i < userMatches.length; i++) {
if(userMatches[i] == user2) {
userMatches[i] = userMatches[userMatches.length - 1];
userMatches.pop();
break;
}
}
}
}
contract SoulboundProfileNFT {
function burnProfile() external {
uint256 tokenId = profileToToken[msg.sender];
require(tokenId != 0, "No profile found");
require(ownerOf(tokenId) == msg.sender, "Not profile owner");
likeRegistry.clearProfileHistory(msg.sender);
_burn(tokenId);
delete profileToToken[msg.sender];
delete _profiles[tokenId];
emit ProfileBurned(msg.sender, tokenId);
}
}