-
Notifications
You must be signed in to change notification settings - Fork 19
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
V2 Conversation Database #1150
base: main
Are you sure you want to change the base?
V2 Conversation Database #1150
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
use super::Sqlite; | ||
use super::{ | ||
db_connection::DbConnection, | ||
schema::consent_records::{self, dsl}, |
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.
The import statement incorrectly references consent_records
instead of v2_conversations
. To align with the table being used in this file, please update the import to:
schema::v2_conversations::{self, dsl},
This change will ensure proper access to the correct table schema and avoid potential compilation errors or runtime issues.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
topic TEXT NOT NULL PRIMARY KEY, | ||
created_at_ns BIGINT NOT NULL, | ||
peer_address TEXT NOT NULL, | ||
envelope_bytes BLOB NOT NULL |
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.
The most expensive thing about listing v2 conversations is decrypting this envelope.
What if we actually stored the plaintext here so it only has to happen once?
pub fn insert_or_replace_v2_conversation(&self, v2_conversation: StoredV2Conversation) -> Result<StoredV2Conversation, StorageError> { | ||
tracing::info!("Trying to insert v2 conversation"); | ||
let stored_v2_conversation = self.raw_query(|conn| { | ||
let maybe_inserted_conversation: Option<StoredV2Conversation> = diesel::insert_into(dsl::v2_conversations) |
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 this is using on_conflict_do_nothing
then it's actually an "insert or ignore" not an "insert or replace"
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.
There is also a helpful Diesel helper function insert_or_ignore_into
|
||
if maybe_inserted_conversation.is_none() { | ||
let existing_conversation: StoredV2Conversation = dsl::v2_conversations.find(v2_conversation.topic).first(conn)?; | ||
if existing_conversation.topic == v2_conversation.topic { |
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 are looking this up by topic, I don't see why you would need this check
We need to store v2 conversations in the V3 database so that we can easily look up to see if a group dm should be shown or not.