# Posts zome ## User stories - An agent should be able to post posts with string content of less than 1 MB of size - An agent should be able to update only the posts they created - Any should be able to query all posts made by an agent ## Entry structure This first anchor type is from [holochain_anchors](https://github.com/holochain/holochain_anchors) ```rust Entry "anchor" { struct Anchor { anchor_type: String, anchor_text: Option<String> } } Entry "post" { struct Post { agent_address: Address, content: String, timestamp: usize // Needs to be updated every time there is a new update } Links: { anchor->Post } } ``` Here there is a tradeoff, depending on how much we expect agents to update their posts. Two possibilities: 1) We create only one anchor per agent, and link to the first version of every post of that agent. ```rust { anchor_type: "posts", anchor_text: "<AGENT_ADDRESS>" } ``` Here the advantadge is that the number of anchors created is much less (one per agent) but the query to get the last version of the post will be slow (proportionate to the number of updates). 2) We create an anchor per each post that an agent makes and from that we add a link to the latest ```rust { anchor_type: "post_by_<AGENT_ADDRESS>", anchor_text: "<TIMESTAMP_OF_POST_CREATION>" } ``` Here the advantadge is that the query of the last post of any agent is much faster (we only do a `get_links` for the post anchor and `get_entry` of the last link) but we are going to create many more entries: one entry more per each post, and one link more per each update --- Without any more information about the users of the app and for simplicity, we'll go with 1). ## Entry relationship diagram ```mermaid graph TD subgraph postszome subgraph anchors all_posts-->alice_anchor all_posts-->bob_anchor end subgraph posts alice_anchor-->post1v0 post1v0==>post1v1 bob_anchor-->post2v0 end end ``` ## Validation ### Entries * `anchors`: * Create valid if the agent_address that is creating it is signing the entry * Update or Delete is not valid * `posts`: * Create, Update or Delete is valid if the agent_address that is creating it is signing the entry ### Links * `anchor->post`: * AddLink and RemoveLink: valid if the agent_addres in the anchor from which we are linking is signing the entry