Skip to content
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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cool-ant
Copy link
Member

No description provided.

@cool-ant cool-ant changed the base branch from mm/chainmail-implement-archive to main September 23, 2024 15:38
@cool-ant cool-ant marked this pull request as draft September 23, 2024 15:44
Copy link
Member

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> {
Copy link
Member

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")?);
Copy link
Member

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.

Copy link
Collaborator

@swatanabe swatanabe Sep 27, 2024

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,
Copy link
Member

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>;
Copy link
Member

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
}
}
Copy link
Member

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) {}
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants