-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from ouchadam/release-candidate
[Auto] Release Candidate
- Loading branch information
Showing
156 changed files
with
2,345 additions
and
1,241 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
plugins { | ||
id 'kotlin' | ||
id 'java-test-fixtures' | ||
} | ||
|
||
dependencies { | ||
api Dependencies.mavenCentral.kotlinCoroutinesCore | ||
api project(":matrix:common") | ||
|
||
kotlinFixtures(it) | ||
testFixturesImplementation(testFixtures(project(":matrix:common"))) | ||
testFixturesImplementation(testFixtures(project(":core"))) | ||
} |
82 changes: 82 additions & 0 deletions
82
chat-engine/src/main/kotlin/app/dapk/st/engine/ChatEngine.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,82 @@ | ||
package app.dapk.st.engine | ||
|
||
import app.dapk.st.matrix.common.EventId | ||
import app.dapk.st.matrix.common.JsonString | ||
import app.dapk.st.matrix.common.RoomId | ||
import app.dapk.st.matrix.common.RoomMember | ||
import kotlinx.coroutines.flow.Flow | ||
import java.io.InputStream | ||
|
||
interface ChatEngine : TaskRunner { | ||
|
||
fun directory(): Flow<DirectoryState> | ||
fun invites(): Flow<InviteState> | ||
fun messages(roomId: RoomId, disableReadReceipts: Boolean): Flow<MessengerState> | ||
|
||
fun notificationsMessages(): Flow<UnreadNotifications> | ||
fun notificationsInvites(): Flow<InviteNotification> | ||
|
||
suspend fun login(request: LoginRequest): LoginResult | ||
|
||
suspend fun me(forceRefresh: Boolean): Me | ||
|
||
suspend fun InputStream.importRoomKeys(password: String): Flow<ImportResult> | ||
|
||
suspend fun send(message: SendMessage, room: RoomOverview) | ||
|
||
suspend fun registerPushToken(token: String, gatewayUrl: String) | ||
|
||
suspend fun joinRoom(roomId: RoomId) | ||
|
||
suspend fun rejectJoinRoom(roomId: RoomId) | ||
|
||
suspend fun findMembersSummary(roomId: RoomId): List<RoomMember> | ||
|
||
fun mediaDecrypter(): MediaDecrypter | ||
|
||
fun pushHandler(): PushHandler | ||
|
||
} | ||
|
||
interface TaskRunner { | ||
|
||
suspend fun runTask(task: ChatEngineTask): TaskResult | ||
|
||
sealed interface TaskResult { | ||
object Success : TaskResult | ||
data class Failure(val canRetry: Boolean) : TaskResult | ||
} | ||
|
||
} | ||
|
||
|
||
data class ChatEngineTask(val type: String, val jsonPayload: String) | ||
|
||
interface MediaDecrypter { | ||
|
||
fun decrypt(input: InputStream, k: String, iv: String): Collector | ||
|
||
fun interface Collector { | ||
fun collect(partial: (ByteArray) -> Unit) | ||
} | ||
|
||
} | ||
|
||
interface PushHandler { | ||
fun onNewToken(payload: JsonString) | ||
fun onMessageReceived(eventId: EventId?, roomId: RoomId?) | ||
} | ||
|
||
typealias UnreadNotifications = Pair<Map<RoomOverview, List<RoomEvent>>, NotificationDiff> | ||
|
||
data class NotificationDiff( | ||
val unchanged: Map<RoomId, List<EventId>>, | ||
val changedOrNew: Map<RoomId, List<EventId>>, | ||
val removed: Map<RoomId, List<EventId>>, | ||
val newRooms: Set<RoomId> | ||
) | ||
|
||
data class InviteNotification( | ||
val content: String, | ||
val roomId: RoomId | ||
) |
Oops, something went wrong.