|
@ -24,7 +24,7 @@ contract Forum { |
|
|
event UsernameUpdated(string newName, string oldName, address userAddress); |
|
|
event UsernameUpdated(string newName, string oldName, address userAddress); |
|
|
|
|
|
|
|
|
function signUp(string memory username) public returns (bool) { |
|
|
function signUp(string memory username) public returns (bool) { |
|
|
require (!hasUserSignedUp(msg.sender), USER_HAS_NOT_SIGNED_UP); |
|
|
require(!hasUserSignedUp(msg.sender), USER_HAS_NOT_SIGNED_UP); |
|
|
require(!isUserNameTaken(username), USERNAME_TAKEN); |
|
|
require(!isUserNameTaken(username), USERNAME_TAKEN); |
|
|
users[msg.sender] = User(username, new uint[](0), new uint[](0), block.timestamp, true); |
|
|
users[msg.sender] = User(username, new uint[](0), new uint[](0), block.timestamp, true); |
|
|
userAddresses[username] = msg.sender; |
|
|
userAddresses[username] = msg.sender; |
|
@ -33,7 +33,7 @@ contract Forum { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function updateUsername(string memory newUsername) public returns (bool) { |
|
|
function updateUsername(string memory newUsername) public returns (bool) { |
|
|
require (hasUserSignedUp(msg.sender), USER_HAS_NOT_SIGNED_UP); |
|
|
require(hasUserSignedUp(msg.sender), USER_HAS_NOT_SIGNED_UP); |
|
|
require(!isUserNameTaken(newUsername), USERNAME_TAKEN); |
|
|
require(!isUserNameTaken(newUsername), USERNAME_TAKEN); |
|
|
string memory oldUsername = getUsername(msg.sender); |
|
|
string memory oldUsername = getUsername(msg.sender); |
|
|
delete userAddresses[users[msg.sender].username]; |
|
|
delete userAddresses[users[msg.sender].username]; |
|
@ -44,7 +44,7 @@ contract Forum { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function getUsername(address userAddress) public view returns (string memory) { |
|
|
function getUsername(address userAddress) public view returns (string memory) { |
|
|
require (hasUserSignedUp(userAddress), USER_HAS_NOT_SIGNED_UP); |
|
|
require(hasUserSignedUp(userAddress), USER_HAS_NOT_SIGNED_UP); |
|
|
return users[userAddress].username; |
|
|
return users[userAddress].username; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -63,17 +63,17 @@ contract Forum { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function getUserTopics(address userAddress) public view returns (uint[] memory) { |
|
|
function getUserTopics(address userAddress) public view returns (uint[] memory) { |
|
|
require (hasUserSignedUp(userAddress), USER_HAS_NOT_SIGNED_UP); |
|
|
require(hasUserSignedUp(userAddress), USER_HAS_NOT_SIGNED_UP); |
|
|
return users[userAddress].topicIDs; |
|
|
return users[userAddress].topicIDs; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function getUserPosts(address userAddress) public view returns (uint[] memory) { |
|
|
function getUserPosts(address userAddress) public view returns (uint[] memory) { |
|
|
require (hasUserSignedUp(userAddress), USER_HAS_NOT_SIGNED_UP); |
|
|
require(hasUserSignedUp(userAddress), USER_HAS_NOT_SIGNED_UP); |
|
|
return users[userAddress].postIDs; |
|
|
return users[userAddress].postIDs; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function getUserDateOfRegister(address userAddress) public view returns (uint) { |
|
|
function getUserDateOfRegister(address userAddress) public view returns (uint) { |
|
|
require (hasUserSignedUp(userAddress), USER_HAS_NOT_SIGNED_UP); |
|
|
require(hasUserSignedUp(userAddress), USER_HAS_NOT_SIGNED_UP); |
|
|
return users[userAddress].timestamp; |
|
|
return users[userAddress].timestamp; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|