thanks again Daniel, as i understood anyone can use addCategory function to add category right?
if it is then how it can be restricted to contract owner only?
another question i made a donation button on every post then i tried to make a similar function as Votes named Donates but instead of adding +1 to every click adds donate amount to table for every post,i copy pasted vote functionā¦code below doesnt work when i call it and add nothing to donates table i also added listenerā¦ you have any idea on this? it would be great help
event Donated (bytes32 indexed postId, address indexed postOwner, address indexed donator, uint80 postDonations);
struct post {
address postOwner;
bytes32 parentPost;
bytes32 contentId;
int40 votes;
bytes32 categoryId;
uint80 donates;
}
function donate (bytes32 _postId, uint80 _donationAdded) external
{
address _donator = msg.sender;
bytes32 _category = postRegistry[_postId].categoryId;
address _contributor = postRegistry[_postId].postOwner;
require (postRegistry[_postId].postOwner != _donator, "you cannot donate your posts");
postRegistry[_postId].donates += _donationAdded;
emit Donated(_postId, _contributor, _donator, postRegistry[_postId].donates);
}
function getPost(bytes32 _postId) public view returns(address, bytes32, bytes32, int72, bytes32, uint80) {
return (
postRegistry[_postId].postOwner,
postRegistry[_postId].parentPost,
postRegistry[_postId].contentId,
postRegistry[_postId].votes,
postRegistry[_postId].categoryId,
postRegistry[_postId].donates);
}