Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "vendor/sqldelight"]
path = vendor/sqldelight
url = https://github.com/MohamadJaara/sqldelight.git
branch = 2.2.1-with-custom-notify
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension

buildscript {
repositories {
maven(url = uri("$rootDir/vendor/sqldelight/build/localMaven"))
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:${libs.versions.agp.get()}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.get()}")
classpath("app.cash.sqldelight:gradle-plugin:${libs.versions.sqldelight.get()}")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:${libs.versions.dokka.get()}")
classpath("com.google.protobuf:protobuf-gradle-plugin:${libs.versions.protobufCodegen.get()}")
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${libs.versions.detekt.get()}")
Expand All @@ -40,6 +40,7 @@ buildscript {

repositories {
wireDetektRulesRepo()
maven(url = uri("$rootDir/vendor/sqldelight/build/localMaven"))
google()
mavenCentral()
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
Expand Down Expand Up @@ -121,6 +122,7 @@ val kaliumGitHash: Provider<String> = providers.environmentVariable("GITHUB_SHA"
allprojects {
version = kaliumGitHash.get()
repositories {
maven(url = uri("$rootDir/vendor/sqldelight/build/localMaven"))
google()
mavenCentral()
}
Expand Down
3 changes: 2 additions & 1 deletion data/persistence/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlin.serialization)
id(libs.plugins.sqldelight.get().pluginId)
alias(libs.plugins.sqldelight)
id(libs.plugins.kalium.library.get().pluginId)
alias(libs.plugins.ksp)
alias(libs.plugins.mockative)
Expand All @@ -35,6 +35,7 @@ sqldelight {
databases {
create("UserDatabase") {
dialect(libs.sqldelight.dialect.get().toString())
enableCustomQueryKeys.set(true)
packageName.set("com.wire.kalium.persistence")
val sourceFolderName = "db_user"
srcDirs.setFrom(listOf("src/commonMain/$sourceFolderName"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ ORDER BY
name COLLATE NOCASE ASC;

selectConversationDetailsWithEvents:
-- @CustomKey conversation_list_membership
-- @CustomKey conversation_list_order
-- @CustomKey conversation_list_last_message
-- @CustomKey conversation_list_unread
-- @CustomKey conversation_list_draft
SELECT * FROM ConversationDetailsWithEvents
WHERE
archived = :fromArchive
Expand Down Expand Up @@ -131,6 +136,11 @@ WHERE
OFFSET :offset;

selectConversationDetailsWithEventsFromSearch:
-- @CustomKey conversation_list_membership
-- @CustomKey conversation_list_order
-- @CustomKey conversation_list_last_message
-- @CustomKey conversation_list_unread
-- @CustomKey conversation_list_draft
SELECT * FROM ConversationDetailsWithEvents
WHERE
archived = :fromArchive
Expand Down Expand Up @@ -166,6 +176,7 @@ LIMIT :limit
OFFSET :offset;

countConversations:
-- @CustomKey conversation_list_membership
SELECT COUNT(*)
FROM Conversation
WHERE
Expand Down Expand Up @@ -227,6 +238,7 @@ WHERE
AND CASE WHEN :onlyInteractionsEnabled THEN interactionEnabled = 1 ELSE 1 END;

countConversationDetailsWithEventsFromSearch:
-- @CustomKey conversation_list_membership
SELECT COUNT(*) FROM ConversationDetails
WHERE
ConversationDetails.type IS NOT 'SELF'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,25 @@ conversationIDByGroupId:
SELECT qualified_id, verification_status FROM Conversation WHERE mls_group_id = :groupId;

deleteAllConversations:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
DELETE FROM Conversation;

deleteConversation:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
DELETE FROM Conversation WHERE qualified_id = ?;

markAsDeletedLocally:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET deleted_locally = 1
WHERE qualified_id = ?;

insertConversation:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
INSERT INTO Conversation(qualified_id, name, type, team_id, mls_group_id, mls_group_state, mls_epoch, protocol, muted_status, muted_time, creator_id, last_modified_date, last_notified_date, access_list, access_role_list, last_read_date, mls_last_keying_material_update_date, mls_cipher_suite, receipt_mode, message_timer, user_message_timer, incomplete_metadata, archived, archived_date_time, is_channel, channel_access, channel_add_permission, wire_cell, history_sharing_retention_seconds)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(qualified_id) DO UPDATE SET
Expand Down Expand Up @@ -124,11 +132,15 @@ wire_cell = excluded.wire_cell,
history_sharing_retention_seconds = excluded.history_sharing_retention_seconds;

updateConversation:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET name = ?, type = ?, team_id = ?
WHERE qualified_id = ?;

updateConversationGroupState:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET mls_group_state = CASE
WHEN mls_group_state = 'ESTABLISHED' THEN :mls_group_state
Expand All @@ -138,6 +150,8 @@ END
WHERE mls_group_id = ?;

updateConversationGroupStateByConversationId:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET mls_group_state = CASE
WHEN mls_group_state = 'ESTABLISHED' THEN :mls_group_state
Expand All @@ -147,6 +161,8 @@ END
WHERE qualified_id = :conversation_id;

updateMlsGroupStateAndCipherSuite:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET mls_group_state = CASE
WHEN mls_group_state = 'ESTABLISHED' THEN :mls_group_state
Expand All @@ -157,6 +173,8 @@ mls_cipher_suite = :mls_cipher_suite
WHERE mls_group_id = :mls_group_id;

updateMLSGroupIdAndState:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET mls_group_id = :new_group_id,
mls_group_state = CASE
Expand Down Expand Up @@ -193,11 +211,15 @@ SET last_notified_date = (
);

updateConversationModifiedDate:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_order
UPDATE Conversation
SET last_modified_date = ?
WHERE qualified_id = ?;

updateConversationModifiedDateToMaxOfSources:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_order
UPDATE Conversation
SET last_modified_date = (
SELECT MAX(last_modified_date)
Expand Down Expand Up @@ -274,11 +296,15 @@ selectConversationIds:
SELECT qualified_id FROM Conversation WHERE protocol = :protocol AND type = :type AND (:teamId IS NULL OR team_id = :teamId);

updateConversationMutingStatus:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_unread
UPDATE Conversation
SET muted_status = ?, muted_time = ?
WHERE qualified_id = ?;

updateConversationArchivingStatus:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET archived = ?, archived_date_time = ?
WHERE qualified_id = ?;
Expand Down Expand Up @@ -311,16 +337,23 @@ SELECT sender_user_id FROM Message WHERE id IN (
) ORDER BY creation_date DESC LIMIT 1;

updateConversationName:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
-- @NotifyCustomKey conversation_list_order
UPDATE Conversation
SET name = ?, last_modified_date = ?
WHERE qualified_id = ?;

updateConversationType:
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET type = ?
WHERE qualified_id = ?;

updateConversationGroupIdAndProtocolInfo {
-- @NotifyCustomKey Conversation
-- @NotifyCustomKey conversation_list_membership
UPDATE Conversation
SET mls_group_id = :groupId, protocol = :protocol, mls_cipher_suite = :mls_cipher_suite
WHERE qualified_id = :qualified_id AND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ CREATE TABLE MessageDraft (
);

deleteDraft:
-- @NotifyCustomKey MessageDraft
-- @NotifyCustomKey conversation_list_draft
DELETE FROM MessageDraft WHERE conversation_id = ?;

upsertDraft:
-- @NotifyCustomKey MessageDraft
-- @NotifyCustomKey conversation_list_draft
INSERT INTO MessageDraft(conversation_id, text, edit_message_id, quoted_message_id, mention_list)
VALUES( ?, ?, ?, ?, ?)
ON CONFLICT(conversation_id) DO UPDATE SET
Expand Down
Loading
Loading