-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into dependabot/gradle/sqldelight-2.0.2
- Loading branch information
Showing
525 changed files
with
23,941 additions
and
3,091 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ jobs: | |
fetch-depth: 0 | ||
|
||
- name: Cherry pick to `develop` | ||
uses: wireapp/[email protected].0 | ||
uses: wireapp/[email protected].2 | ||
with: | ||
target-branch: develop | ||
pr-title-suffix: '🍒' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
# Please look up the latest version from | ||
# https://github.com/amannn/action-semantic-pull-request/releases | ||
- name: Run Semantic Commint Linter | ||
uses: amannn/[email protected].2 | ||
uses: amannn/[email protected].3 | ||
with: | ||
# Configure which types are allowed. | ||
# Default: https://github.com/commitizen/conventional-commit-types | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
cli/src/commonMain/kotlin/com/wire/kalium/cli/commands/GenerateEventsCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.cli.commands | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
import com.github.ajalt.clikt.core.PrintMessage | ||
import com.github.ajalt.clikt.core.requireObject | ||
import com.github.ajalt.clikt.parameters.arguments.argument | ||
import com.github.ajalt.clikt.parameters.options.option | ||
import com.github.ajalt.clikt.parameters.options.required | ||
import com.github.ajalt.clikt.parameters.types.int | ||
import com.wire.kalium.logic.data.conversation.ClientId | ||
import com.wire.kalium.logic.data.id.ConversationId | ||
import com.wire.kalium.logic.data.id.QualifiedClientID | ||
import com.wire.kalium.logic.data.user.UserId | ||
import com.wire.kalium.logic.feature.UserSessionScope | ||
import com.wire.kalium.logic.data.event.EventGenerator | ||
import com.wire.kalium.logic.functional.getOrFail | ||
import com.wire.kalium.network.api.authenticated.notification.NotificationResponse | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.toList | ||
import kotlinx.coroutines.runBlocking | ||
import kotlinx.datetime.Clock | ||
import kotlinx.io.Buffer | ||
import kotlinx.io.buffered | ||
import kotlinx.io.files.Path | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
import kotlinx.io.files.SystemFileSystem | ||
import kotlinx.io.writeString | ||
|
||
class GenerateEventsCommand : CliktCommand(name = "generate-events") { | ||
|
||
private val userSession by requireObject<UserSessionScope>() | ||
private val targetUserId: String by option(help = "Target User which events will be generator for.").required() | ||
private val targetClientId: String by option(help = "Target Client which events will be generator for.").required() | ||
private val conversationId: String by option(help = "Target conversation which which will receive the events").required() | ||
private val eventLimit: Int by argument("Number of events to generate").int() | ||
private val outputFile: String by argument("Output file for the generated events") | ||
|
||
private var json = Json { | ||
prettyPrint = true | ||
} | ||
|
||
override fun run() = runBlocking { | ||
val selfUserId = userSession.users.getSelfUser().first().id | ||
val selfClientId = userSession.clientIdProvider().getOrFail { throw PrintMessage("No self client is registered") } | ||
val targetUserId = UserId(value = targetUserId, domain = selfUserId.domain) | ||
val targetClientId = ClientId(targetClientId) | ||
|
||
userSession.debug.establishSession( | ||
userId = targetUserId, | ||
clientId = targetClientId | ||
) | ||
val generator = EventGenerator( | ||
selfClient = QualifiedClientID( | ||
clientId = selfClientId, | ||
userId = selfUserId | ||
), | ||
targetClient = QualifiedClientID( | ||
clientId = targetClientId, | ||
userId = targetUserId | ||
), | ||
proteusClient = userSession.proteusClientProvider.getOrCreate() | ||
) | ||
val events = generator.generateEvents( | ||
limit = eventLimit, | ||
conversationId = ConversationId(conversationId, domain = selfUserId.domain) | ||
) | ||
val response = NotificationResponse( | ||
time = Clock.System.now().toString(), | ||
hasMore = false, | ||
notifications = events.toList() | ||
) | ||
|
||
val sink = SystemFileSystem.sink(Path(outputFile)).buffered() | ||
val buffer = Buffer() | ||
buffer.writeString(json.encodeToString(response)) | ||
sink.write(buffer, buffer.size) | ||
sink.close() | ||
|
||
echo("Generated $eventLimit event(s) written into $outputFile") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.