-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chainmail: implement save/unsave message #855 #856
base: main
Are you sure you want to change the base?
Conversation
…table definition out of the service mod
…ST handler rework for msg retrieval by id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of this doesn't belong in the mdbook, but instead belongs in a github issue.
In general, the doc updates should be split out from this chainmail save/unsave message implementation, lest you hold up the chainmail update for a much longer time than necessary. In fact, I'd recommend you split the doc updates themselves into many/multiple individual PRs so they can be independently reviewed on where the new docs get inserted and their content
params | ||
} | ||
|
||
fn get_where_clause_from_sender_receiver_params(params: HashMap<String, String>) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need "from_sender_receiver_params" in the function name, because it would already read get_where_clause(params)
so it's clear it's from the params
let mq: HttpRequest; | ||
// handle id param requests (for specific message) | ||
if params.contains_key("id") { | ||
where_clause = format!("WHERE CONCAT(receiver, rowid) = {}", params.get("id")?); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ID actually fixed? If the event database is pruned, then the email this refers to would probably shift. Probably better to just add an auto-incrementing ID field for each email.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rowid
is the event id, which is stable.
Transact::add_action_to_transaction( | ||
"save", | ||
&chainmail::action_structs::save { | ||
receiver: msg.receiver, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're saving a sent message, then it makes sense to save the receiver. If you're saving a received message, then it makes sense to save the sender. So you probably want to always save both sender + receiver.
archive: func(event-id: u64) -> result<_, error>; | ||
|
||
// Save an email | ||
save: func(event-id: u64) -> result<_, error>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing unsave
fn get_primary_key(&self) -> Self::PrimaryKey { | ||
self.event_id | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because you can't use #[primary_key] when the struct is split into a separate module?
#[event(history)] | ||
pub fn sent(sender: AccountNumber, receiver: AccountNumber, subject: String, body: String) {} | ||
#[event(history)] | ||
pub fn archive(event_id: String) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add an email id field, you can make this archive(account: AccountNumber, email_id: u64)
No description provided.