Add has_been_merged to DB

This commit is contained in:
Andras Schmelczer 2025-10-19 11:47:55 +01:00
parent de143f9033
commit 12aa457e3a
6 changed files with 28 additions and 6 deletions

View file

@ -77,6 +77,7 @@ pub async fn create_document(
is_deleted: false,
user_id: user.name,
device_id: device_id.0,
has_been_merged: false,
};
state

View file

@ -66,6 +66,7 @@ pub async fn delete_document(
is_deleted: true,
user_id: user.name,
device_id: device_id.0,
has_been_merged: false
};
state

View file

@ -120,11 +120,12 @@ pub async fn update_document(
)));
}
let merged_content = if is_file_type_mergable(&sanitized_relative_path)
let are_all_participants_mergable = is_file_type_mergable(&sanitized_relative_path)
&& !is_binary(&parent_document.content)
&& !is_binary(&latest_version.content)
&& !is_binary(&content)
{
&& !is_binary(&content);
let merged_content = if are_all_participants_mergable {
reconcile(
str::from_utf8(&parent_document.content)
.expect("parent must be valid UTF-8 because it's not binary"),
@ -177,6 +178,7 @@ pub async fn update_document(
is_deleted: false,
user_id: user.name,
device_id: device_id.0,
has_been_merged: are_all_participants_mergable && is_different_from_request_content,
};
state