diff --git a/CHANGES.md b/CHANGES.md
index 1601e0ec85..a73551cc33 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,9 +1,33 @@
-Changes in Element 1.1.4 (2021-XX-XX)
+Changes in Element 1.1.5 (2021-XX-XX)
===================================================
Features ✨:
-
+Improvements 🙌:
+ -
+
+Bugfix 🐛:
+ -
+
+Translations 🗣:
+ -
+
+SDK API changes ⚠️:
+ -
+
+Build 🧱:
+ -
+
+Test:
+ -
+
+Other changes:
+ -
+
+Changes in Element 1.1.4 (2021-04-09)
+===================================================
+
Improvements 🙌:
- Split network request `/keys/query` into smaller requests (250 users max) (#2925)
- Crypto improvement | Bulk send NO_OLM withheld code
@@ -14,28 +38,32 @@ Improvements 🙌:
- Update reactions to Unicode 13.1 (#2998)
- Be more robust when parsing some enums
- Improve timeline filtering (dissociate membership and profile events, display hidden events when highlighted, fix hidden item/read receipts behavior)
+ - Add better support for empty room name fallback (#3106)
+ - Room list improvements (paging)
+ - Fix quick click action (#3127)
+ - Get Event after a Push for a faster notification display in some conditions
+ - Always try to retry Http requests in case of 429 (#1300)
+ - registration availability endpoint added to matrix-sdk
Bugfix 🐛:
- Fix bad theme change for the MainActivity
- Handle encrypted reactions (#2509)
- Disable URL preview for some domains (#2995)
- Fix avatar rendering for DMs, after initial sync (#2693)
-
-Translations 🗣:
- -
+ - Fix mandatory parameter in API (#3065)
+ - If signout request fails, do not start LoginActivity, but restart the app (#3099)
+ - Retain keyword order in emoji import script, and update the generated file (#3147)
SDK API changes ⚠️:
- Several Services have been migrated to coroutines (#2449)
- Removes filtering options on Timeline.
Build 🧱:
- -
-
-Test:
- -
+ - Properly exclude gms dependencies in fdroid build flavour which were pulled in through the jitsi SDK (#3125)
Other changes:
- Add version details on the login screen, in debug or developer mode
+ - Migrate Retrofit interface to coroutine calls
Changes in Element 1.1.3 (2021-03-18)
===================================================
diff --git a/attachment-viewer/build.gradle b/attachment-viewer/build.gradle
index 5a8cce92e8..8db57a59af 100644
--- a/attachment-viewer/build.gradle
+++ b/attachment-viewer/build.gradle
@@ -69,7 +69,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
- implementation "androidx.recyclerview:recyclerview:1.2.0-rc01"
+ implementation "androidx.recyclerview:recyclerview:1.2.0"
implementation 'com.google.android.material:material:1.3.0'
}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 637b1de7cb..b8da6c3864 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,7 +16,7 @@ buildscript {
classpath 'com.google.gms:google-services:4.3.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.1.1'
- classpath 'com.google.android.gms:oss-licenses-plugin:0.10.2'
+ classpath 'com.google.android.gms:oss-licenses-plugin:0.10.3'
classpath "com.likethesalad.android:string-reference:1.2.1"
// NOTE: Do not place your application dependencies here; they belong
diff --git a/fastlane/metadata/android/ar/changelogs/40101010.txt b/fastlane/metadata/android/ar/changelogs/40101010.txt
new file mode 100644
index 0000000000..329fffeb3c
--- /dev/null
+++ b/fastlane/metadata/android/ar/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+التغييرات الرئيسة في هذه النسخة: تحسينات على الأداء وإصلاح للعلل!
+اطّلع على سجل التغييرات الكامل هنا: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/ar/title.txt b/fastlane/metadata/android/ar/title.txt
index 9b382729c8..11992d355d 100644
--- a/fastlane/metadata/android/ar/title.txt
+++ b/fastlane/metadata/android/ar/title.txt
@@ -1 +1 @@
-Element (سابقاً Riot.im)
+Element (Riot.im سابقًا)
diff --git a/fastlane/metadata/android/ca/changelogs/40101010.txt b/fastlane/metadata/android/ca/changelogs/40101010.txt
new file mode 100644
index 0000000000..26ce0562d0
--- /dev/null
+++ b/fastlane/metadata/android/ca/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Canvis principals d'aquesta versió: millora de rendiment i correcció d'errors!
+Registre de canvis complet: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/cs/changelogs/40101010.txt b/fastlane/metadata/android/cs/changelogs/40101010.txt
new file mode 100644
index 0000000000..73c691da06
--- /dev/null
+++ b/fastlane/metadata/android/cs/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Hlavní změny v této verzi: vylepšení výkonnosti a opravy chyb!
+Úplný záznam změn: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/de/changelogs/40100110.txt b/fastlane/metadata/android/de/changelogs/40100110.txt
index e70007b5d7..24bc6e518c 100644
--- a/fastlane/metadata/android/de/changelogs/40100110.txt
+++ b/fastlane/metadata/android/de/changelogs/40100110.txt
@@ -1,2 +1,2 @@
-Diese neue Version enthält hauptsächlich Verbesserungen der Benutzer*innenoberfläche und der Handhabung. Du kannst jetzt ganz schnell Freund*innen einladen und DMs erstellen, indem du schlicht einen QR-Code scannst.
+Diese neue Version enthält hauptsächlich Verbesserungen der Benutzeroberfläche und der Handhabung. Du kannst jetzt ganz schnell Freund*innen einladen und DMs erstellen, indem du schlicht einen QR-Code scannst.
Vollständige Versionshinweise: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/de/changelogs/40101010.txt b/fastlane/metadata/android/de/changelogs/40101010.txt
new file mode 100644
index 0000000000..59758edcc9
--- /dev/null
+++ b/fastlane/metadata/android/de/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Hauptänderungen in dieser Version: Leistungsverbesserungen und Fehlerbehebungen!
+Vollständiges Änderungsprotokoll: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/de/full_description.txt b/fastlane/metadata/android/de/full_description.txt
index 133f5e10d4..568ae61875 100644
--- a/fastlane/metadata/android/de/full_description.txt
+++ b/fastlane/metadata/android/de/full_description.txt
@@ -3,7 +3,7 @@ Element ist eine neuartige Messaging- und Kollaborationsapp:
1. Volle Kontrolle über deine Privatssphäre
2. Kommuniziere mit jedem aus dem Matrix-Netzwerk und mit der Integration von z.B. Slack sogar über Matrix hinaus
3. Schutz vor Werbung, Datamining und geschlossenen Platformen
-4. Absicherung durch Ende-zu-Ende-Verschlüsselung, und Cross Signing um andere zu verifizieren
+4. Absicherung durch Ende-zu-Ende-Verschlüsselung, und Cross-Signing um andere zu verifizieren
Element unterscheidet sich durch Dezentralität und Open Source deutlich von anderen Messaging- und Kollaborationsapps.
@@ -11,11 +11,11 @@ Element ermöglicht es einen eigenen Server zu betreiben - oder einen beliebigen
Element ist zu all diesem in der Lage, weil es Matrix nutzt - einen Standard für offene, dezentrale Kommunikation.
-Element gibt dir die Kontrolle, indem es dir die Wahl darüber lässt, wer deine Konversationen hostet. In der Element App kannst du zwischen verschiedenen Möglichkeiten auswählen:
+Element gibt dir die Kontrolle, indem es dir die Wahl darüber lässt, wer deine Konversationen hostet. In der Element-App kannst du zwischen verschiedenen Möglichkeiten auswählen:
1. Kostenlos auf dem öffentlichen matrix.org Server registrieren, der von den Matrix-Entwicklern gehostet wird, oder wähle aus Tausenden von öffentlichen Servern, die von Freiwilligen gehostet werden
-2. Einen Account auf einem eigenen Server auf eigener Hardware betreiben
-3. Einen Account auf einem benutzerdefinierten Server erstellen, zum Beispiel durch ein Abonnment bei der Element Matrix Services Hosting-Platform
+2. Einen Konto auf einem eigenen Server auf eigener Hardware betreiben
+3. Einen Konto auf einem benutzerdefinierten Server erstellen, zum Beispiel durch ein Abonnement bei Element Matrix Services (kurz EMS)
Wieso Element nutzen?
@@ -23,8 +23,8 @@ Element gibt dir die Kontrolle, indem es dir die Wahl darüber lässt, wer deine
OFFENE KOMMUNIKATION UND KOLLABORATION: Du kannst mit jedem im Matrix-Netzwerk schreiben, ob sie nun Element oder eine andere Matrix-App nutzen, oder gar ein anderes Kommunikationssystem wie z.B. Slack, IRC oder XMPP.
-SUPER SICHER: Echte Ende-zu-Ende-Verschlüsselung (nur Personen in der Konversation können die Nachrichten entschlüsseln), und Cross Signing um die Geräte der anderen Personen zu verifizieren.
+SUPER SICHER: Echte Ende-zu-Ende-Verschlüsselung (nur Personen in der Konversation können die Nachrichten entschlüsseln), und Cross-Signing um die Geräte der anderen Personen zu verifizieren.
VOLLSTÄNDIGE KOMMUNIKATION: Nachrichten, Telefonate und Videoanrufe, Teilen von Dateien oder dem eigenen Bildschirm und viele andere Integrationen, Bots und Widgets. Erstelle Räume, Communities, bleib in Kontakt und sei produktiv.
-ÜBERALL WO DU BIST: Bleib in Kontakt wo auch immer du bist - mit einem vollständig synchronisierten Nachrichtenverlauf über alle Geräte und im Web auf https://app.element.io.
+ÜBERALL WO DU BIST: Bleib in Kontakt wo auch immer du bist - mit einem vollständig synchronisierten Nachrichtenverlauf über alle Geräte und im Netz auf https://app.element.io.
diff --git a/fastlane/metadata/android/de/short_description.txt b/fastlane/metadata/android/de/short_description.txt
index 0ffacfd8d9..d2c30d4167 100644
--- a/fastlane/metadata/android/de/short_description.txt
+++ b/fastlane/metadata/android/de/short_description.txt
@@ -1 +1 @@
-Sicherer dezentraler Chat & Telefonie. Schütze deine Daten vor Dritten.
+Sicherer dezentraler Chat und Telefonie. Schütze deine Daten vor Dritten.
diff --git a/fastlane/metadata/android/en-US/changelogs/40101040.txt b/fastlane/metadata/android/en-US/changelogs/40101040.txt
new file mode 100644
index 0000000000..e8977f3211
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/40101040.txt
@@ -0,0 +1,2 @@
+Main changes in this version: performance improvement and bug fixes!
+Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.1.4
\ No newline at end of file
diff --git a/fastlane/metadata/android/et/changelogs/40101010.txt b/fastlane/metadata/android/et/changelogs/40101010.txt
new file mode 100644
index 0000000000..4db2c52cb0
--- /dev/null
+++ b/fastlane/metadata/android/et/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Põhilised muutused selles versioonis: jõudluse parandused ja pisikohendused.
+Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/fa/changelogs/40100120.txt b/fastlane/metadata/android/fa/changelogs/40100120.txt
new file mode 100644
index 0000000000..511cdb49fa
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40100120.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: پیشنمایش نشانی، صفحهکلید اموجی جدید، تنظیمهای اتاق جدید و برف برای کریسمس!
+گزارش تغییر کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.12
diff --git a/fastlane/metadata/android/fa/changelogs/40100130.txt b/fastlane/metadata/android/fa/changelogs/40100130.txt
new file mode 100644
index 0000000000..d78c76e041
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40100130.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: پیشنمایش نشانی، صفحهکلید اموجی جدید، تنظیمهای اتاق جدید و برف برای کریسمس!
+گزارش تغییر کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.13
diff --git a/fastlane/metadata/android/fa/changelogs/40100140.txt b/fastlane/metadata/android/fa/changelogs/40100140.txt
new file mode 100644
index 0000000000..5defa284aa
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40100140.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: ویرایش اجازههای اتاق، زمینهٔ تاریک/روشن خودکار و رفع دستهای از مشکلها.
+گزارش تغییر کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.14
diff --git a/fastlane/metadata/android/fa/changelogs/40100150.txt b/fastlane/metadata/android/fa/changelogs/40100150.txt
new file mode 100644
index 0000000000..d856b3a252
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40100150.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: پشتیبانی از ورود اجتماعی.
+گزارش تغییر کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.15
diff --git a/fastlane/metadata/android/fa/changelogs/40100160.txt b/fastlane/metadata/android/fa/changelogs/40100160.txt
new file mode 100644
index 0000000000..4d8aea0cb6
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40100160.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: پشتیبانی از ورود اجتماعی.
+گزارش تغییر کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.15 و https://github.com/vector-im/element-android/releases/tag/v1.0.16
diff --git a/fastlane/metadata/android/fa/changelogs/40100170.txt b/fastlane/metadata/android/fa/changelogs/40100170.txt
new file mode 100644
index 0000000000..6de164e57f
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40100170.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: رفع مشکلها!
+گزارش تغییر کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.17
diff --git a/fastlane/metadata/android/fa/changelogs/40101000.txt b/fastlane/metadata/android/fa/changelogs/40101000.txt
new file mode 100644
index 0000000000..6a3c154ae4
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: بهبود ویپ (تماسهای صوتی و تصویری در پیامهای مستقیم) و رفع مشکلها!
+گزارش تغییر کامل: https://github.com/vector-im/element-android/releases/tag/v1.1.0
diff --git a/fastlane/metadata/android/fa/changelogs/40101010.txt b/fastlane/metadata/android/fa/changelogs/40101010.txt
new file mode 100644
index 0000000000..8e29373452
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: بهبود عملکرد و رفع مشکلها!
+گزارش تغییر کامل: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/fi/changelogs/40101000.txt b/fastlane/metadata/android/fi/changelogs/40101000.txt
new file mode 100644
index 0000000000..1b85b6d00d
--- /dev/null
+++ b/fastlane/metadata/android/fi/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+Suurimmat muutokset tässä versiossa: VoIP-parannuksia ja korjauksia (ääni- ja videopuhelut yksityiskeskusteluissa)
+Täysi muutosloki: https://github.com/vector-im/element-android/releases/tag/v1.1.0
diff --git a/fastlane/metadata/android/fi/changelogs/40101010.txt b/fastlane/metadata/android/fi/changelogs/40101010.txt
new file mode 100644
index 0000000000..c79023c148
--- /dev/null
+++ b/fastlane/metadata/android/fi/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Suurimmat muutokset tässä versiossa: suorituskykyparannuksia ja bugikorjauksia!
+Täysi muutosloki: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/fr/changelogs/40100130.txt b/fastlane/metadata/android/fr/changelogs/40100130.txt
index 412b2b9db2..a7e233616a 100644
--- a/fastlane/metadata/android/fr/changelogs/40100130.txt
+++ b/fastlane/metadata/android/fr/changelogs/40100130.txt
@@ -1,2 +1,2 @@
Principaux changements apportés par cette version : aperçu des URL, nouveau clavier Emoji, nouvelles options de configuration pour le salon et neige pour Noël.
-Liste complète des changements : https://github.com/vector-im/element-android/releases/tag/v1.0.12
+Liste complète des changements : https://github.com/vector-im/element-android/releases/tag/v1.0.13
diff --git a/fastlane/metadata/android/fr/changelogs/40100140.txt b/fastlane/metadata/android/fr/changelogs/40100140.txt
new file mode 100644
index 0000000000..e823d7a89a
--- /dev/null
+++ b/fastlane/metadata/android/fr/changelogs/40100140.txt
@@ -0,0 +1,2 @@
+Principaux changements pour cette version : modification des permissions dans les salons, thème lumineux/sombre automatique, et plein de corrections de bugs.
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.0.14
diff --git a/fastlane/metadata/android/fr/changelogs/40100150.txt b/fastlane/metadata/android/fr/changelogs/40100150.txt
new file mode 100644
index 0000000000..cfc92299d4
--- /dev/null
+++ b/fastlane/metadata/android/fr/changelogs/40100150.txt
@@ -0,0 +1,2 @@
+Principaux changements pour cette version : prise en charge de l’authentification avec les réseaux sociaux.
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.0.15
diff --git a/fastlane/metadata/android/fr/changelogs/40100160.txt b/fastlane/metadata/android/fr/changelogs/40100160.txt
new file mode 100644
index 0000000000..b5bca83268
--- /dev/null
+++ b/fastlane/metadata/android/fr/changelogs/40100160.txt
@@ -0,0 +1,2 @@
+Principaux changements pour cette version : prise en charge de l’authentification avec les réseaux sociaux !
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.0.15 et https://github.com/vector-im/element-android/releases/tag/v1.0.16
diff --git a/fastlane/metadata/android/fr/changelogs/40100170.txt b/fastlane/metadata/android/fr/changelogs/40100170.txt
new file mode 100644
index 0000000000..5474f15417
--- /dev/null
+++ b/fastlane/metadata/android/fr/changelogs/40100170.txt
@@ -0,0 +1,2 @@
+Principaux changements pour cette version : corrections de bugs !
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1..017
diff --git a/fastlane/metadata/android/fr/changelogs/40101000.txt b/fastlane/metadata/android/fr/changelogs/40101000.txt
new file mode 100644
index 0000000000..e9330611ee
--- /dev/null
+++ b/fastlane/metadata/android/fr/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+Principaux changements pour cette version : améliorations de la VoIP (appels audio et vidéo dans les conversations primées) et corrections de bugs !
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.1.0
diff --git a/fastlane/metadata/android/fr/changelogs/40101010.txt b/fastlane/metadata/android/fr/changelogs/40101010.txt
new file mode 100644
index 0000000000..8e9de64423
--- /dev/null
+++ b/fastlane/metadata/android/fr/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Principaux changements pour cette version : amélioration des performances et corrections de bugs !
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/ga/title.txt b/fastlane/metadata/android/ga/title.txt
new file mode 100644
index 0000000000..85dd3fa07f
--- /dev/null
+++ b/fastlane/metadata/android/ga/title.txt
@@ -0,0 +1 @@
+Element (Riot.im roimhe sin)
diff --git a/fastlane/metadata/android/it/changelogs/40101000.txt b/fastlane/metadata/android/it/changelogs/40101000.txt
new file mode 100644
index 0000000000..bd13c2c185
--- /dev/null
+++ b/fastlane/metadata/android/it/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+Modifiche principali in questa versione: migliorato il VoIP (chiamate audio e video in MD) e correzione di errori!
+Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.1.0
diff --git a/fastlane/metadata/android/it/changelogs/40101010.txt b/fastlane/metadata/android/it/changelogs/40101010.txt
new file mode 100644
index 0000000000..51e6659827
--- /dev/null
+++ b/fastlane/metadata/android/it/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Modifiche principali in questa versione: prestazioni migliorate e correzione di errori!
+Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/kab/short_description.txt b/fastlane/metadata/android/kab/short_description.txt
index bee72ea427..453d31fc2a 100644
--- a/fastlane/metadata/android/kab/short_description.txt
+++ b/fastlane/metadata/android/kab/short_description.txt
@@ -1 +1 @@
-Adiwenni aɣellsan ur nelli aslammas & VoIP. Ḥrez isefra-k•m seg tama tis tlata.
+Adiwenni aɣellsan ur nelli d aslammas & VoIP. Ḥrez isefra-k•m seg wis tlata.
diff --git a/fastlane/metadata/android/pt-BR/changelogs/40101000.txt b/fastlane/metadata/android/pt-BR/changelogs/40101000.txt
new file mode 100644
index 0000000000..8138e376c6
--- /dev/null
+++ b/fastlane/metadata/android/pt-BR/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+Principais mudanças nesta versão: Melhoria de VoIP (chamadas de áudio e vídeo em conversas) e correção de erros!
+Registro de alterações completo: https://github.com/vector-im/element-android/releases/tag/v1.1.0
diff --git a/fastlane/metadata/android/pt-BR/changelogs/40101010.txt b/fastlane/metadata/android/pt-BR/changelogs/40101010.txt
new file mode 100644
index 0000000000..56f9c2955d
--- /dev/null
+++ b/fastlane/metadata/android/pt-BR/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Principais mudanças nesta versão: melhoria de desempenho e correção de erros!
+Registro de alterações completo: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/ru/changelogs/40101000.txt b/fastlane/metadata/android/ru/changelogs/40101000.txt
new file mode 100644
index 0000000000..8ec344a85a
--- /dev/null
+++ b/fastlane/metadata/android/ru/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+Основные изменения в этой версии: VoIP (аудио и видео звонки в ЛС) Улучшение и исправления ошибок!
+Полный список изменений: https://github.com/vector-im/element-android/release/tag/v1.1.0
diff --git a/fastlane/metadata/android/ru/changelogs/40101010.txt b/fastlane/metadata/android/ru/changelogs/40101010.txt
new file mode 100644
index 0000000000..7295e0df60
--- /dev/null
+++ b/fastlane/metadata/android/ru/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Основные изменения в этой версии: улучшение производительности и исправления ошибок!
+Полный список изменений: https://github.com/vector-im/element-android/release/tag/v1.1.1
diff --git a/fastlane/metadata/android/sv/changelogs/40101010.txt b/fastlane/metadata/android/sv/changelogs/40101010.txt
new file mode 100644
index 0000000000..66a3751aac
--- /dev/null
+++ b/fastlane/metadata/android/sv/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Huvudsakliga ändringar i den här versionen: Förbättringar och buggfixar!
+Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/tr/changelogs/40100140.txt b/fastlane/metadata/android/tr/changelogs/40100140.txt
new file mode 100644
index 0000000000..9a5cf6d5f0
--- /dev/null
+++ b/fastlane/metadata/android/tr/changelogs/40100140.txt
@@ -0,0 +1,2 @@
+Bu sürümdeki başlıca değişiklikler: Oda izinlerini düzenleme, otomatik koyu/açık tema ve bir avuç hata düzeltmeleri.
+Değişim günlüğünün tamamı: https://github.com/vector-im/element-android/releases/tag/v1.0.14
diff --git a/fastlane/metadata/android/tr/changelogs/40100170.txt b/fastlane/metadata/android/tr/changelogs/40100170.txt
new file mode 100644
index 0000000000..a93cbb4908
--- /dev/null
+++ b/fastlane/metadata/android/tr/changelogs/40100170.txt
@@ -0,0 +1,2 @@
+Bu sürümdeki başlıca değişiklikler: Hata düzeltmeleri!
+değişim günlüğünün tamamı: https://github.com/vector-im/element-android/releases/tag/v1.0.17
diff --git a/fastlane/metadata/android/tr/changelogs/40101000.txt b/fastlane/metadata/android/tr/changelogs/40101000.txt
new file mode 100644
index 0000000000..ce457ee0f4
--- /dev/null
+++ b/fastlane/metadata/android/tr/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+Bu sürümdeki ana değişiklikler: VoIP (DM'de sesli ve görüntülü aramalar) geliştirmeleri ve hata düzeltmeleri!
+Değişim günlüğünün tamamı: https://github.com/vector-im/element-android/releases/tag/v1.1.0
diff --git a/fastlane/metadata/android/tr/changelogs/40101010.txt b/fastlane/metadata/android/tr/changelogs/40101010.txt
new file mode 100644
index 0000000000..912d5bcd7c
--- /dev/null
+++ b/fastlane/metadata/android/tr/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Bu sürümdeki ana değişiklikler: performans iyileştirme ve hata düzeltmeleri!
+Değişim günlüğünün tamamı: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/uk/changelogs/40101010.txt b/fastlane/metadata/android/uk/changelogs/40101010.txt
new file mode 100644
index 0000000000..085ac5a118
--- /dev/null
+++ b/fastlane/metadata/android/uk/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Основні зміни в цій версії: поліпшення продуктивності та виправлення помилок!
+Повний журнал змін: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40100100.txt b/fastlane/metadata/android/zh-Hans/changelogs/40100100.txt
index 0dc493cf40..0c226c1c8f 100644
--- a/fastlane/metadata/android/zh-Hans/changelogs/40100100.txt
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40100100.txt
@@ -1,2 +1,2 @@
-此新版本主要包含错误修复和改进。现在,发送消息要快得多。
+此新版本主要包含错误修复和改进。现在,发送消息比以前快多了。
完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40100120.txt b/fastlane/metadata/android/zh-Hans/changelogs/40100120.txt
new file mode 100644
index 0000000000..67d69a3834
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40100120.txt
@@ -0,0 +1,2 @@
+此版本的主要变化:链接预览,全新 Emoji 键盘,全新聊天室设置功能,以及圣诞节雪花!
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.0.12
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40100130.txt b/fastlane/metadata/android/zh-Hans/changelogs/40100130.txt
new file mode 100644
index 0000000000..5a2ba4256f
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40100130.txt
@@ -0,0 +1,2 @@
+此版本的主要变化:链接预览,全新 Emoji 键盘,全新聊天室设置功能,以及圣诞节雪花!
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.0.13
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40100140.txt b/fastlane/metadata/android/zh-Hans/changelogs/40100140.txt
new file mode 100644
index 0000000000..dc25b5094b
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40100140.txt
@@ -0,0 +1,2 @@
+此版本的主要变化:支持编辑聊天室权限,自动切换浅色/深色主题,修复大量错误。
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.0.14
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40100150.txt b/fastlane/metadata/android/zh-Hans/changelogs/40100150.txt
new file mode 100644
index 0000000000..d5f37ff3a6
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40100150.txt
@@ -0,0 +1,2 @@
+此版本的主要变化:支持通过社交网络登录。
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.0.15
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40100160.txt b/fastlane/metadata/android/zh-Hans/changelogs/40100160.txt
new file mode 100644
index 0000000000..c0658e1881
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40100160.txt
@@ -0,0 +1,2 @@
+此版本的主要变化:支持通过社交网络登录。
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.0.15 和 https://github.com/vector-im/element-android/releases/tag/v1.0.16
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40100170.txt b/fastlane/metadata/android/zh-Hans/changelogs/40100170.txt
new file mode 100644
index 0000000000..55cbadb37f
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40100170.txt
@@ -0,0 +1,2 @@
+此版本的主要变化:修复错误!
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.0.17
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40101000.txt b/fastlane/metadata/android/zh-Hans/changelogs/40101000.txt
new file mode 100644
index 0000000000..95bd9c55c0
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+此版本的主要变化:改进 VoIP(私聊中的音频与视频通话)以及修复错误!
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.1.0
diff --git a/fastlane/metadata/android/zh-Hans/changelogs/40101010.txt b/fastlane/metadata/android/zh-Hans/changelogs/40101010.txt
new file mode 100644
index 0000000000..9a4e611cf9
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hans/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+此版本的主要变化:改进性能以及修复错误!
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/zh-Hans/full_description.txt b/fastlane/metadata/android/zh-Hans/full_description.txt
index 12664f7c9b..4791c9652b 100644
--- a/fastlane/metadata/android/zh-Hans/full_description.txt
+++ b/fastlane/metadata/android/zh-Hans/full_description.txt
@@ -1,30 +1,30 @@
-Element 是一种新型消息和协作应用:
+Element 是一种新型的通讯与协作应用:
1. 使您可以掌控您的隐私
-2. 使您与 Matrix 网络中的任何人交流,甚至可以通过与其他应用如 Slack 集成
-3. 保护您远离广告,数据挖掘和围墙花园
-4. 通过端到端加密保护您,通过交叉签名验证其他人
+2. 使您与 Matrix 网络中的任何人交流,甚至可以通过集成功能与如 Slack 之类的其他应用通讯
+3. 保护您免受广告,大数据挖掘和封闭服务的侵害
+4. 通过端到端加密保证安全,通过交叉签名验证其他人
-Element 与其他消息和协作应用完全不同,因为它是去中心化且开源的。
+Element 与其他通讯与协作应用完全不同,因为它是去中心化且开源的。
-Element 使您可以自托管 - 或选择托管商 - 因此您拥有您的数据和会话的隐私权,所有权和控制权。它使您可以访问开放网络;因此您可以不仅仅与其他 Element 用户交流。并且它非常安全。
+Element 允许您自托管——或者选择托管商——因此,您能拥有数据和会话的隐私权,所有权和控制权。它允许您访问开放网络;因此,您可以与 Element 用户以外的人交流。并且它非常安全。
-Element 可以做到这些因为它在 Matrix 上运行 - 开放,去中心化通信标准。
+Element 之所以可以做到这些,是因为它在 Matrix 上运行——开放,去中心化通讯的标准。
-Element 通过让您选择谁来托管您的会话使您掌控一切。在 Element 应用中,您可以选择不同的托管方式:
+通过让您选择由谁来托管您的会话,Element 让您掌控一切。在 Element 应用中,您可以选择不同的托管方式:
-1. 在由 Matrix 开发者托管的 matrix.org 公共服务器上获取免费帐户,或从志愿者托管的几千个公共服务器中选择
-2. 在您自己的硬件上运行服务器自托管您的会话
-3. 通过简单地订阅 Element Matrix Services 托管平台在自定义服务器上注册账户
+1. 在由 Matrix 开发者托管的 matrix.org 公共服务器上获取免费帐户,或从志愿者托管的上千个公共服务器中选择
+2. 在您自己的硬件上运行服务器,自托管您的会话
+3. 通过订阅 Element Matrix Services 托管平台,简单地在自定义服务器上注册账户
为什么选择 Element?
-拥有您的数据:您来决定存放您的数据和消息的位置。拥有并控制它的是您,而不是挖掘您的数据或与第三方分享的巨型企业。
+掌控您的数据:您来决定存放您的数据和消息的位置。拥有并控制它的是您,而不是挖掘您的数据或与第三方分享的巨型企业。
-开放消息与协作:您可以与 Matrix 网络中的任何人聊天,不论他们使用 Element 还是其他 Matrix 应用,甚至即使他们在使用不同的消息系统例如 Slack,IRC 或 XMPP。
+开放通讯与协作:您可以与 Matrix 网络中的任何人聊天,不论他们使用 Element 还是其他 Matrix 应用,甚至/即使他们在使用不同的通讯系统,例如 Slack,IRC 或 XMPP。
-超级安全:真正的端到端加密(仅有会话中的人可以解密消息),及用于验证会话参与方的设备的交叉签名。
+超级安全:支持真正的端到端加密(仅有会话中的人可以解密消息),还有能够验证会话参与方的设备的交叉签名。
-丰富的通信方式:消息,语音和视频通话,文件分享,屏幕分享和大量集成,机器人和小部件。建立房间,社区,保持联系并做好工作。
+完善的通讯方式:消息,语音和视频通话,文件共享,屏幕共享和大量集成功能,机器人和小挂件。建立房间与社区,保持联系并完成工作。
-随时随地:通过在您的全部设备和 https://app.element.io 网页上完全同步的消息历史,无论您在哪里都可以保持联系。
+随时随地:消息历史可在您的全部设备和 https://app.element.io 网页端之间完全同步,无论您在哪里,都可以保持联系。
diff --git a/fastlane/metadata/android/zh-Hans/short_description.txt b/fastlane/metadata/android/zh-Hans/short_description.txt
index 87d127335b..53d7d33403 100644
--- a/fastlane/metadata/android/zh-Hans/short_description.txt
+++ b/fastlane/metadata/android/zh-Hans/short_description.txt
@@ -1 +1 @@
-安全去中心化的聊天和 VoIP。保护您的数据不受第三方的影响。
+安全、去中心化的聊天与 VoIP 通话。保护您的数据不被第三方窃取。
diff --git a/fastlane/metadata/android/zh-Hant/changelogs/40101010.txt b/fastlane/metadata/android/zh-Hant/changelogs/40101010.txt
new file mode 100644
index 0000000000..8b0e45e6b3
--- /dev/null
+++ b/fastlane/metadata/android/zh-Hant/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+此版本的主要變更:效能改進與錯誤修復!
+完整變更紀錄:https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle
index 0ca605dc8b..669444d563 100644
--- a/matrix-sdk-android/build.gradle
+++ b/matrix-sdk-android/build.gradle
@@ -108,11 +108,11 @@ static def gitRevisionDate() {
dependencies {
def arrow_version = "0.8.2"
- def moshi_version = '1.11.0'
+ def moshi_version = '1.12.0'
def lifecycle_version = '2.2.0'
def arch_version = '2.1.0'
def markwon_version = '3.1.0'
- def daggerVersion = '2.33'
+ def daggerVersion = '2.34'
def work_version = '2.5.0'
def retrofit_version = '2.9.0'
@@ -166,7 +166,7 @@ dependencies {
implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'
// Phone number https://github.com/google/libphonenumber
- implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.20'
+ implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.21'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.5.1'
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestRoomDisplayNameFallbackProvider.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestRoomDisplayNameFallbackProvider.kt
index 7a1d4604f0..af2d57f9ce 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestRoomDisplayNameFallbackProvider.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestRoomDisplayNameFallbackProvider.kt
@@ -18,23 +18,26 @@ package org.matrix.android.sdk.common
import org.matrix.android.sdk.api.RoomDisplayNameFallbackProvider
-class TestRoomDisplayNameFallbackProvider() : RoomDisplayNameFallbackProvider {
+class TestRoomDisplayNameFallbackProvider : RoomDisplayNameFallbackProvider {
override fun getNameForRoomInvite() =
"Room invite"
- override fun getNameForEmptyRoom() =
+ override fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List) =
"Empty room"
- override fun getNameFor2members(name1: String?, name2: String?) =
+ override fun getNameFor1member(name: String) =
+ name
+
+ override fun getNameFor2members(name1: String, name2: String) =
"$name1 and $name2"
- override fun getNameFor3members(name1: String?, name2: String?, name3: String?) =
+ override fun getNameFor3members(name1: String, name2: String, name3: String) =
"$name1, $name2 and $name3"
- override fun getNameFor4members(name1: String?, name2: String?, name3: String?, name4: String?) =
+ override fun getNameFor4members(name1: String, name2: String, name3: String, name4: String) =
"$name1, $name2, $name3 and $name4"
- override fun getNameFor4membersAndMore(name1: String?, name2: String?, name3: String?, remainingCount: Int) =
+ override fun getNameFor4membersAndMore(name1: String, name2: String, name3: String, remainingCount: Int) =
"$name1, $name2, $name3 and $remainingCount others"
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/RoomDisplayNameFallbackProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/RoomDisplayNameFallbackProvider.kt
index 4ac14d5f63..a34dbcc196 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/RoomDisplayNameFallbackProvider.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/RoomDisplayNameFallbackProvider.kt
@@ -18,9 +18,10 @@ package org.matrix.android.sdk.api
interface RoomDisplayNameFallbackProvider {
fun getNameForRoomInvite(): String
- fun getNameForEmptyRoom(): String
- fun getNameFor2members(name1: String?, name2: String?): String
- fun getNameFor3members(name1: String?, name2: String?, name3: String?): String
- fun getNameFor4members(name1: String?, name2: String?, name3: String?, name4: String?): String
- fun getNameFor4membersAndMore(name1: String?, name2: String?, name3: String?, remainingCount: Int): String
+ fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List): String
+ fun getNameFor1member(name: String): String
+ fun getNameFor2members(name1: String, name2: String): String
+ fun getNameFor3members(name1: String, name2: String, name3: String): String
+ fun getNameFor4members(name1: String, name2: String, name3: String, name4: String): String
+ fun getNameFor4membersAndMore(name1: String, name2: String, name3: String, remainingCount: Int): String
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationAvailability.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationAvailability.kt
new file mode 100644
index 0000000000..f9a7ace7ba
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationAvailability.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.api.auth.registration
+
+import org.matrix.android.sdk.api.failure.Failure
+
+sealed class RegistrationAvailability {
+ object Available : RegistrationAvailability()
+ data class NotAvailable(val failure: Failure.ServerError) : RegistrationAvailability()
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationWizard.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationWizard.kt
index d00c9a0c82..38a5a77291 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationWizard.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationWizard.kt
@@ -36,6 +36,8 @@ interface RegistrationWizard {
suspend fun checkIfEmailHasBeenValidated(delayMillis: Long): RegistrationResult
+ suspend fun registrationAvailable(userName: String): RegistrationAvailability
+
val currentThreePid: String?
// True when login and password has been sent with success to the homeserver
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/failure/Extensions.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/failure/Extensions.kt
index e0ee9f36ba..0ba61e5890 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/failure/Extensions.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/failure/Extensions.kt
@@ -37,6 +37,18 @@ fun Throwable.shouldBeRetried(): Boolean {
|| (this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
}
+/**
+ * Get the retry delay in case of rate limit exceeded error, adding 100 ms, of defaultValue otherwise
+ */
+fun Throwable.getRetryDelay(defaultValue: Long): Long {
+ return (this as? Failure.ServerError)
+ ?.error
+ ?.takeIf { it.code == MatrixError.M_LIMIT_EXCEEDED }
+ ?.retryAfterMillis
+ ?.plus(100L)
+ ?: defaultValue
+}
+
fun Throwable.isInvalidPassword(): Boolean {
return this is Failure.ServerError
&& error.code == MatrixError.M_FORBIDDEN
@@ -53,13 +65,16 @@ fun Throwable.isInvalidUIAAuth(): Boolean {
* Try to convert to a RegistrationFlowResponse. Return null in the cases it's not possible
*/
fun Throwable.toRegistrationFlowResponse(): RegistrationFlowResponse? {
- return if (this is Failure.OtherServerError && httpCode == 401) {
+ return if (this is Failure.OtherServerError
+ && httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */) {
tryOrNull {
MoshiProvider.providesMoshi()
.adapter(RegistrationFlowResponse::class.java)
.fromJson(errorBody)
}
- } else if (this is Failure.ServerError && httpCode == 401 && error.code == MatrixError.M_FORBIDDEN) {
+ } else if (this is Failure.ServerError
+ && httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
+ && error.code == MatrixError.M_FORBIDDEN) {
// This happens when the submission for this stage was bad (like bad password)
if (error.session != null && error.flows != null) {
RegistrationFlowResponse(
@@ -75,3 +90,11 @@ fun Throwable.toRegistrationFlowResponse(): RegistrationFlowResponse? {
null
}
}
+
+fun Throwable.isRegistrationAvailabilityError(): Boolean {
+ return this is Failure.ServerError
+ && httpCode == HttpsURLConnection.HTTP_BAD_REQUEST /* 400 */
+ && (error.code == MatrixError.M_USER_IN_USE
+ || error.code == MatrixError.M_INVALID_USERNAME
+ || error.code == MatrixError.M_EXCLUSIVE)
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/pushrules/PushRuleService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/pushrules/PushRuleService.kt
index 4da1662681..d9bf5cfd13 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/pushrules/PushRuleService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/pushrules/PushRuleService.kt
@@ -39,6 +39,8 @@ interface PushRuleService {
fun removePushRuleListener(listener: PushRuleListener)
+ fun getActions(event: Event): List
+
// fun fulfilledBingRule(event: Event, rules: List): PushRule?
interface PushRuleListener {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomCategoryFilter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomCategoryFilter.kt
new file mode 100644
index 0000000000..c8ccc4c8a3
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomCategoryFilter.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.api.query
+
+enum class RoomCategoryFilter {
+ ONLY_DM,
+ ONLY_ROOMS,
+ ONLY_WITH_NOTIFICATIONS,
+ ALL
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomTagQueryFilter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomTagQueryFilter.kt
new file mode 100644
index 0000000000..613916bc18
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/RoomTagQueryFilter.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.api.query
+
+data class RoomTagQueryFilter(
+ val isFavorite: Boolean?,
+ val isLowPriority: Boolean?,
+ val isServerNotice: Boolean?
+)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt
index 7a24ccac11..a15799d862 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt
@@ -30,6 +30,7 @@ import org.matrix.android.sdk.api.session.call.CallSignalingService
import org.matrix.android.sdk.api.session.content.ContentUploadStateTracker
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
import org.matrix.android.sdk.api.session.crypto.CryptoService
+import org.matrix.android.sdk.api.session.events.EventService
import org.matrix.android.sdk.api.session.file.ContentDownloadStateTracker
import org.matrix.android.sdk.api.session.file.FileService
import org.matrix.android.sdk.api.session.group.GroupService
@@ -68,6 +69,7 @@ interface Session :
SignOutService,
FilterService,
TermsService,
+ EventService,
ProfileService,
PushRuleService,
PushersService,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/EventService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/EventService.kt
new file mode 100644
index 0000000000..297f277497
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/EventService.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.api.session.events
+
+import org.matrix.android.sdk.api.session.events.model.Event
+
+interface EventService {
+
+ /**
+ * Ask the homeserver for an event content. The SDK will try to decrypt it if it is possible
+ * The result will not be stored into cache
+ */
+ suspend fun getEvent(roomId: String,
+ eventId: String): Event
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt
index 844e8dbbab..89b873febb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt
@@ -289,3 +289,7 @@ fun Event.getRelationContent(): RelationDefaultContent? {
fun Event.isReply(): Boolean {
return getRelationContent()?.inReplyTo?.eventId != null
}
+
+fun Event.isEdition(): Boolean {
+ return getRelationContent()?.takeIf { it.type == RelationType.REPLACE }?.eventId != null
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt
index bc5cb3c8f4..22045366cb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt
@@ -17,12 +17,14 @@
package org.matrix.android.sdk.api.session.room
import androidx.lifecycle.LiveData
+import androidx.paging.PagedList
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
import org.matrix.android.sdk.api.session.room.peeking.PeekResult
+import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.internal.session.room.alias.RoomAliasDescription
@@ -170,4 +172,29 @@ interface RoomService {
* This call will try to gather some information on this room, but it could fail and get nothing more
*/
suspend fun peekRoom(roomIdOrAlias: String): PeekResult
+
+ /**
+ * TODO Doc
+ */
+ fun getPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
+ pagedListConfig: PagedList.Config = defaultPagedListConfig): LiveData>
+
+ /**
+ * TODO Doc
+ */
+ fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
+ pagedListConfig: PagedList.Config = defaultPagedListConfig): UpdatableFilterLivePageResult
+
+ /**
+ * TODO Doc
+ */
+ fun getNotificationCountForRooms(queryParams: RoomSummaryQueryParams): RoomAggregateNotificationCount
+
+ private val defaultPagedListConfig
+ get() = PagedList.Config.Builder()
+ .setPageSize(10)
+ .setInitialLoadSizeHint(20)
+ .setEnablePlaceholders(false)
+ .setPrefetchDistance(10)
+ .build()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt
index f859d74a6f..7e04ebb5f2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt
@@ -17,6 +17,8 @@
package org.matrix.android.sdk.api.session.room
import org.matrix.android.sdk.api.query.QueryStringValue
+import org.matrix.android.sdk.api.query.RoomCategoryFilter
+import org.matrix.android.sdk.api.query.RoomTagQueryFilter
import org.matrix.android.sdk.api.session.room.model.Membership
fun roomSummaryQueryParams(init: (RoomSummaryQueryParams.Builder.() -> Unit) = {}): RoomSummaryQueryParams {
@@ -31,7 +33,9 @@ data class RoomSummaryQueryParams(
val roomId: QueryStringValue,
val displayName: QueryStringValue,
val canonicalAlias: QueryStringValue,
- val memberships: List
+ val memberships: List,
+ val roomCategoryFilter: RoomCategoryFilter?,
+ val roomTagQueryFilter: RoomTagQueryFilter?
) {
class Builder {
@@ -40,12 +44,16 @@ data class RoomSummaryQueryParams(
var displayName: QueryStringValue = QueryStringValue.IsNotEmpty
var canonicalAlias: QueryStringValue = QueryStringValue.NoCondition
var memberships: List = Membership.all()
+ var roomCategoryFilter: RoomCategoryFilter? = RoomCategoryFilter.ALL
+ var roomTagQueryFilter: RoomTagQueryFilter? = null
fun build() = RoomSummaryQueryParams(
roomId = roomId,
displayName = displayName,
canonicalAlias = canonicalAlias,
- memberships = memberships
+ memberships = memberships,
+ roomCategoryFilter = roomCategoryFilter,
+ roomTagQueryFilter = roomTagQueryFilter
)
}
}
diff --git a/vector/src/main/java/im/vector/app/features/home/HomeRoomListDataSource.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/UpdatableFilterLivePageResult.kt
similarity index 60%
rename from vector/src/main/java/im/vector/app/features/home/HomeRoomListDataSource.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/UpdatableFilterLivePageResult.kt
index 6bcd6f01eb..71b3c665e7 100644
--- a/vector/src/main/java/im/vector/app/features/home/HomeRoomListDataSource.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/UpdatableFilterLivePageResult.kt
@@ -1,11 +1,11 @@
/*
- * Copyright 2019 New Vector Ltd
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,12 +14,14 @@
* limitations under the License.
*/
-package im.vector.app.features.home
+package org.matrix.android.sdk.api.session.room
-import im.vector.app.core.utils.BehaviorDataSource
+import androidx.lifecycle.LiveData
+import androidx.paging.PagedList
import org.matrix.android.sdk.api.session.room.model.RoomSummary
-import javax.inject.Inject
-import javax.inject.Singleton
-@Singleton
-class HomeRoomListDataSource @Inject constructor() : BehaviorDataSource>()
+interface UpdatableFilterLivePageResult {
+ val livePagedList: LiveData>
+
+ fun updateQuery(queryParams: RoomSummaryQueryParams)
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageType.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageType.kt
index a2b4e135d1..c96a800ee5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageType.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageType.kt
@@ -35,5 +35,5 @@ object MessageType {
const val MSGTYPE_STICKER_LOCAL = "org.matrix.android.sdk.sticker"
const val MSGTYPE_CONFETTI = "nic.custom.confetti"
- const val MSGTYPE_SNOW = "nic.custom.snow"
+ const val MSGTYPE_SNOW = "io.element.effect.snowfall"
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/summary/RoomAggregateNotificationCount.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/summary/RoomAggregateNotificationCount.kt
new file mode 100644
index 0000000000..066178b1ec
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/summary/RoomAggregateNotificationCount.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.api.session.room.summary
+
+data class RoomAggregateNotificationCount(
+ val notificationCount: Int,
+ val highlightCount: Int
+) {
+ val totalCount = notificationCount + highlightCount
+ val isHighlight = highlightCount > 0
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/AuthAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/AuthAPI.kt
index f92ae7e0ee..f93f285c6e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/AuthAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/AuthAPI.kt
@@ -17,6 +17,7 @@
package org.matrix.android.sdk.internal.auth
import org.matrix.android.sdk.api.auth.data.Credentials
+import org.matrix.android.sdk.internal.auth.data.Availability
import org.matrix.android.sdk.internal.auth.data.LoginFlowResponse
import org.matrix.android.sdk.internal.auth.data.PasswordLoginParams
import org.matrix.android.sdk.internal.auth.data.RiotConfig
@@ -29,12 +30,12 @@ import org.matrix.android.sdk.internal.auth.registration.SuccessResult
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
import org.matrix.android.sdk.internal.auth.version.Versions
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path
+import retrofit2.http.Query
import retrofit2.http.Url
/**
@@ -45,26 +46,32 @@ internal interface AuthAPI {
* Get a Riot config file, using the name including the domain
*/
@GET("config.{domain}.json")
- fun getRiotConfigDomain(@Path("domain") domain: String): Call
+ suspend fun getRiotConfigDomain(@Path("domain") domain: String): RiotConfig
/**
* Get a Riot config file
*/
@GET("config.json")
- fun getRiotConfig(): Call
+ suspend fun getRiotConfig(): RiotConfig
/**
* Get the version information of the homeserver
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
- fun versions(): Call
+ suspend fun versions(): Versions
/**
* Register to the homeserver, or get error 401 with a RegistrationFlowResponse object if registration is incomplete
* Ref: https://matrix.org/docs/spec/client_server/latest#account-registration-and-management
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register")
- fun register(@Body registrationParams: RegistrationParams): Call
+ suspend fun register(@Body registrationParams: RegistrationParams): Credentials
+
+ /**
+ * Checks to see if a username is available, and valid, for the server.
+ */
+ @GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register/available")
+ suspend fun registerAvailable(@Query("username") username: String): Availability
/**
* Add 3Pid during registration
@@ -72,22 +79,22 @@ internal interface AuthAPI {
* https://github.com/matrix-org/matrix-doc/pull/2290
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register/{threePid}/requestToken")
- fun add3Pid(@Path("threePid") threePid: String,
- @Body params: AddThreePidRegistrationParams): Call
+ suspend fun add3Pid(@Path("threePid") threePid: String,
+ @Body params: AddThreePidRegistrationParams): AddThreePidRegistrationResponse
/**
* Validate 3pid
*/
@POST
- fun validate3Pid(@Url url: String,
- @Body params: ValidationCodeBody): Call
+ suspend fun validate3Pid(@Url url: String,
+ @Body params: ValidationCodeBody): SuccessResult
/**
* Get the supported login flow
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
- fun getLoginFlows(): Call
+ suspend fun getLoginFlows(): LoginFlowResponse
/**
* Pass params to the server for the current login phase.
@@ -97,22 +104,22 @@ internal interface AuthAPI {
*/
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
- fun login(@Body loginParams: PasswordLoginParams): Call
+ suspend fun login(@Body loginParams: PasswordLoginParams): Credentials
// Unfortunately we cannot use interface for @Body parameter, so I duplicate the method for the type TokenLoginParams
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
- fun login(@Body loginParams: TokenLoginParams): Call
+ suspend fun login(@Body loginParams: TokenLoginParams): Credentials
/**
* Ask the homeserver to reset the password associated with the provided email.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password/email/requestToken")
- fun resetPassword(@Body params: AddThreePidRegistrationParams): Call
+ suspend fun resetPassword(@Body params: AddThreePidRegistrationParams): AddThreePidRegistrationResponse
/**
* Ask the homeserver to reset the password with the provided new password once the email is validated.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password")
- fun resetPasswordMailConfirmed(@Body params: ResetPasswordMailConfirmed): Call
+ suspend fun resetPasswordMailConfirmed(@Body params: ResetPasswordMailConfirmed)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt
index 4f3451cf30..e26286ad2f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt
@@ -31,7 +31,6 @@ import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.util.appendParamToUrl
import org.matrix.android.sdk.internal.SessionManager
-import org.matrix.android.sdk.internal.auth.data.LoginFlowResponse
import org.matrix.android.sdk.internal.auth.data.RiotConfig
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
import org.matrix.android.sdk.internal.auth.login.DefaultLoginWizard
@@ -172,8 +171,8 @@ internal class DefaultAuthenticationService @Inject constructor(
// First check the homeserver version
return runCatching {
- executeRequest(null) {
- apiCall = authAPI.versions()
+ executeRequest(null) {
+ authAPI.versions()
}
}
.map { versions ->
@@ -204,8 +203,8 @@ internal class DefaultAuthenticationService @Inject constructor(
// Ok, try to get the config.domain.json file of a RiotWeb client
return runCatching {
- executeRequest(null) {
- apiCall = authAPI.getRiotConfigDomain(domain)
+ executeRequest(null) {
+ authAPI.getRiotConfigDomain(domain)
}
}
.map { riotConfig ->
@@ -232,8 +231,8 @@ internal class DefaultAuthenticationService @Inject constructor(
// Ok, try to get the config.json file of a RiotWeb client
return runCatching {
- executeRequest(null) {
- apiCall = authAPI.getRiotConfig()
+ executeRequest(null) {
+ authAPI.getRiotConfig()
}
}
.map { riotConfig ->
@@ -265,8 +264,8 @@ internal class DefaultAuthenticationService @Inject constructor(
val newAuthAPI = buildAuthAPI(newHomeServerConnectionConfig)
- val versions = executeRequest(null) {
- apiCall = newAuthAPI.versions()
+ val versions = executeRequest(null) {
+ newAuthAPI.versions()
}
return getLoginFlowResult(newAuthAPI, versions, defaultHomeServerUrl)
@@ -293,8 +292,8 @@ internal class DefaultAuthenticationService @Inject constructor(
val newAuthAPI = buildAuthAPI(newHomeServerConnectionConfig)
- val versions = executeRequest(null) {
- apiCall = newAuthAPI.versions()
+ val versions = executeRequest(null) {
+ newAuthAPI.versions()
}
getLoginFlowResult(newAuthAPI, versions, wellknownResult.homeServerUrl)
@@ -305,8 +304,8 @@ internal class DefaultAuthenticationService @Inject constructor(
private suspend fun getLoginFlowResult(authAPI: AuthAPI, versions: Versions, homeServerUrl: String): LoginFlowResult {
// Get the login flow
- val loginFlowResponse = executeRequest(null) {
- apiCall = authAPI.getLoginFlows()
+ val loginFlowResponse = executeRequest(null) {
+ authAPI.getLoginFlows()
}
return LoginFlowResult.Success(
loginFlowResponse.flows.orEmpty().mapNotNull { it.type },
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/IsValidClientServerApiTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/IsValidClientServerApiTask.kt
index b8416d69bf..867cf46b8d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/IsValidClientServerApiTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/IsValidClientServerApiTask.kt
@@ -20,7 +20,6 @@ import dagger.Lazy
import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.failure.Failure
-import org.matrix.android.sdk.internal.auth.data.LoginFlowResponse
import org.matrix.android.sdk.internal.di.Unauthenticated
import org.matrix.android.sdk.internal.network.RetrofitFactory
import org.matrix.android.sdk.internal.network.executeRequest
@@ -49,8 +48,8 @@ internal class DefaultIsValidClientServerApiTask @Inject constructor(
.create(AuthAPI::class.java)
return try {
- executeRequest(null) {
- apiCall = authAPI.getLoginFlows()
+ executeRequest(null) {
+ authAPI.getLoginFlows()
}
// We get a response, so the API is valid
true
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/data/Availability.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/data/Availability.kt
new file mode 100644
index 0000000000..5ef3c0d06a
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/data/Availability.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.internal.auth.data
+
+import com.squareup.moshi.Json
+import com.squareup.moshi.JsonClass
+
+@JsonClass(generateAdapter = true)
+internal data class Availability(
+ /**
+ * A flag to indicate that the username is available. This should always be true when the server replies with 200 OK.
+ */
+ @Json(name = "available")
+ val available: Boolean? = null
+)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DefaultLoginWizard.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DefaultLoginWizard.kt
index 4167875849..8b81f42e03 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DefaultLoginWizard.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DefaultLoginWizard.kt
@@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.auth.login
import android.util.Patterns
-import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.auth.login.LoginWizard
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid
import org.matrix.android.sdk.api.session.Session
@@ -29,7 +28,6 @@ import org.matrix.android.sdk.internal.auth.data.ThreePidMedium
import org.matrix.android.sdk.internal.auth.data.TokenLoginParams
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationParams
-import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationResponse
import org.matrix.android.sdk.internal.auth.registration.RegisterAddThreePidTask
import org.matrix.android.sdk.internal.network.executeRequest
@@ -49,8 +47,8 @@ internal class DefaultLoginWizard(
} else {
PasswordLoginParams.userIdentifier(login, password, deviceName)
}
- val credentials = executeRequest(null) {
- apiCall = authAPI.login(loginParams)
+ val credentials = executeRequest(null) {
+ authAPI.login(loginParams)
}
return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
@@ -63,8 +61,8 @@ internal class DefaultLoginWizard(
val loginParams = TokenLoginParams(
token = loginToken
)
- val credentials = executeRequest(null) {
- apiCall = authAPI.login(loginParams)
+ val credentials = executeRequest(null) {
+ authAPI.login(loginParams)
}
return sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
@@ -80,8 +78,8 @@ internal class DefaultLoginWizard(
pendingSessionData = pendingSessionData.copy(sendAttempt = pendingSessionData.sendAttempt + 1)
.also { pendingSessionStore.savePendingSessionData(it) }
- val result = executeRequest(null) {
- apiCall = authAPI.resetPassword(AddThreePidRegistrationParams.from(param))
+ val result = executeRequest(null) {
+ authAPI.resetPassword(AddThreePidRegistrationParams.from(param))
}
pendingSessionData = pendingSessionData.copy(resetPasswordData = ResetPasswordData(newPassword, result))
@@ -98,8 +96,8 @@ internal class DefaultLoginWizard(
safeResetPasswordData.newPassword
)
- executeRequest(null) {
- apiCall = authAPI.resetPasswordMailConfirmed(param)
+ executeRequest(null) {
+ authAPI.resetPasswordMailConfirmed(param)
}
// Set to null?
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt
index be6ff38931..77bbb8096f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt
@@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.auth.login
import dagger.Lazy
-import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.Session
@@ -59,19 +58,16 @@ internal class DefaultDirectLoginTask @Inject constructor(
val loginParams = PasswordLoginParams.userIdentifier(params.userId, params.password, params.deviceName)
val credentials = try {
- executeRequest(null) {
- apiCall = authAPI.login(loginParams)
+ executeRequest(null) {
+ authAPI.login(loginParams)
}
} catch (throwable: Throwable) {
- when (throwable) {
- is UnrecognizedCertificateException -> {
- throw Failure.UnrecognizedCertificateFailure(
- homeServerUrl,
- throwable.fingerprint
- )
- }
- else ->
- throw throwable
+ throw when (throwable) {
+ is UnrecognizedCertificateException -> Failure.UnrecognizedCertificateFailure(
+ homeServerUrl,
+ throwable.fingerprint
+ )
+ else -> throwable
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/DefaultRegistrationWizard.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/DefaultRegistrationWizard.kt
index 91e414e689..4a3d53a8fc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/DefaultRegistrationWizard.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/DefaultRegistrationWizard.kt
@@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.auth.registration
import kotlinx.coroutines.delay
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid
+import org.matrix.android.sdk.api.auth.registration.RegistrationAvailability
import org.matrix.android.sdk.api.auth.registration.RegistrationResult
import org.matrix.android.sdk.api.auth.registration.RegistrationWizard
import org.matrix.android.sdk.api.auth.registration.toFlowResult
@@ -40,9 +41,10 @@ internal class DefaultRegistrationWizard(
private var pendingSessionData: PendingSessionData = pendingSessionStore.getPendingSessionData() ?: error("Pending session data should exist here")
- private val registerTask = DefaultRegisterTask(authAPI)
- private val registerAddThreePidTask = DefaultRegisterAddThreePidTask(authAPI)
- private val validateCodeTask = DefaultValidateCodeTask(authAPI)
+ private val registerTask: RegisterTask = DefaultRegisterTask(authAPI)
+ private val registerAvailableTask: RegisterAvailableTask = DefaultRegisterAvailableTask(authAPI)
+ private val registerAddThreePidTask: RegisterAddThreePidTask = DefaultRegisterAddThreePidTask(authAPI)
+ private val validateCodeTask: ValidateCodeTask = DefaultValidateCodeTask(authAPI)
override val currentThreePid: String?
get() {
@@ -203,4 +205,8 @@ internal class DefaultRegistrationWizard(
val session = sessionCreator.createSession(credentials, pendingSessionData.homeServerConnectionConfig)
return RegistrationResult.Success(session)
}
+
+ override suspend fun registrationAvailable(userName: String): RegistrationAvailability {
+ return registerAvailableTask.execute(RegisterAvailableTask.Params(userName))
+ }
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAddThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAddThreePidTask.kt
index 57c4b72b8a..54a8ba0e6c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAddThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAddThreePidTask.kt
@@ -35,7 +35,7 @@ internal class DefaultRegisterAddThreePidTask(
override suspend fun execute(params: RegisterAddThreePidTask.Params): AddThreePidRegistrationResponse {
return executeRequest(null) {
- apiCall = authAPI.add3Pid(params.threePid.toPath(), AddThreePidRegistrationParams.from(params))
+ authAPI.add3Pid(params.threePid.toPath(), AddThreePidRegistrationParams.from(params))
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAvailableTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAvailableTask.kt
new file mode 100644
index 0000000000..314a24dad4
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAvailableTask.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.internal.auth.registration
+
+import org.matrix.android.sdk.api.auth.registration.RegistrationAvailability
+import org.matrix.android.sdk.api.failure.Failure
+import org.matrix.android.sdk.api.failure.isRegistrationAvailabilityError
+import org.matrix.android.sdk.internal.auth.AuthAPI
+import org.matrix.android.sdk.internal.network.executeRequest
+import org.matrix.android.sdk.internal.task.Task
+
+internal interface RegisterAvailableTask : Task {
+ data class Params(
+ val userName: String
+ )
+}
+
+internal class DefaultRegisterAvailableTask(private val authAPI: AuthAPI) : RegisterAvailableTask {
+ override suspend fun execute(params: RegisterAvailableTask.Params): RegistrationAvailability {
+ return try {
+ executeRequest(null) {
+ authAPI.registerAvailable(params.userName)
+ }
+ RegistrationAvailability.Available
+ } catch (exception: Throwable) {
+ if (exception.isRegistrationAvailabilityError()) {
+ RegistrationAvailability.NotAvailable(exception as Failure.ServerError)
+ } else {
+ throw exception
+ }
+ }
+ }
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterTask.kt
index bf5d899276..45668cb8ad 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterTask.kt
@@ -36,7 +36,7 @@ internal class DefaultRegisterTask(
override suspend fun execute(params: RegisterTask.Params): Credentials {
try {
return executeRequest(null) {
- apiCall = authAPI.register(params.registrationParams)
+ authAPI.register(params.registrationParams)
}
} catch (throwable: Throwable) {
throw throwable.toRegistrationFlowResponse()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/ValidateCodeTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/ValidateCodeTask.kt
index b297c9849d..d68b7cd9eb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/ValidateCodeTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/ValidateCodeTask.kt
@@ -33,7 +33,7 @@ internal class DefaultValidateCodeTask(
override suspend fun execute(params: ValidateCodeTask.Params): SuccessResult {
return executeRequest(null) {
- apiCall = authAPI.validate3Pid(params.url, params.body)
+ authAPI.validate3Pid(params.url, params.body)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/api/CryptoApi.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/api/CryptoApi.kt
index 5604e97152..cef86e8b5e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/api/CryptoApi.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/api/CryptoApi.kt
@@ -30,7 +30,6 @@ import org.matrix.android.sdk.internal.crypto.model.rest.SignatureUploadResponse
import org.matrix.android.sdk.internal.crypto.model.rest.UpdateDeviceInfoBody
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.HTTP
@@ -46,14 +45,14 @@ internal interface CryptoApi {
* Doc: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices")
- fun getDevices(): Call
+ suspend fun getDevices(): DevicesListResponse
/**
* Get the device info by id
* Doc: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices-deviceid
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{deviceId}")
- fun getDeviceInfo(@Path("deviceId") deviceId: String): Call
+ suspend fun getDeviceInfo(@Path("deviceId") deviceId: String): DeviceInfo
/**
* Upload device and/or one-time keys.
@@ -62,7 +61,7 @@ internal interface CryptoApi {
* @param body the keys to be sent.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/upload")
- fun uploadKeys(@Body body: KeysUploadBody): Call
+ suspend fun uploadKeys(@Body body: KeysUploadBody): KeysUploadResponse
/**
* Download device keys.
@@ -71,7 +70,7 @@ internal interface CryptoApi {
* @param params the params.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/query")
- fun downloadKeysForUsers(@Body params: KeysQueryBody): Call
+ suspend fun downloadKeysForUsers(@Body params: KeysQueryBody): KeysQueryResponse
/**
* CrossSigning - Uploading signing keys
@@ -79,7 +78,7 @@ internal interface CryptoApi {
* This endpoint requires UI Auth.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "keys/device_signing/upload")
- fun uploadSigningKeys(@Body params: UploadSigningKeysBody): Call
+ suspend fun uploadSigningKeys(@Body params: UploadSigningKeysBody): KeysQueryResponse
/**
* CrossSigning - Uploading signatures
@@ -98,7 +97,7 @@ internal interface CryptoApi {
* However, signatures made for other users' keys, made by her user-signing key, will not be included.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "keys/signatures/upload")
- fun uploadSignatures(@Body params: Map?): Call
+ suspend fun uploadSignatures(@Body params: Map?): SignatureUploadResponse
/**
* Claim one-time keys.
@@ -107,7 +106,7 @@ internal interface CryptoApi {
* @param params the params.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/claim")
- fun claimOneTimeKeysForUsersDevices(@Body body: KeysClaimBody): Call
+ suspend fun claimOneTimeKeysForUsersDevices(@Body body: KeysClaimBody): KeysClaimResponse
/**
* Send an event to a specific list of devices
@@ -118,9 +117,9 @@ internal interface CryptoApi {
* @param body the body
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "sendToDevice/{eventType}/{txnId}")
- fun sendToDevice(@Path("eventType") eventType: String,
- @Path("txnId") transactionId: String,
- @Body body: SendToDeviceBody): Call
+ suspend fun sendToDevice(@Path("eventType") eventType: String,
+ @Path("txnId") transactionId: String,
+ @Body body: SendToDeviceBody)
/**
* Delete a device.
@@ -130,8 +129,8 @@ internal interface CryptoApi {
* @param params the deletion parameters
*/
@HTTP(path = NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{device_id}", method = "DELETE", hasBody = true)
- fun deleteDevice(@Path("device_id") deviceId: String,
- @Body params: DeleteDeviceParams): Call
+ suspend fun deleteDevice(@Path("device_id") deviceId: String,
+ @Body params: DeleteDeviceParams)
/**
* Update the device information.
@@ -141,8 +140,8 @@ internal interface CryptoApi {
* @param params the params
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{device_id}")
- fun updateDeviceInfo(@Path("device_id") deviceId: String,
- @Body params: UpdateDeviceInfoBody): Call
+ suspend fun updateDeviceInfo(@Path("device_id") deviceId: String,
+ @Body params: UpdateDeviceInfoBody)
/**
* Get the update devices list from two sync token.
@@ -152,6 +151,6 @@ internal interface CryptoApi {
* @param newToken the up-to token.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/changes")
- fun getKeyChanges(@Query("from") oldToken: String,
- @Query("to") newToken: String): Call
+ suspend fun getKeyChanges(@Query("from") oldToken: String,
+ @Query("to") newToken: String): KeyChangesResponse
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/api/RoomKeysApi.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/api/RoomKeysApi.kt
index 3f8333528f..eb4c55a3e7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/api/RoomKeysApi.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/api/RoomKeysApi.kt
@@ -25,7 +25,6 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionR
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.RoomKeysBackupData
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.UpdateKeysBackupVersionBody
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
@@ -48,14 +47,14 @@ internal interface RoomKeysApi {
* @param createKeysBackupVersionBody the body
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version")
- fun createKeysBackupVersion(@Body createKeysBackupVersionBody: CreateKeysBackupVersionBody): Call
+ suspend fun createKeysBackupVersion(@Body createKeysBackupVersionBody: CreateKeysBackupVersionBody): KeysVersion
/**
* Get the key backup last version
* If not supported by the server, an error is returned: {"errcode":"M_NOT_FOUND","error":"No backup found"}
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version")
- fun getKeysBackupLastVersion(): Call
+ suspend fun getKeysBackupLastVersion(): KeysVersionResult
/**
* Get information about the given version.
@@ -64,7 +63,7 @@ internal interface RoomKeysApi {
* @param version version
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
- fun getKeysBackupVersion(@Path("version") version: String): Call
+ suspend fun getKeysBackupVersion(@Path("version") version: String): KeysVersionResult
/**
* Update information about the given version.
@@ -72,8 +71,8 @@ internal interface RoomKeysApi {
* @param updateKeysBackupVersionBody the body
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
- fun updateKeysBackupVersion(@Path("version") version: String,
- @Body keysBackupVersionBody: UpdateKeysBackupVersionBody): Call
+ suspend fun updateKeysBackupVersion(@Path("version") version: String,
+ @Body keysBackupVersionBody: UpdateKeysBackupVersionBody)
/* ==========================================================================================
* Storing keys
@@ -94,10 +93,10 @@ internal interface RoomKeysApi {
* @param keyBackupData the data to send
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
- fun storeRoomSessionData(@Path("roomId") roomId: String,
- @Path("sessionId") sessionId: String,
- @Query("version") version: String,
- @Body keyBackupData: KeyBackupData): Call
+ suspend fun storeRoomSessionData(@Path("roomId") roomId: String,
+ @Path("sessionId") sessionId: String,
+ @Query("version") version: String,
+ @Body keyBackupData: KeyBackupData): BackupKeysResult
/**
* Store several keys for the given room, using the given backup version.
@@ -107,9 +106,9 @@ internal interface RoomKeysApi {
* @param roomKeysBackupData the data to send
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
- fun storeRoomSessionsData(@Path("roomId") roomId: String,
- @Query("version") version: String,
- @Body roomKeysBackupData: RoomKeysBackupData): Call
+ suspend fun storeRoomSessionsData(@Path("roomId") roomId: String,
+ @Query("version") version: String,
+ @Body roomKeysBackupData: RoomKeysBackupData): BackupKeysResult
/**
* Store several keys, using the given backup version.
@@ -118,8 +117,8 @@ internal interface RoomKeysApi {
* @param keysBackupData the data to send
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
- fun storeSessionsData(@Query("version") version: String,
- @Body keysBackupData: KeysBackupData): Call
+ suspend fun storeSessionsData(@Query("version") version: String,
+ @Body keysBackupData: KeysBackupData): BackupKeysResult
/* ==========================================================================================
* Retrieving keys
@@ -133,9 +132,9 @@ internal interface RoomKeysApi {
* @param version the version of the backup, or empty String to retrieve the last version
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
- fun getRoomSessionData(@Path("roomId") roomId: String,
- @Path("sessionId") sessionId: String,
- @Query("version") version: String): Call
+ suspend fun getRoomSessionData(@Path("roomId") roomId: String,
+ @Path("sessionId") sessionId: String,
+ @Query("version") version: String): KeyBackupData
/**
* Retrieve all the keys for the given room from the backup.
@@ -144,8 +143,8 @@ internal interface RoomKeysApi {
* @param version the version of the backup, or empty String to retrieve the last version
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
- fun getRoomSessionsData(@Path("roomId") roomId: String,
- @Query("version") version: String): Call
+ suspend fun getRoomSessionsData(@Path("roomId") roomId: String,
+ @Query("version") version: String): RoomKeysBackupData
/**
* Retrieve all the keys from the backup.
@@ -153,7 +152,7 @@ internal interface RoomKeysApi {
* @param version the version of the backup, or empty String to retrieve the last version
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
- fun getSessionsData(@Query("version") version: String): Call
+ suspend fun getSessionsData(@Query("version") version: String): KeysBackupData
/* ==========================================================================================
* Deleting keys
@@ -163,22 +162,22 @@ internal interface RoomKeysApi {
* Deletes keys from the backup.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
- fun deleteRoomSessionData(@Path("roomId") roomId: String,
- @Path("sessionId") sessionId: String,
- @Query("version") version: String): Call
+ suspend fun deleteRoomSessionData(@Path("roomId") roomId: String,
+ @Path("sessionId") sessionId: String,
+ @Query("version") version: String)
/**
* Deletes keys from the backup.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
- fun deleteRoomSessionsData(@Path("roomId") roomId: String,
- @Query("version") version: String): Call
+ suspend fun deleteRoomSessionsData(@Path("roomId") roomId: String,
+ @Query("version") version: String)
/**
* Deletes keys from the backup.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
- fun deleteSessionsData(@Query("version") version: String): Call
+ suspend fun deleteSessionsData(@Query("version") version: String)
/* ==========================================================================================
* Deleting backup
@@ -188,5 +187,5 @@ internal interface RoomKeysApi {
* Deletes a backup.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
- fun deleteBackup(@Path("version") version: String): Call
+ suspend fun deleteBackup(@Path("version") version: String)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/CreateKeysBackupVersionTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/CreateKeysBackupVersionTask.kt
index 5c59cfd80e..62610a0b7b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/CreateKeysBackupVersionTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/CreateKeysBackupVersionTask.kt
@@ -33,7 +33,7 @@ internal class DefaultCreateKeysBackupVersionTask @Inject constructor(
override suspend fun execute(params: CreateKeysBackupVersionBody): KeysVersion {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.createKeysBackupVersion(params)
+ roomKeysApi.createKeysBackupVersion(params)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteBackupTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteBackupTask.kt
index ec09da7240..7ee6f2358d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteBackupTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteBackupTask.kt
@@ -35,7 +35,7 @@ internal class DefaultDeleteBackupTask @Inject constructor(
override suspend fun execute(params: DeleteBackupTask.Params) {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.deleteBackup(params.version)
+ roomKeysApi.deleteBackup(params.version)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionDataTask.kt
index 9c477efb78..7f1b03b932 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionDataTask.kt
@@ -37,7 +37,7 @@ internal class DefaultDeleteRoomSessionDataTask @Inject constructor(
override suspend fun execute(params: DeleteRoomSessionDataTask.Params) {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.deleteRoomSessionData(
+ roomKeysApi.deleteRoomSessionData(
params.roomId,
params.sessionId,
params.version)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionsDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionsDataTask.kt
index 82d022f3ab..394cc861d6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionsDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionsDataTask.kt
@@ -36,7 +36,7 @@ internal class DefaultDeleteRoomSessionsDataTask @Inject constructor(
override suspend fun execute(params: DeleteRoomSessionsDataTask.Params) {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.deleteRoomSessionsData(
+ roomKeysApi.deleteRoomSessionsData(
params.roomId,
params.version)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteSessionsDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteSessionsDataTask.kt
index e4df379963..808c6c9956 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteSessionsDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteSessionsDataTask.kt
@@ -35,7 +35,7 @@ internal class DefaultDeleteSessionsDataTask @Inject constructor(
override suspend fun execute(params: DeleteSessionsDataTask.Params) {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.deleteSessionsData(params.version)
+ roomKeysApi.deleteSessionsData(params.version)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupLastVersionTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupLastVersionTask.kt
index 3566ff0e68..54dbf85e30 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupLastVersionTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupLastVersionTask.kt
@@ -32,7 +32,7 @@ internal class DefaultGetKeysBackupLastVersionTask @Inject constructor(
override suspend fun execute(params: Unit): KeysVersionResult {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.getKeysBackupLastVersion()
+ roomKeysApi.getKeysBackupLastVersion()
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupVersionTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupVersionTask.kt
index 13c99fb0f4..390873eb68 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupVersionTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupVersionTask.kt
@@ -32,7 +32,7 @@ internal class DefaultGetKeysBackupVersionTask @Inject constructor(
override suspend fun execute(params: String): KeysVersionResult {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.getKeysBackupVersion(params)
+ roomKeysApi.getKeysBackupVersion(params)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionDataTask.kt
index 168020d9cd..ff515ed80f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionDataTask.kt
@@ -38,7 +38,7 @@ internal class DefaultGetRoomSessionDataTask @Inject constructor(
override suspend fun execute(params: GetRoomSessionDataTask.Params): KeyBackupData {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.getRoomSessionData(
+ roomKeysApi.getRoomSessionData(
params.roomId,
params.sessionId,
params.version)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionsDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionsDataTask.kt
index 95d5ef2e53..1b4fe2d966 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionsDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionsDataTask.kt
@@ -37,7 +37,7 @@ internal class DefaultGetRoomSessionsDataTask @Inject constructor(
override suspend fun execute(params: GetRoomSessionsDataTask.Params): RoomKeysBackupData {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.getRoomSessionsData(
+ roomKeysApi.getRoomSessionsData(
params.roomId,
params.version)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetSessionsDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetSessionsDataTask.kt
index e41a13e3eb..707125f4cd 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetSessionsDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetSessionsDataTask.kt
@@ -36,7 +36,7 @@ internal class DefaultGetSessionsDataTask @Inject constructor(
override suspend fun execute(params: GetSessionsDataTask.Params): KeysBackupData {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.getSessionsData(params.version)
+ roomKeysApi.getSessionsData(params.version)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreRoomSessionDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreRoomSessionDataTask.kt
index 3954277e39..180aaecf82 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreRoomSessionDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreRoomSessionDataTask.kt
@@ -40,7 +40,7 @@ internal class DefaultStoreRoomSessionDataTask @Inject constructor(
override suspend fun execute(params: StoreRoomSessionDataTask.Params): BackupKeysResult {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.storeRoomSessionData(
+ roomKeysApi.storeRoomSessionData(
params.roomId,
params.sessionId,
params.version,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreRoomSessionsDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreRoomSessionsDataTask.kt
index 4e209b4abc..d1aa9d2eb0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreRoomSessionsDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreRoomSessionsDataTask.kt
@@ -39,7 +39,7 @@ internal class DefaultStoreRoomSessionsDataTask @Inject constructor(
override suspend fun execute(params: StoreRoomSessionsDataTask.Params): BackupKeysResult {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.storeRoomSessionsData(
+ roomKeysApi.storeRoomSessionsData(
params.roomId,
params.version,
params.roomKeysBackupData)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreSessionsDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreSessionsDataTask.kt
index a607477d21..3dbeafe9de 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreSessionsDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/StoreSessionsDataTask.kt
@@ -38,7 +38,7 @@ internal class DefaultStoreSessionsDataTask @Inject constructor(
override suspend fun execute(params: StoreSessionsDataTask.Params): BackupKeysResult {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.storeSessionsData(
+ roomKeysApi.storeSessionsData(
params.version,
params.keysBackupData)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/UpdateKeysBackupVersionTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/UpdateKeysBackupVersionTask.kt
index f012cd13eb..2b3d044ab7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/UpdateKeysBackupVersionTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/UpdateKeysBackupVersionTask.kt
@@ -37,7 +37,7 @@ internal class DefaultUpdateKeysBackupVersionTask @Inject constructor(
override suspend fun execute(params: UpdateKeysBackupVersionTask.Params) {
return executeRequest(globalErrorReceiver) {
- apiCall = roomKeysApi.updateKeysBackupVersion(params.version, params.keysBackupVersionBody)
+ roomKeysApi.updateKeysBackupVersion(params.version, params.keysBackupVersionBody)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/ClaimOneTimeKeysForUsersDeviceTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/ClaimOneTimeKeysForUsersDeviceTask.kt
index 3df6312adb..d5cf749db7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/ClaimOneTimeKeysForUsersDeviceTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/ClaimOneTimeKeysForUsersDeviceTask.kt
@@ -20,7 +20,6 @@ import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.MXKey
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.internal.crypto.model.rest.KeysClaimBody
-import org.matrix.android.sdk.internal.crypto.model.rest.KeysClaimResponse
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
@@ -42,8 +41,8 @@ internal class DefaultClaimOneTimeKeysForUsersDevice @Inject constructor(
override suspend fun execute(params: ClaimOneTimeKeysForUsersDeviceTask.Params): MXUsersDevicesMap {
val body = KeysClaimBody(oneTimeKeys = params.usersDevicesKeyTypesMap.map)
- val keysClaimResponse = executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.claimOneTimeKeysForUsersDevices(body)
+ val keysClaimResponse = executeRequest(globalErrorReceiver) {
+ cryptoApi.claimOneTimeKeysForUsersDevices(body)
}
val map = MXUsersDevicesMap()
keysClaimResponse.oneTimeKeys?.let { oneTimeKeys ->
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
index 61596bb5b6..bdb8e8d137 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
@@ -42,8 +42,8 @@ internal class DefaultDeleteDeviceTask @Inject constructor(
override suspend fun execute(params: DeleteDeviceTask.Params) {
try {
- executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.deleteDevice(params.deviceId, DeleteDeviceParams(params.userAuthParam?.asMap()))
+ executeRequest(globalErrorReceiver) {
+ cryptoApi.deleteDevice(params.deviceId, DeleteDeviceParams(params.userAuthParam?.asMap()))
}
} catch (throwable: Throwable) {
if (params.userInteractiveAuthInterceptor == null
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DownloadKeysForUsersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DownloadKeysForUsersTask.kt
index 0c17cbb43a..86f02866ae 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DownloadKeysForUsersTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DownloadKeysForUsersTask.kt
@@ -72,8 +72,8 @@ internal class DefaultDownloadKeysForUsers @Inject constructor(
}
.map { body ->
async {
- val result = executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.downloadKeysForUsers(body)
+ val result = executeRequest(globalErrorReceiver) {
+ cryptoApi.downloadKeysForUsers(body)
}
mutex.withLock {
@@ -98,7 +98,7 @@ internal class DefaultDownloadKeysForUsers @Inject constructor(
} else {
// No need to chunk, direct request
executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.downloadKeysForUsers(
+ cryptoApi.downloadKeysForUsers(
KeysQueryBody(
deviceKeys = params.userIds.associateWith { emptyList() },
token = token
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetDeviceInfoTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetDeviceInfoTask.kt
index 5f6d2e344f..9f20ea598d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetDeviceInfoTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetDeviceInfoTask.kt
@@ -34,7 +34,7 @@ internal class DefaultGetDeviceInfoTask @Inject constructor(
override suspend fun execute(params: GetDeviceInfoTask.Params): DeviceInfo {
return executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.getDeviceInfo(params.deviceId)
+ cryptoApi.getDeviceInfo(params.deviceId)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetDevicesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetDevicesTask.kt
index ea33a918bc..52f9f73299 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetDevicesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetDevicesTask.kt
@@ -32,7 +32,7 @@ internal class DefaultGetDevicesTask @Inject constructor(
override suspend fun execute(params: Unit): DevicesListResponse {
return executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.getDevices()
+ cryptoApi.getDevices()
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetKeyChangesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetKeyChangesTask.kt
index 4cc9ab2fcb..6e524c7fbe 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetKeyChangesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetKeyChangesTask.kt
@@ -39,7 +39,7 @@ internal class DefaultGetKeyChangesTask @Inject constructor(
override suspend fun execute(params: GetKeyChangesTask.Params): KeyChangesResponse {
return executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.getKeyChanges(params.from, params.to)
+ cryptoApi.getKeyChanges(params.from, params.to)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/RedactEventTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/RedactEventTask.kt
index 5226e52b33..d6a7f3c6a0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/RedactEventTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/RedactEventTask.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.crypto.tasks
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
-import org.matrix.android.sdk.internal.session.room.send.SendResponse
import org.matrix.android.sdk.internal.task.Task
import javax.inject.Inject
@@ -36,14 +35,14 @@ internal class DefaultRedactEventTask @Inject constructor(
private val globalErrorReceiver: GlobalErrorReceiver) : RedactEventTask {
override suspend fun execute(params: RedactEventTask.Params): String {
- val executeRequest = executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.redactEvent(
+ val response = executeRequest(globalErrorReceiver) {
+ roomAPI.redactEvent(
txId = params.txID,
roomId = params.roomId,
eventId = params.eventId,
reason = if (params.reason == null) emptyMap() else mapOf("reason" to params.reason)
)
}
- return executeRequest.eventId
+ return response.eventId
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendEventTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendEventTask.kt
index 573f2c3a54..e1e297767b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendEventTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendEventTask.kt
@@ -22,7 +22,6 @@ import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.session.room.membership.LoadRoomMembersTask
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
-import org.matrix.android.sdk.internal.session.room.send.SendResponse
import org.matrix.android.sdk.internal.task.Task
import javax.inject.Inject
@@ -52,8 +51,8 @@ internal class DefaultSendEventTask @Inject constructor(
val event = handleEncryption(params)
val localId = event.eventId!!
localEchoRepository.updateSendState(localId, params.event.roomId, SendState.SENDING)
- val executeRequest = executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.send(
+ val response = executeRequest(globalErrorReceiver) {
+ roomAPI.send(
localId,
roomId = event.roomId ?: "",
content = event.content,
@@ -61,7 +60,7 @@ internal class DefaultSendEventTask @Inject constructor(
)
}
localEchoRepository.updateSendState(localId, params.event.roomId, SendState.SENT)
- return executeRequest.eventId
+ return response.eventId
} catch (e: Throwable) {
// localEchoRepository.updateSendState(params.event.eventId!!, SendState.UNDELIVERED)
throw e
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt
index d2af91601b..41a5118be0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt
@@ -46,14 +46,16 @@ internal class DefaultSendToDeviceTask @Inject constructor(
messages = params.contentMap.map
)
- return executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.sendToDevice(
+ return executeRequest(
+ globalErrorReceiver,
+ canRetry = true,
+ maxRetriesCount = 3
+ ) {
+ cryptoApi.sendToDevice(
params.eventType,
params.transactionId ?: Random.nextInt(Integer.MAX_VALUE).toString(),
sendToDeviceBody
)
- isRetryable = true
- maxRetryCount = 3
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendVerificationMessageTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendVerificationMessageTask.kt
index ab125135bb..d8b9d3cd86 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendVerificationMessageTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendVerificationMessageTask.kt
@@ -22,7 +22,6 @@ import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
-import org.matrix.android.sdk.internal.session.room.send.SendResponse
import org.matrix.android.sdk.internal.task.Task
import javax.inject.Inject
@@ -45,8 +44,8 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
try {
localEchoRepository.updateSendState(localId, event.roomId, SendState.SENDING)
- val executeRequest = executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.send(
+ val response = executeRequest(globalErrorReceiver) {
+ roomAPI.send(
localId,
roomId = event.roomId ?: "",
content = event.content,
@@ -54,7 +53,7 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
)
}
localEchoRepository.updateSendState(localId, event.roomId, SendState.SENT)
- return executeRequest.eventId
+ return response.eventId
} catch (e: Throwable) {
localEchoRepository.updateSendState(localId, event.roomId, SendState.UNDELIVERED)
throw e
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SetDeviceNameTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SetDeviceNameTask.kt
index b835d46236..4bedb1f393 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SetDeviceNameTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SetDeviceNameTask.kt
@@ -42,7 +42,7 @@ internal class DefaultSetDeviceNameTask @Inject constructor(
displayName = params.deviceName
)
return executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.updateDeviceInfo(params.deviceId, body)
+ cryptoApi.updateDeviceInfo(params.deviceId, body)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt
index eb53bbbf8d..cac4dadd93 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt
@@ -50,7 +50,7 @@ internal class DefaultUploadKeysTask @Inject constructor(
Timber.i("## Uploading device keys -> $body")
return executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.uploadKeys(body)
+ cryptoApi.uploadKeys(body)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSignaturesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSignaturesTask.kt
index c50faf37b1..e03e353cb1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSignaturesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSignaturesTask.kt
@@ -17,7 +17,6 @@ package org.matrix.android.sdk.internal.crypto.tasks
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
-import org.matrix.android.sdk.internal.crypto.model.rest.SignatureUploadResponse
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
@@ -36,10 +35,12 @@ internal class DefaultUploadSignaturesTask @Inject constructor(
override suspend fun execute(params: UploadSignaturesTask.Params) {
try {
- val response = executeRequest(globalErrorReceiver) {
- this.isRetryable = true
- this.maxRetryCount = 10
- this.apiCall = cryptoApi.uploadSignatures(params.signatures)
+ val response = executeRequest(
+ globalErrorReceiver,
+ canRetry = true,
+ maxRetriesCount = 10
+ ) {
+ cryptoApi.uploadSignatures(params.signatures)
}
if (response.failures?.isNotEmpty() == true) {
throw Throwable(response.failures.toString())
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
index 14fad2ea38..08c767ba34 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto.tasks
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
-import org.matrix.android.sdk.internal.crypto.model.rest.KeysQueryResponse
import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
import org.matrix.android.sdk.internal.crypto.model.toRest
@@ -61,8 +60,8 @@ internal class DefaultUploadSigningKeysTask @Inject constructor(
}
private suspend fun doRequest(uploadQuery: UploadSigningKeysBody) {
- val keysQueryResponse = executeRequest(globalErrorReceiver) {
- apiCall = cryptoApi.uploadSigningKeys(uploadQuery)
+ val keysQueryResponse = executeRequest(globalErrorReceiver) {
+ cryptoApi.uploadSigningKeys(uploadQuery)
}
if (keysQueryResponse.failures?.isNotEmpty() == true) {
throw UploadSigningKeys(keysQueryResponse.failures)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt
index c7fe7ab447..1daae906f2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt
@@ -17,22 +17,27 @@
package org.matrix.android.sdk.internal.database
import io.realm.DynamicRealm
+import io.realm.FieldAttribute
import io.realm.RealmMigration
+import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
import org.matrix.android.sdk.internal.database.model.EditAggregatedSummaryEntityFields
import org.matrix.android.sdk.internal.database.model.EditionOfEventFields
+import org.matrix.android.sdk.internal.database.model.EventEntityFields
import org.matrix.android.sdk.internal.database.model.HomeServerCapabilitiesEntityFields
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntityFields
import org.matrix.android.sdk.internal.database.model.PreviewUrlCacheEntityFields
import org.matrix.android.sdk.internal.database.model.RoomEntityFields
import org.matrix.android.sdk.internal.database.model.RoomMembersLoadStatusType
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
+import org.matrix.android.sdk.internal.database.model.RoomTagEntityFields
+import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields
import timber.log.Timber
import javax.inject.Inject
class RealmSessionStoreMigration @Inject constructor() : RealmMigration {
companion object {
- const val SESSION_STORE_SCHEMA_VERSION = 8L
+ const val SESSION_STORE_SCHEMA_VERSION = 9L
}
override fun migrate(realm: DynamicRealm, oldVersion: Long, newVersion: Long) {
@@ -46,6 +51,7 @@ class RealmSessionStoreMigration @Inject constructor() : RealmMigration {
if (oldVersion <= 5) migrateTo6(realm)
if (oldVersion <= 6) migrateTo7(realm)
if (oldVersion <= 7) migrateTo8(realm)
+ if (oldVersion <= 8) migrateTo9(realm)
}
private fun migrateTo1(realm: DynamicRealm) {
@@ -149,4 +155,43 @@ class RealmSessionStoreMigration @Inject constructor() : RealmMigration {
?.removeField("sourceLocalEchoEvents")
?.addRealmListField(EditAggregatedSummaryEntityFields.EDITIONS.`$`, editionOfEventSchema)
}
+
+ fun migrateTo9(realm: DynamicRealm) {
+ Timber.d("Step 8 -> 9")
+
+ realm.schema.get("RoomSummaryEntity")
+ ?.addField(RoomSummaryEntityFields.LAST_ACTIVITY_TIME, Long::class.java, FieldAttribute.INDEXED)
+ ?.setNullable(RoomSummaryEntityFields.LAST_ACTIVITY_TIME, true)
+ ?.addIndex(RoomSummaryEntityFields.MEMBERSHIP_STR)
+ ?.addIndex(RoomSummaryEntityFields.IS_DIRECT)
+ ?.addIndex(RoomSummaryEntityFields.VERSIONING_STATE_STR)
+
+ ?.addField(RoomSummaryEntityFields.IS_FAVOURITE, Boolean::class.java)
+ ?.addIndex(RoomSummaryEntityFields.IS_FAVOURITE)
+ ?.addField(RoomSummaryEntityFields.IS_LOW_PRIORITY, Boolean::class.java)
+ ?.addIndex(RoomSummaryEntityFields.IS_LOW_PRIORITY)
+ ?.addField(RoomSummaryEntityFields.IS_SERVER_NOTICE, Boolean::class.java)
+ ?.addIndex(RoomSummaryEntityFields.IS_SERVER_NOTICE)
+
+ ?.transform { obj ->
+
+ val isFavorite = obj.getList(RoomSummaryEntityFields.TAGS.`$`).any {
+ it.getString(RoomTagEntityFields.TAG_NAME) == RoomTag.ROOM_TAG_FAVOURITE
+ }
+ obj.setBoolean(RoomSummaryEntityFields.IS_FAVOURITE, isFavorite)
+
+ val isLowPriority = obj.getList(RoomSummaryEntityFields.TAGS.`$`).any {
+ it.getString(RoomTagEntityFields.TAG_NAME) == RoomTag.ROOM_TAG_LOW_PRIORITY
+ }
+
+ obj.setBoolean(RoomSummaryEntityFields.IS_LOW_PRIORITY, isLowPriority)
+
+// XXX migrate last message origin server ts
+ obj.getObject(RoomSummaryEntityFields.LATEST_PREVIEWABLE_EVENT.`$`)
+ ?.getObject(TimelineEventEntityFields.ROOT.`$`)
+ ?.getLong(EventEntityFields.ORIGIN_SERVER_TS)?.let {
+ obj.setLong(RoomSummaryEntityFields.LAST_ACTIVITY_TIME, it)
+ }
+ }
+ }
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt
index 2e54a4cd52..6dc70b60fc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt
@@ -26,7 +26,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa
private val typingUsersTracker: DefaultTypingUsersTracker) {
fun map(roomSummaryEntity: RoomSummaryEntity): RoomSummary {
- val tags = roomSummaryEntity.tags.map {
+ val tags = roomSummaryEntity.tags().map {
RoomTag(it.tagName, it.tagOrder)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomMemberSummaryEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomMemberSummaryEntity.kt
index a48b081f02..e970fab397 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomMemberSummaryEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomMemberSummaryEntity.kt
@@ -39,5 +39,7 @@ internal open class RoomMemberSummaryEntity(@PrimaryKey var primaryKey: String =
membershipStr = value.name
}
+ fun getBestName() = displayName?.takeIf { it.isNotBlank() } ?: userId
+
companion object
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt
index 37696c9082..c87ac15a78 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt
@@ -16,61 +16,217 @@
package org.matrix.android.sdk.internal.database.model
+import io.realm.RealmList
+import io.realm.RealmObject
+import io.realm.annotations.Index
+import io.realm.annotations.PrimaryKey
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.VersioningState
-import io.realm.RealmList
-import io.realm.RealmObject
-import io.realm.annotations.PrimaryKey
+import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
internal open class RoomSummaryEntity(
- @PrimaryKey var roomId: String = "",
- var displayName: String? = "",
- var avatarUrl: String? = "",
- var name: String? = "",
- var topic: String? = "",
- var latestPreviewableEvent: TimelineEventEntity? = null,
- var heroes: RealmList = RealmList(),
- var joinedMembersCount: Int? = 0,
- var invitedMembersCount: Int? = 0,
- var isDirect: Boolean = false,
- var directUserId: String? = null,
- var otherMemberIds: RealmList = RealmList(),
- var notificationCount: Int = 0,
- var highlightCount: Int = 0,
- var readMarkerId: String? = null,
- var hasUnreadMessages: Boolean = false,
- var tags: RealmList = RealmList(),
- var userDrafts: UserDraftsEntity? = null,
- var breadcrumbsIndex: Int = RoomSummary.NOT_IN_BREADCRUMBS,
- var canonicalAlias: String? = null,
- var aliases: RealmList = RealmList(),
- // this is required for querying
- var flatAliases: String = "",
- var isEncrypted: Boolean = false,
- var encryptionEventTs: Long? = 0,
- var roomEncryptionTrustLevelStr: String? = null,
- var inviterId: String? = null,
- var hasFailedSending: Boolean = false
+ @PrimaryKey var roomId: String = ""
) : RealmObject() {
+ var displayName: String? = ""
+ set(value) {
+ if (value != field) field = value
+ }
+ var avatarUrl: String? = ""
+ set(value) {
+ if (value != field) field = value
+ }
+ var name: String? = ""
+ set(value) {
+ if (value != field) field = value
+ }
+ var topic: String? = ""
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var latestPreviewableEvent: TimelineEventEntity? = null
+ set(value) {
+ if (value != field) field = value
+ }
+
+ @Index
+ var lastActivityTime: Long? = null
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var heroes: RealmList = RealmList()
+
+ var joinedMembersCount: Int? = 0
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var invitedMembersCount: Int? = 0
+ set(value) {
+ if (value != field) field = value
+ }
+
+ @Index
+ var isDirect: Boolean = false
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var directUserId: String? = null
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var otherMemberIds: RealmList = RealmList()
+
+ var notificationCount: Int = 0
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var highlightCount: Int = 0
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var readMarkerId: String? = null
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var hasUnreadMessages: Boolean = false
+ set(value) {
+ if (value != field) field = value
+ }
+
+ private var tags: RealmList = RealmList()
+
+ fun tags(): List = tags
+
+ fun updateTags(newTags: List>) {
+ val toDelete = mutableListOf()
+ tags.forEach { existingTag ->
+ val updatedTag = newTags.firstOrNull { it.first == existingTag.tagName }
+ if (updatedTag == null) {
+ toDelete.add(existingTag)
+ } else {
+ existingTag.tagOrder = updatedTag.second
+ }
+ }
+ toDelete.forEach { it.deleteFromRealm() }
+ newTags.forEach { newTag ->
+ if (tags.all { it.tagName != newTag.first }) {
+ // we must add it
+ tags.add(
+ RoomTagEntity(newTag.first, newTag.second)
+ )
+ }
+ }
+
+ isFavourite = newTags.any { it.first == RoomTag.ROOM_TAG_FAVOURITE }
+ isLowPriority = newTags.any { it.first == RoomTag.ROOM_TAG_LOW_PRIORITY }
+ isServerNotice = newTags.any { it.first == RoomTag.ROOM_TAG_SERVER_NOTICE }
+ }
+
+ @Index
+ var isFavourite: Boolean = false
+ set(value) {
+ if (value != field) field = value
+ }
+
+ @Index
+ var isLowPriority: Boolean = false
+ set(value) {
+ if (value != field) field = value
+ }
+
+ @Index
+ var isServerNotice: Boolean = false
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var userDrafts: UserDraftsEntity? = null
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var breadcrumbsIndex: Int = RoomSummary.NOT_IN_BREADCRUMBS
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var canonicalAlias: String? = null
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var aliases: RealmList = RealmList()
+
+ fun updateAliases(newAliases: List) {
+ // only update underlying field if there is a diff
+ if (newAliases.distinct().sorted() != aliases.distinct().sorted()) {
+ aliases.clear()
+ aliases.addAll(newAliases)
+ flatAliases = newAliases.joinToString(separator = "|", prefix = "|")
+ }
+ }
+
+ // this is required for querying
+ var flatAliases: String = ""
+
+ var isEncrypted: Boolean = false
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var encryptionEventTs: Long? = 0
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var roomEncryptionTrustLevelStr: String? = null
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var inviterId: String? = null
+ set(value) {
+ if (value != field) field = value
+ }
+
+ var hasFailedSending: Boolean = false
+ set(value) {
+ if (value != field) field = value
+ }
+
+ @Index
private var membershipStr: String = Membership.NONE.name
+
var membership: Membership
get() {
return Membership.valueOf(membershipStr)
}
set(value) {
- membershipStr = value.name
+ if (value.name != membershipStr) {
+ membershipStr = value.name
+ }
}
+ @Index
private var versioningStateStr: String = VersioningState.NONE.name
var versioningState: VersioningState
get() {
return VersioningState.valueOf(versioningStateStr)
}
set(value) {
- versioningStateStr = value.name
+ if (value.name != versioningStateStr) {
+ versioningStateStr = value.name
+ }
}
var roomEncryptionTrustLevel: RoomEncryptionTrustLevel?
@@ -84,7 +240,9 @@ internal open class RoomSummaryEntity(
}
}
set(value) {
- roomEncryptionTrustLevelStr = value?.name
+ if (value?.name != roomEncryptionTrustLevelStr) {
+ roomEncryptionTrustLevelStr = value?.name
+ }
}
companion object
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt
index a3c741ad55..5423025823 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt
@@ -38,16 +38,21 @@ internal fun isEventRead(realmConfiguration: RealmConfiguration,
Realm.getInstance(realmConfiguration).use { realm ->
val liveChunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomId) ?: return@use
val eventToCheck = liveChunk.timelineEvents.find(eventId)
- isEventRead = if (eventToCheck == null || eventToCheck.root?.sender == userId) {
- true
- } else {
- val readReceipt = ReadReceiptEntity.where(realm, roomId, userId).findFirst()
- ?: return@use
- val readReceiptIndex = liveChunk.timelineEvents.find(readReceipt.eventId)?.displayIndex
- ?: Int.MIN_VALUE
- val eventToCheckIndex = eventToCheck.displayIndex
+ isEventRead = when {
+ eventToCheck == null -> {
+ // This can happen in case of fast lane Event
+ false
+ }
+ eventToCheck.root?.sender == userId -> true
+ else -> {
+ val readReceipt = ReadReceiptEntity.where(realm, roomId, userId).findFirst()
+ ?: return@use
+ val readReceiptIndex = liveChunk.timelineEvents.find(readReceipt.eventId)?.displayIndex
+ ?: Int.MIN_VALUE
+ val eventToCheckIndex = eventToCheck.displayIndex
- eventToCheckIndex <= readReceiptIndex
+ eventToCheckIndex <= readReceiptIndex
+ }
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/FederationAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/FederationAPI.kt
index 1816616336..c37392494f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/FederationAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/FederationAPI.kt
@@ -18,10 +18,9 @@
package org.matrix.android.sdk.internal.federation
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.GET
internal interface FederationAPI {
@GET(NetworkConstants.URI_FEDERATION_PATH + "version")
- fun getVersion(): Call
+ suspend fun getVersion(): FederationGetVersionResult
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/GetFederationVersionTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/GetFederationVersionTask.kt
index ce35e48f6b..b7f73a606c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/GetFederationVersionTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/GetFederationVersionTask.kt
@@ -28,8 +28,8 @@ internal class DefaultGetFederationVersionTask @Inject constructor(
) : GetFederationVersionTask {
override suspend fun execute(params: Unit): FederationVersion {
- val result = executeRequest(null) {
- apiCall = federationAPI.getVersion()
+ val result = executeRequest(null) {
+ federationAPI.getVersion()
}
return FederationVersion(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
index 442029127d..0246bae024 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
@@ -19,38 +19,49 @@ package org.matrix.android.sdk.internal.network
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.delay
import org.matrix.android.sdk.api.failure.Failure
+import org.matrix.android.sdk.api.failure.MatrixError
+import org.matrix.android.sdk.api.failure.getRetryDelay
import org.matrix.android.sdk.api.failure.shouldBeRetried
import org.matrix.android.sdk.internal.network.ssl.CertUtil
-import retrofit2.Call
-import retrofit2.awaitResponse
+import retrofit2.HttpException
import timber.log.Timber
import java.io.IOException
-internal suspend inline fun executeRequest(globalErrorReceiver: GlobalErrorReceiver?,
- block: Request.() -> Unit) = Request(globalErrorReceiver).apply(block).execute()
+/**
+ * Execute a request from the requestBlock and handle some of the Exception it could generate
+ * Ref: https://github.com/matrix-org/matrix-js-sdk/blob/develop/src/scheduler.js#L138-L175
+ *
+ * @param globalErrorReceiver will be use to notify error such as invalid token error. See [GlobalError]
+ * @param canRetry if set to true, the request will be executed again in case of error, after a delay
+ * @param maxDelayBeforeRetry the max delay to wait before a retry
+ * @param maxRetriesCount the max number of retries
+ * @param requestBlock a suspend lambda to perform the network request
+ */
+internal suspend inline fun executeRequest(globalErrorReceiver: GlobalErrorReceiver?,
+ canRetry: Boolean = false,
+ maxDelayBeforeRetry: Long = 32_000L,
+ maxRetriesCount: Int = 4,
+ noinline requestBlock: suspend () -> DATA): DATA {
+ var currentRetryCount = 0
+ var currentDelay = 1_000L
-internal class Request(private val globalErrorReceiver: GlobalErrorReceiver?) {
-
- var isRetryable = false
- var initialDelay: Long = 100L
- var maxDelay: Long = 10_000L
- var maxRetryCount = Int.MAX_VALUE
- private var currentRetryCount = 0
- private var currentDelay = initialDelay
- lateinit var apiCall: Call
-
- suspend fun execute(): DATA {
- return try {
- val response = apiCall.clone().awaitResponse()
- if (response.isSuccessful) {
- response.body()
- ?: throw IllegalStateException("The request returned a null body")
- } else {
- throw response.toFailure(globalErrorReceiver)
+ while (true) {
+ try {
+ return requestBlock()
+ } catch (throwable: Throwable) {
+ val exception = when (throwable) {
+ is KotlinNullPointerException -> IllegalStateException("The request returned a null body")
+ is HttpException -> throwable.toFailure(globalErrorReceiver)
+ else -> throwable
+ }
+
+ // Log some details about the request which has failed.
+ val request = (throwable as? HttpException)?.response()?.raw()?.request
+ if (request == null) {
+ Timber.e("Exception when executing request")
+ } else {
+ Timber.e("Exception when executing request ${request.method} ${request.url.toString().substringBefore("?")}")
}
- } catch (exception: Throwable) {
- // Log some details about the request which has failed
- Timber.e("Exception when executing request ${apiCall.request().method} ${apiCall.request().url.toString().substringBefore("?")}")
// Check if this is a certificateException
CertUtil.getCertificateException(exception)
@@ -61,10 +72,18 @@ internal class Request(private val globalErrorReceiver: GlobalErrorR
// }
?.also { unrecognizedCertificateException -> throw unrecognizedCertificateException }
- if (isRetryable && currentRetryCount++ < maxRetryCount && exception.shouldBeRetried()) {
+ currentRetryCount++
+
+ if (exception is Failure.ServerError
+ && exception.httpCode == 429
+ && exception.error.code == MatrixError.M_LIMIT_EXCEEDED
+ && currentRetryCount < maxRetriesCount) {
+ // 429, we can retry
+ delay(exception.getRetryDelay(1_000))
+ } else if (canRetry && currentRetryCount < maxRetriesCount && exception.shouldBeRetried()) {
delay(currentDelay)
- currentDelay = (currentDelay * 2L).coerceAtMost(maxDelay)
- return execute()
+ currentDelay = currentDelay.times(2L).coerceAtMost(maxDelayBeforeRetry)
+ // Try again (loop)
} else {
throw when (exception) {
is IOException -> Failure.NetworkConnection(exception)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
index dd5a69dd3c..7132b4ff7a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
@@ -25,6 +25,7 @@ import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.internal.di.MoshiProvider
import kotlinx.coroutines.suspendCancellableCoroutine
import okhttp3.ResponseBody
+import retrofit2.HttpException
import retrofit2.Response
import timber.log.Timber
import java.io.IOException
@@ -57,6 +58,13 @@ internal fun Response.toFailure(globalErrorReceiver: GlobalErrorReceiver?
return toFailure(errorBody(), code(), globalErrorReceiver)
}
+/**
+ * Convert a HttpException to a Failure, and eventually parse errorBody to convert it to a MatrixError
+ */
+internal fun HttpException.toFailure(globalErrorReceiver: GlobalErrorReceiver?): Failure {
+ return toFailure(response()?.errorBody(), code(), globalErrorReceiver)
+}
+
/**
* Convert a okhttp3 Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/GetUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/GetUrlTask.kt
index 16633d90ef..d0e2534e7a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/GetUrlTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/GetUrlTask.kt
@@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.raw
import com.zhuinden.monarchy.Monarchy
-import okhttp3.ResponseBody
import org.matrix.android.sdk.api.cache.CacheStrategy
import org.matrix.android.sdk.internal.database.model.RawCacheEntity
import org.matrix.android.sdk.internal.database.query.get
@@ -58,8 +57,8 @@ internal class DefaultGetUrlTask @Inject constructor(
}
private suspend fun doRequest(url: String): String {
- return executeRequest(null) {
- apiCall = rawAPI.getUrl(url)
+ return executeRequest(null) {
+ rawAPI.getUrl(url)
}
.string()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/RawAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/RawAPI.kt
index 4b08afd711..338d94781b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/RawAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/RawAPI.kt
@@ -18,11 +18,10 @@
package org.matrix.android.sdk.internal.raw
import okhttp3.ResponseBody
-import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Url
internal interface RawAPI {
@GET
- fun getUrl(@Url url: String): Call
+ suspend fun getUrl(@Url url: String): ResponseBody
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
index 45fcc5af2d..821a9cba8c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
@@ -33,6 +33,7 @@ import org.matrix.android.sdk.api.session.call.CallSignalingService
import org.matrix.android.sdk.api.session.content.ContentUploadStateTracker
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
import org.matrix.android.sdk.api.session.crypto.CryptoService
+import org.matrix.android.sdk.api.session.events.EventService
import org.matrix.android.sdk.api.session.file.ContentDownloadStateTracker
import org.matrix.android.sdk.api.session.file.FileService
import org.matrix.android.sdk.api.session.group.GroupService
@@ -114,6 +115,7 @@ internal class DefaultSession @Inject constructor(
private val accountDataService: Lazy,
private val _sharedSecretStorageService: Lazy,
private val accountService: Lazy,
+ private val eventService: Lazy,
private val defaultIdentityService: DefaultIdentityService,
private val integrationManagerService: IntegrationManagerService,
private val thirdPartyService: Lazy,
@@ -129,6 +131,7 @@ internal class DefaultSession @Inject constructor(
FilterService by filterService.get(),
PushRuleService by pushRuleService.get(),
PushersService by pushersService.get(),
+ EventService by eventService.get(),
TermsService by termsService.get(),
InitialSyncProgressService by initialSyncProgressService.get(),
SecureStorageService by secureStorageService.get(),
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
index f10eb67921..e61e4ecd89 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
@@ -32,10 +32,11 @@ import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.auth.data.sessionId
import org.matrix.android.sdk.api.crypto.MXCryptoConfig
-import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.accountdata.AccountDataService
+import org.matrix.android.sdk.api.session.events.EventService
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
+import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
import org.matrix.android.sdk.api.session.securestorage.SecureStorageService
import org.matrix.android.sdk.api.session.securestorage.SharedSecretStorageService
@@ -75,6 +76,7 @@ import org.matrix.android.sdk.internal.network.token.AccessTokenProvider
import org.matrix.android.sdk.internal.network.token.HomeserverAccessTokenProvider
import org.matrix.android.sdk.internal.session.call.CallEventProcessor
import org.matrix.android.sdk.internal.session.download.DownloadProgressInterceptor
+import org.matrix.android.sdk.internal.session.events.DefaultEventService
import org.matrix.android.sdk.internal.session.homeserver.DefaultHomeServerCapabilitiesService
import org.matrix.android.sdk.internal.session.identity.DefaultIdentityService
import org.matrix.android.sdk.internal.session.initsync.DefaultInitialSyncProgressService
@@ -357,6 +359,9 @@ internal abstract class SessionModule {
@Binds
abstract fun bindAccountDataService(service: DefaultAccountDataService): AccountDataService
+ @Binds
+ abstract fun bindEventService(service: DefaultEventService): EventService
+
@Binds
abstract fun bindSharedSecretStorageService(service: DefaultSharedSecretStorageService): SharedSecretStorageService
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/AccountAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/AccountAPI.kt
index 1db9d121a6..a04d0f2686 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/AccountAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/AccountAPI.kt
@@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.session.account
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.POST
@@ -28,7 +27,7 @@ internal interface AccountAPI {
* @param params parameters to change password.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password")
- fun changePassword(@Body params: ChangePasswordParams): Call
+ suspend fun changePassword(@Body params: ChangePasswordParams)
/**
* Deactivate the user account
@@ -36,5 +35,5 @@ internal interface AccountAPI {
* @param params the deactivate account params
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/deactivate")
- fun deactivate(@Body params: DeactivateAccountParams): Call
+ suspend fun deactivate(@Body params: DeactivateAccountParams)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
index 1f043b0a9d..02c3735998 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
@@ -39,8 +39,8 @@ internal class DefaultChangePasswordTask @Inject constructor(
override suspend fun execute(params: ChangePasswordTask.Params) {
val changePasswordParams = ChangePasswordParams.create(userId, params.password, params.newPassword)
try {
- executeRequest(globalErrorReceiver) {
- apiCall = accountAPI.changePassword(changePasswordParams)
+ executeRequest(globalErrorReceiver) {
+ accountAPI.changePassword(changePasswordParams)
}
} catch (throwable: Throwable) {
val registrationFlowResponse = throwable.toRegistrationFlowResponse()
@@ -49,8 +49,8 @@ internal class DefaultChangePasswordTask @Inject constructor(
/* Avoid infinite loop */
&& changePasswordParams.auth?.session == null) {
// Retry with authentication
- executeRequest(globalErrorReceiver) {
- apiCall = accountAPI.changePassword(
+ executeRequest(globalErrorReceiver) {
+ accountAPI.changePassword(
changePasswordParams.copy(auth = changePasswordParams.auth?.copy(session = registrationFlowResponse.session))
)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/DeactivateAccountTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/DeactivateAccountTask.kt
index ca6b0554a9..1a8e80ab68 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/DeactivateAccountTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/DeactivateAccountTask.kt
@@ -46,8 +46,8 @@ internal class DefaultDeactivateAccountTask @Inject constructor(
val deactivateAccountParams = DeactivateAccountParams.create(params.userAuthParam, params.eraseAllData)
val canCleanup = try {
- executeRequest(globalErrorReceiver) {
- apiCall = accountAPI.deactivate(deactivateAccountParams)
+ executeRequest(globalErrorReceiver) {
+ accountAPI.deactivate(deactivateAccountParams)
}
true
} catch (throwable: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallEventProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallEventProcessor.kt
index 4887351709..a190ff62ac 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallEventProcessor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallEventProcessor.kt
@@ -21,9 +21,11 @@ import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.internal.database.model.EventInsertType
import org.matrix.android.sdk.internal.session.EventInsertLiveProcessor
+import org.matrix.android.sdk.internal.session.SessionScope
import timber.log.Timber
import javax.inject.Inject
+@SessionScope
internal class CallEventProcessor @Inject constructor(private val callSignalingHandler: CallSignalingHandler)
: EventInsertLiveProcessor {
@@ -51,6 +53,15 @@ internal class CallEventProcessor @Inject constructor(private val callSignalingH
eventsToPostProcess.add(event)
}
+ fun shouldProcessFastLane(eventType: String): Boolean {
+ return eventType == EventType.CALL_INVITE
+ }
+
+ suspend fun processFastLane(event: Event) {
+ eventsToPostProcess.add(event)
+ onPostProcess()
+ }
+
override suspend fun onPostProcess() {
eventsToPostProcess.forEach {
dispatchToCallSignalingHandlerIfNeeded(it)
@@ -60,7 +71,7 @@ internal class CallEventProcessor @Inject constructor(private val callSignalingH
private fun dispatchToCallSignalingHandlerIfNeeded(event: Event) {
val now = System.currentTimeMillis()
- // TODO might check if an invite is not closed (hangup/answsered) in the same event batch?
+ // TODO might check if an invite is not closed (hangup/answered) in the same event batch?
event.roomId ?: return Unit.also {
Timber.w("Event with no room id ${event.eventId}")
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallSignalingHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallSignalingHandler.kt
index 7e54301f63..8d7e9e819a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallSignalingHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallSignalingHandler.kt
@@ -56,25 +56,25 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa
fun onCallEvent(event: Event) {
when (event.getClearType()) {
- EventType.CALL_ANSWER -> {
+ EventType.CALL_ANSWER -> {
handleCallAnswerEvent(event)
}
- EventType.CALL_INVITE -> {
+ EventType.CALL_INVITE -> {
handleCallInviteEvent(event)
}
- EventType.CALL_HANGUP -> {
+ EventType.CALL_HANGUP -> {
handleCallHangupEvent(event)
}
- EventType.CALL_REJECT -> {
+ EventType.CALL_REJECT -> {
handleCallRejectEvent(event)
}
- EventType.CALL_CANDIDATES -> {
+ EventType.CALL_CANDIDATES -> {
handleCallCandidatesEvent(event)
}
EventType.CALL_SELECT_ANSWER -> {
handleCallSelectAnswerEvent(event)
}
- EventType.CALL_NEGOTIATE -> {
+ EventType.CALL_NEGOTIATE -> {
handleCallNegotiateEvent(event)
}
}
@@ -168,6 +168,14 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa
return
}
val content = event.getClearContent().toModel() ?: return
+
+ content.callId ?: return
+ if (activeCallHandler.getCallWithId(content.callId) != null) {
+ // Call is already known, maybe due to fast lane. Ignore
+ Timber.d("Ignoring already known call invite")
+ return
+ }
+
val incomingCall = mxCallFactory.createIncomingCall(
roomId = event.roomId,
opponentUserId = event.senderId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/GetTurnServerTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/GetTurnServerTask.kt
index b21ec1113a..d53ddb7371 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/GetTurnServerTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/GetTurnServerTask.kt
@@ -31,7 +31,7 @@ internal class DefaultGetTurnServerTask @Inject constructor(private val voipAPI:
override suspend fun execute(params: Params): TurnServerResponse {
return executeRequest(globalErrorReceiver) {
- apiCall = voipAPI.getTurnServer()
+ voipAPI.getTurnServer()
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/VoipApi.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/VoipApi.kt
index 72c6c58f27..469faaae74 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/VoipApi.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/VoipApi.kt
@@ -18,11 +18,10 @@ package org.matrix.android.sdk.internal.session.call
import org.matrix.android.sdk.api.session.call.TurnServerResponse
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.GET
internal interface VoipApi {
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "voip/turnServer")
- fun getTurnServer(): Call
+ suspend fun getTurnServer(): TurnServerResponse
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/directory/DirectoryAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/directory/DirectoryAPI.kt
index 6a50f3ee37..19bc7e1908 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/directory/DirectoryAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/directory/DirectoryAPI.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.directory
import org.matrix.android.sdk.internal.network.NetworkConstants
import org.matrix.android.sdk.internal.session.room.alias.AddRoomAliasBody
import org.matrix.android.sdk.internal.session.room.alias.RoomAliasDescription
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
@@ -33,7 +32,7 @@ internal interface DirectoryAPI {
* @param roomAlias the room alias.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
- fun getRoomIdByAlias(@Path("roomAlias") roomAlias: String): Call
+ suspend fun getRoomIdByAlias(@Path("roomAlias") roomAlias: String): RoomAliasDescription
/**
* Get the room directory visibility.
@@ -41,7 +40,7 @@ internal interface DirectoryAPI {
* @param roomId the room id.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/list/room/{roomId}")
- fun getRoomDirectoryVisibility(@Path("roomId") roomId: String): Call
+ suspend fun getRoomDirectoryVisibility(@Path("roomId") roomId: String): RoomDirectoryVisibilityJson
/**
* Set the room directory visibility.
@@ -50,21 +49,21 @@ internal interface DirectoryAPI {
* @param body the body containing the new directory visibility
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/list/room/{roomId}")
- fun setRoomDirectoryVisibility(@Path("roomId") roomId: String,
- @Body body: RoomDirectoryVisibilityJson): Call
+ suspend fun setRoomDirectoryVisibility(@Path("roomId") roomId: String,
+ @Body body: RoomDirectoryVisibilityJson)
/**
* Add alias to the room.
* @param roomAlias the room alias.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
- fun addRoomAlias(@Path("roomAlias") roomAlias: String,
- @Body body: AddRoomAliasBody): Call
+ suspend fun addRoomAlias(@Path("roomAlias") roomAlias: String,
+ @Body body: AddRoomAliasBody)
/**
* Delete a room alias
* @param roomAlias the room alias.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
- fun deleteRoomAlias(@Path("roomAlias") roomAlias: String): Call
+ suspend fun deleteRoomAlias(@Path("roomAlias") roomAlias: String)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/events/DefaultEventService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/events/DefaultEventService.kt
new file mode 100644
index 0000000000..d7e9ef2ee0
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/events/DefaultEventService.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.internal.session.events
+
+import org.matrix.android.sdk.api.session.events.EventService
+import org.matrix.android.sdk.api.session.events.model.Event
+import org.matrix.android.sdk.internal.session.call.CallEventProcessor
+import org.matrix.android.sdk.internal.session.room.timeline.GetEventTask
+import javax.inject.Inject
+
+internal class DefaultEventService @Inject constructor(
+ private val getEventTask: GetEventTask,
+ private val callEventProcessor: CallEventProcessor
+) : EventService {
+
+ override suspend fun getEvent(roomId: String, eventId: String): Event {
+ val event = getEventTask.execute(GetEventTask.Params(roomId, eventId))
+
+ // Fast lane to the call event processors: try to make the incoming call ring faster
+ if (callEventProcessor.shouldProcessFastLane(event.getClearType())) {
+ callEventProcessor.processFastLane(event)
+ }
+
+ return event
+ }
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/events/EventExt.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/events/EventExt.kt
new file mode 100644
index 0000000000..91e709e464
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/events/EventExt.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.internal.session.events
+
+import org.matrix.android.sdk.api.session.events.model.Event
+import org.matrix.android.sdk.api.session.events.model.toModel
+import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
+
+internal fun Event.getFixedRoomMemberContent(): RoomMemberContent? {
+ val content = content.toModel()
+ // if user is leaving, we should grab his last name and avatar from prevContent
+ return if (content?.membership?.isLeft() == true) {
+ val prevContent = resolvedPrevContent().toModel()
+ content.copy(
+ displayName = prevContent?.displayName,
+ avatarUrl = prevContent?.avatarUrl
+ )
+ } else {
+ content
+ }
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/FilterApi.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/FilterApi.kt
index 285bd51d38..2809dea23b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/FilterApi.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/FilterApi.kt
@@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.session.filter
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
@@ -32,8 +31,8 @@ internal interface FilterApi {
* @param body the Json representation of a FilterBody object
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/filter")
- fun uploadFilter(@Path("userId") userId: String,
- @Body body: Filter): Call
+ suspend fun uploadFilter(@Path("userId") userId: String,
+ @Body body: Filter): FilterResponse
/**
* Gets a filter with a given filterId from the homeserver
@@ -43,6 +42,6 @@ internal interface FilterApi {
* @return Filter
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/filter/{filterId}")
- fun getFilterById(@Path("userId") userId: String,
- @Path("filterId") filterId: String): Call
+ suspend fun getFilterById(@Path("userId") userId: String,
+ @Path("filterId") filterId: String): Filter
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt
index d42962d54a..3cac89ce28 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt
@@ -59,9 +59,9 @@ internal class DefaultSaveFilterTask @Inject constructor(
}
val updated = filterRepository.storeFilter(filterBody, roomFilter)
if (updated) {
- val filterResponse = executeRequest(globalErrorReceiver) {
+ val filterResponse = executeRequest(globalErrorReceiver) {
// TODO auto retry
- apiCall = filterAPI.uploadFilter(userId, filterBody)
+ filterAPI.uploadFilter(userId, filterBody)
}
filterRepository.storeFilterId(filterBody, filterResponse.filterId)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt
index 9836164aec..4e0ee3422b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt
@@ -64,14 +64,14 @@ internal class DefaultGetGroupDataTask @Inject constructor(
}
Timber.v("Fetch data for group with ids: ${groupIds.joinToString(";")}")
val data = groupIds.map { groupId ->
- val groupSummary = executeRequest(globalErrorReceiver) {
- apiCall = groupAPI.getSummary(groupId)
+ val groupSummary = executeRequest(globalErrorReceiver) {
+ groupAPI.getSummary(groupId)
}
- val groupRooms = executeRequest(globalErrorReceiver) {
- apiCall = groupAPI.getRooms(groupId)
+ val groupRooms = executeRequest(globalErrorReceiver) {
+ groupAPI.getRooms(groupId)
}
- val groupUsers = executeRequest(globalErrorReceiver) {
- apiCall = groupAPI.getUsers(groupId)
+ val groupUsers = executeRequest(globalErrorReceiver) {
+ groupAPI.getUsers(groupId)
}
GroupData(groupId, groupSummary, groupRooms, groupUsers)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GroupAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GroupAPI.kt
index 004112578c..58dcc57dd6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GroupAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GroupAPI.kt
@@ -20,7 +20,6 @@ import org.matrix.android.sdk.internal.network.NetworkConstants
import org.matrix.android.sdk.internal.session.group.model.GroupRooms
import org.matrix.android.sdk.internal.session.group.model.GroupSummaryResponse
import org.matrix.android.sdk.internal.session.group.model.GroupUsers
-import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Path
@@ -32,7 +31,7 @@ internal interface GroupAPI {
* @param groupId the group id
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/summary")
- fun getSummary(@Path("groupId") groupId: String): Call
+ suspend fun getSummary(@Path("groupId") groupId: String): GroupSummaryResponse
/**
* Request the rooms list.
@@ -40,7 +39,7 @@ internal interface GroupAPI {
* @param groupId the group id
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/rooms")
- fun getRooms(@Path("groupId") groupId: String): Call
+ suspend fun getRooms(@Path("groupId") groupId: String): GroupRooms
/**
* Request the users list.
@@ -48,5 +47,5 @@ internal interface GroupAPI {
* @param groupId the group id
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/users")
- fun getUsers(@Path("groupId") groupId: String): Call
+ suspend fun getUsers(@Path("groupId") groupId: String): GroupUsers
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/CapabilitiesAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/CapabilitiesAPI.kt
index 8242edac84..7de0cc9592 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/CapabilitiesAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/CapabilitiesAPI.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.homeserver
import org.matrix.android.sdk.internal.auth.version.Versions
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.GET
internal interface CapabilitiesAPI {
@@ -26,17 +25,17 @@ internal interface CapabilitiesAPI {
* Request the homeserver capabilities
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "capabilities")
- fun getCapabilities(): Call
+ suspend fun getCapabilities(): GetCapabilitiesResult
/**
* Request the versions
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
- fun getVersions(): Call
+ suspend fun getVersions(): Versions
/**
* Ping the homeserver. We do not care about the returned data, so there is no use to parse them
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
- fun ping(): Call
+ suspend fun ping()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt
index 84c9132d61..740370123f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt
@@ -71,20 +71,20 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
}
val capabilities = runCatching {
- executeRequest(globalErrorReceiver) {
- apiCall = capabilitiesAPI.getCapabilities()
+ executeRequest(globalErrorReceiver) {
+ capabilitiesAPI.getCapabilities()
}
}.getOrNull()
val mediaConfig = runCatching {
- executeRequest(globalErrorReceiver) {
- apiCall = mediaAPI.getMediaConfig()
+ executeRequest(globalErrorReceiver) {
+ mediaAPI.getMediaConfig()
}
}.getOrNull()
val versions = runCatching {
- executeRequest(null) {
- apiCall = capabilitiesAPI.getVersions()
+ executeRequest(null) {
+ capabilitiesAPI.getVersions()
}
}.getOrNull()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/HomeServerPinger.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/HomeServerPinger.kt
index 522097acbf..bb526adf4a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/HomeServerPinger.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/HomeServerPinger.kt
@@ -34,8 +34,8 @@ internal class HomeServerPinger @Inject constructor(private val taskExecutor: Ta
suspend fun canReachHomeServer(): Boolean {
return try {
- executeRequest(null) {
- apiCall = capabilitiesAPI.ping()
+ executeRequest(null) {
+ capabilitiesAPI.ping()
}
true
} catch (throwable: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityAPI.kt
index 7e2702e70d..e9e4d17e3a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityAPI.kt
@@ -26,7 +26,6 @@ import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestOwn
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForEmailBody
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForMsisdnBody
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenResponse
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
@@ -43,20 +42,20 @@ internal interface IdentityAPI {
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-account
*/
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "account")
- fun getAccount(): Call
+ suspend fun getAccount(): IdentityAccountResponse
/**
* Logs out the access token, preventing it from being used to authenticate future requests to the server.
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "account/logout")
- fun logout(): Call
+ suspend fun logout()
/**
* Request the hash detail to request a bunch of 3PIDs
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-hash-details
*/
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "hash_details")
- fun hashDetails(): Call
+ suspend fun hashDetails(): IdentityHashDetailResponse
/**
* Request a bunch of 3PIDs
@@ -65,7 +64,7 @@ internal interface IdentityAPI {
* @param body the body request
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "lookup")
- fun lookup(@Body body: IdentityLookUpParams): Call
+ suspend fun lookup(@Body body: IdentityLookUpParams): IdentityLookUpResponse
/**
* Create a session to change the bind status of an email to an identity server
@@ -75,7 +74,7 @@ internal interface IdentityAPI {
* @return the sid
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/email/requestToken")
- fun requestTokenToBindEmail(@Body body: IdentityRequestTokenForEmailBody): Call
+ suspend fun requestTokenToBindEmail(@Body body: IdentityRequestTokenForEmailBody): IdentityRequestTokenResponse
/**
* Create a session to change the bind status of an phone number to an identity server
@@ -85,7 +84,7 @@ internal interface IdentityAPI {
* @return the sid
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/msisdn/requestToken")
- fun requestTokenToBindMsisdn(@Body body: IdentityRequestTokenForMsisdnBody): Call
+ suspend fun requestTokenToBindMsisdn(@Body body: IdentityRequestTokenForMsisdnBody): IdentityRequestTokenResponse
/**
* Validate ownership of an email address, or a phone number.
@@ -94,6 +93,6 @@ internal interface IdentityAPI {
* - https://matrix.org/docs/spec/identity_service/latest#post-matrix-identity-v2-validate-email-submittoken
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/{medium}/submitToken")
- fun submitToken(@Path("medium") medium: String,
- @Body body: IdentityRequestOwnershipParams): Call
+ suspend fun submitToken(@Path("medium") medium: String,
+ @Body body: IdentityRequestOwnershipParams): SuccessResult
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityAuthAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityAuthAPI.kt
index fd6e1163ef..1671859585 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityAuthAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityAuthAPI.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.identity
import org.matrix.android.sdk.internal.network.NetworkConstants
import org.matrix.android.sdk.internal.session.identity.model.IdentityRegisterResponse
import org.matrix.android.sdk.internal.session.openid.RequestOpenIdTokenResponse
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
@@ -40,18 +39,18 @@ internal interface IdentityAuthAPI {
* @return 200 in case of success
*/
@GET(NetworkConstants.URI_IDENTITY_PREFIX_PATH)
- fun ping(): Call
+ suspend fun ping()
/**
* Ping v1 will be used to check outdated Identity server
*/
@GET("_matrix/identity/api/v1")
- fun pingV1(): Call
+ suspend fun pingV1()
/**
* Exchanges an OpenID token from the homeserver for an access token to access the identity server.
* The request body is the same as the values returned by /openid/request_token in the Client-Server API.
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "account/register")
- fun register(@Body openIdToken: RequestOpenIdTokenResponse): Call
+ suspend fun register(@Body openIdToken: RequestOpenIdTokenResponse): IdentityRegisterResponse
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityBulkLookupTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityBulkLookupTask.kt
index 67f3b2aa56..4f6e906766 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityBulkLookupTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityBulkLookupTask.kt
@@ -83,7 +83,7 @@ internal class DefaultIdentityBulkLookupTask @Inject constructor(
return try {
LookUpData(hashedAddresses,
executeRequest(null) {
- apiCall = identityAPI.lookup(IdentityLookUpParams(
+ identityAPI.lookup(IdentityLookUpParams(
hashedAddresses,
IdentityHashDetailResponse.ALGORITHM_SHA256,
hashDetailResponse.pepper
@@ -126,7 +126,7 @@ internal class DefaultIdentityBulkLookupTask @Inject constructor(
private suspend fun fetchHashDetails(identityAPI: IdentityAPI): IdentityHashDetailResponse {
return executeRequest(null) {
- apiCall = identityAPI.hashDetails()
+ identityAPI.hashDetails()
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityDisconnectTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityDisconnectTask.kt
index 50e24f1245..fc84a144fe 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityDisconnectTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityDisconnectTask.kt
@@ -42,8 +42,8 @@ internal class DefaultIdentityDisconnectTask @Inject constructor(
return
}
- executeRequest(null) {
- apiCall = identityAPI.logout()
+ executeRequest(null) {
+ identityAPI.logout()
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityPingTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityPingTask.kt
index b0d33811bd..fca9408d9c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityPingTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityPingTask.kt
@@ -33,14 +33,14 @@ internal class DefaultIdentityPingTask @Inject constructor() : IdentityPingTask
override suspend fun execute(params: IdentityPingTask.Params) {
try {
- executeRequest(null) {
- apiCall = params.identityAuthAPI.ping()
+ executeRequest(null) {
+ params.identityAuthAPI.ping()
}
} catch (throwable: Throwable) {
if (throwable is Failure.ServerError && throwable.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
// Check if API v1 is available
- executeRequest(null) {
- apiCall = params.identityAuthAPI.pingV1()
+ executeRequest(null) {
+ params.identityAuthAPI.pingV1()
}
// API V1 is responding, but not V2 -> Outdated
throw IdentityServiceError.OutdatedIdentityServer
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRegisterTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRegisterTask.kt
index 19215f353a..8cc854bd94 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRegisterTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRegisterTask.kt
@@ -33,7 +33,7 @@ internal class DefaultIdentityRegisterTask @Inject constructor() : IdentityRegis
override suspend fun execute(params: IdentityRegisterTask.Params): IdentityRegisterResponse {
return executeRequest(null) {
- apiCall = params.identityAuthAPI.register(params.openIdTokenResponse)
+ params.identityAuthAPI.register(params.openIdTokenResponse)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRequestTokenForBindingTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRequestTokenForBindingTask.kt
index bd4cd763f0..9c89048176 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRequestTokenForBindingTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRequestTokenForBindingTask.kt
@@ -25,7 +25,6 @@ import org.matrix.android.sdk.internal.session.identity.data.IdentityPendingBind
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForEmailBody
import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenForMsisdnBody
-import org.matrix.android.sdk.internal.session.identity.model.IdentityRequestTokenResponse
import org.matrix.android.sdk.internal.task.Task
import java.util.UUID
import javax.inject.Inject
@@ -56,8 +55,8 @@ internal class DefaultIdentityRequestTokenForBindingTask @Inject constructor(
val clientSecret = identityPendingBinding?.clientSecret ?: UUID.randomUUID().toString()
val sendAttempt = identityPendingBinding?.sendAttempt?.inc() ?: 1
- val tokenResponse = executeRequest(null) {
- apiCall = when (params.threePid) {
+ val tokenResponse = executeRequest(null) {
+ when (params.threePid) {
is ThreePid.Email -> identityAPI.requestTokenToBindEmail(IdentityRequestTokenForEmailBody(
clientSecret = clientSecret,
sendAttempt = sendAttempt,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentitySubmitTokenForBindingTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentitySubmitTokenForBindingTask.kt
index ebc71c715d..f884e2816d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentitySubmitTokenForBindingTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentitySubmitTokenForBindingTask.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.identity
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.api.session.identity.toMedium
-import org.matrix.android.sdk.internal.auth.registration.SuccessResult
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
@@ -44,8 +43,8 @@ internal class DefaultIdentitySubmitTokenForBindingTask @Inject constructor(
val identityAPI = getIdentityApiAndEnsureTerms(identityApiProvider, userId)
val identityPendingBinding = identityStore.getPendingBinding(params.threePid) ?: throw IdentityServiceError.NoCurrentBindingError
- val tokenResponse = executeRequest(null) {
- apiCall = identityAPI.submitToken(
+ val tokenResponse = executeRequest(null) {
+ identityAPI.submitToken(
params.threePid.toMedium(),
IdentityRequestOwnershipParams(
clientSecret = identityPendingBinding.clientSecret,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityTaskHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityTaskHelper.kt
index d3aecce381..d06b157f22 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityTaskHelper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityTaskHelper.kt
@@ -18,14 +18,13 @@ package org.matrix.android.sdk.internal.session.identity
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
import org.matrix.android.sdk.internal.network.executeRequest
-import org.matrix.android.sdk.internal.session.identity.model.IdentityAccountResponse
internal suspend fun getIdentityApiAndEnsureTerms(identityApiProvider: IdentityApiProvider, userId: String): IdentityAPI {
val identityAPI = identityApiProvider.identityApi ?: throw IdentityServiceError.NoIdentityServerConfigured
// Always check that we have access to the service (regarding terms)
- val identityAccountResponse = executeRequest(null) {
- apiCall = identityAPI.getAccount()
+ val identityAccountResponse = executeRequest(null) {
+ identityAPI.getAccount()
}
assert(userId == identityAccountResponse.userId)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt
index d85e471f1d..e707c2351c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt
@@ -65,8 +65,8 @@ internal class DefaultGetPreviewUrlTask @Inject constructor(
}
private suspend fun doRequest(url: String, timestamp: Long?): PreviewUrlData {
- return executeRequest(globalErrorReceiver) {
- apiCall = mediaAPI.getPreviewUrlData(url, timestamp)
+ return executeRequest(globalErrorReceiver) {
+ mediaAPI.getPreviewUrlData(url, timestamp)
}
.toPreviewUrlData(url)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetRawPreviewUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetRawPreviewUrlTask.kt
index 32305cd4e4..fd906f0dc8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetRawPreviewUrlTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetRawPreviewUrlTask.kt
@@ -36,7 +36,7 @@ internal class DefaultGetRawPreviewUrlTask @Inject constructor(
override suspend fun execute(params: GetRawPreviewUrlTask.Params): JsonDict {
return executeRequest(globalErrorReceiver) {
- apiCall = mediaAPI.getPreviewUrlData(params.url, params.timestamp)
+ mediaAPI.getPreviewUrlData(params.url, params.timestamp)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/MediaAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/MediaAPI.kt
index bbb4f1e06a..9ee1d26cdc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/MediaAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/MediaAPI.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.media
import org.matrix.android.sdk.api.util.JsonDict
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Query
@@ -28,7 +27,7 @@ internal interface MediaAPI {
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-config
*/
@GET(NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "config")
- fun getMediaConfig(): Call
+ suspend fun getMediaConfig(): GetMediaConfigResult
/**
* Get information about a URL for the client. Typically this is called when a client
@@ -39,5 +38,5 @@ internal interface MediaAPI {
* if it does not have the requested version available.
*/
@GET(NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "preview_url")
- fun getPreviewUrlData(@Query("url") url: String, @Query("ts") ts: Long?): Call
+ suspend fun getPreviewUrlData(@Query("url") url: String, @Query("ts") ts: Long?): JsonDict
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/DefaultPushRuleService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/DefaultPushRuleService.kt
index e00d2ff26c..38f6b08b43 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/DefaultPushRuleService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/DefaultPushRuleService.kt
@@ -16,8 +16,10 @@
package org.matrix.android.sdk.internal.session.notification
import com.zhuinden.monarchy.Monarchy
+import org.matrix.android.sdk.api.pushrules.Action
import org.matrix.android.sdk.api.pushrules.PushRuleService
import org.matrix.android.sdk.api.pushrules.RuleKind
+import org.matrix.android.sdk.api.pushrules.RuleScope
import org.matrix.android.sdk.api.pushrules.RuleSetKey
import org.matrix.android.sdk.api.pushrules.getActions
import org.matrix.android.sdk.api.pushrules.rest.PushRule
@@ -45,6 +47,7 @@ internal class DefaultPushRuleService @Inject constructor(
private val addPushRuleTask: AddPushRuleTask,
private val updatePushRuleActionsTask: UpdatePushRuleActionsTask,
private val removePushRuleTask: RemovePushRuleTask,
+ private val pushRuleFinder: PushRuleFinder,
private val taskExecutor: TaskExecutor,
@SessionDatabase private val monarchy: Monarchy
) : PushRuleService {
@@ -130,6 +133,12 @@ internal class DefaultPushRuleService @Inject constructor(
}
}
+ override fun getActions(event: Event): List {
+ val rules = getPushRules(RuleScope.GLOBAL).getAllRules()
+
+ return pushRuleFinder.fulfilledBingRule(event, rules)?.getActions().orEmpty()
+ }
+
// fun processEvents(events: List) {
// var hasDoneSomething = false
// events.forEach { event ->
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt
index 54883b51e6..0ece07fc15 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt
@@ -16,9 +16,7 @@
package org.matrix.android.sdk.internal.session.notification
-import org.matrix.android.sdk.api.pushrules.ConditionResolver
import org.matrix.android.sdk.api.pushrules.rest.PushRule
-import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.session.sync.model.RoomsSyncResponse
@@ -35,7 +33,7 @@ internal interface ProcessEventForPushTask : Task
- fulfilledBingRule(event, params.rules)?.let {
+ pushRuleFinder.fulfilledBingRule(event, params.rules)?.let {
Timber.v("[PushRules] Rule $it match for event ${event.eventId}")
defaultPushRuleService.dispatchBing(event, it)
}
@@ -94,13 +92,4 @@ internal class DefaultProcessEventForPushTask @Inject constructor(
defaultPushRuleService.dispatchFinish()
}
-
- private fun fulfilledBingRule(event: Event, rules: List): PushRule? {
- return rules.firstOrNull { rule ->
- // All conditions must hold true for an event in order to apply the action for the event.
- rule.enabled && rule.conditions?.all {
- it.asExecutableCondition(rule)?.isSatisfied(event, conditionResolver) ?: false
- } ?: false
- }
- }
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/PushRuleFinder.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/PushRuleFinder.kt
new file mode 100644
index 0000000000..6e302d373d
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/PushRuleFinder.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.internal.session.notification
+
+import org.matrix.android.sdk.api.pushrules.ConditionResolver
+import org.matrix.android.sdk.api.pushrules.rest.PushRule
+import org.matrix.android.sdk.api.session.events.model.Event
+import javax.inject.Inject
+
+internal class PushRuleFinder @Inject constructor(
+ private val conditionResolver: ConditionResolver
+) {
+ fun fulfilledBingRule(event: Event, rules: List): PushRule? {
+ return rules.firstOrNull { rule ->
+ // All conditions must hold true for an event in order to apply the action for the event.
+ rule.enabled && rule.conditions?.all {
+ it.asExecutableCondition(rule)?.isSatisfied(event, conditionResolver) ?: false
+ } ?: false
+ }
+ }
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/GetOpenIdTokenTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/GetOpenIdTokenTask.kt
index f83c6b770a..8481a6ab93 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/GetOpenIdTokenTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/GetOpenIdTokenTask.kt
@@ -31,7 +31,7 @@ internal class DefaultGetOpenIdTokenTask @Inject constructor(
override suspend fun execute(params: Unit): RequestOpenIdTokenResponse {
return executeRequest(globalErrorReceiver) {
- apiCall = openIdAPI.openIdToken(userId)
+ openIdAPI.openIdToken(userId)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/OpenIdAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/OpenIdAPI.kt
index 4614d82453..ed090b845d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/OpenIdAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/OpenIdAPI.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.openid
import org.matrix.android.sdk.api.util.JsonDict
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.POST
import retrofit2.http.Path
@@ -34,6 +33,6 @@ internal interface OpenIdAPI {
* @param userId the user id
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/openid/request_token")
- fun openIdToken(@Path("userId") userId: String,
- @Body body: JsonDict = emptyMap()): Call
+ suspend fun openIdToken(@Path("userId") userId: String,
+ @Body body: JsonDict = emptyMap()): RequestOpenIdTokenResponse
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt
index 6d6d70bb0d..678d399428 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt
@@ -50,13 +50,14 @@ internal class DefaultAddThreePidTask @Inject constructor(
val clientSecret = UUID.randomUUID().toString()
val sendAttempt = 1
- val result = executeRequest(globalErrorReceiver) {
- val body = AddEmailBody(
- clientSecret = clientSecret,
- email = threePid.email,
- sendAttempt = sendAttempt
- )
- apiCall = profileAPI.addEmail(body)
+ val body = AddEmailBody(
+ clientSecret = clientSecret,
+ email = threePid.email,
+ sendAttempt = sendAttempt
+ )
+
+ val result = executeRequest(globalErrorReceiver) {
+ profileAPI.addEmail(body)
}
// Store as a pending three pid
@@ -84,14 +85,15 @@ internal class DefaultAddThreePidTask @Inject constructor(
val countryCode = parsedNumber.countryCode
val country = phoneNumberUtil.getRegionCodeForCountryCode(countryCode)
- val result = executeRequest(globalErrorReceiver) {
- val body = AddMsisdnBody(
- clientSecret = clientSecret,
- country = country,
- phoneNumber = parsedNumber.nationalNumber.toString(),
- sendAttempt = sendAttempt
- )
- apiCall = profileAPI.addMsisdn(body)
+ val body = AddMsisdnBody(
+ clientSecret = clientSecret,
+ country = country,
+ phoneNumber = parsedNumber.nationalNumber.toString(),
+ sendAttempt = sendAttempt
+ )
+
+ val result = executeRequest(globalErrorReceiver) {
+ profileAPI.addMsisdn(body)
}
// Store as a pending three pid
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidsTask.kt
index a37e5380bc..87e51181e6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidsTask.kt
@@ -43,8 +43,8 @@ internal class DefaultBindThreePidsTask @Inject constructor(private val profileA
val identityServerAccessToken = accessTokenProvider.getToken() ?: throw IdentityServiceError.NoIdentityServerConfigured
val identityPendingBinding = identityStore.getPendingBinding(params.threePid) ?: throw IdentityServiceError.NoCurrentBindingError
- executeRequest(globalErrorReceiver) {
- apiCall = profileAPI.bindThreePid(
+ executeRequest(globalErrorReceiver) {
+ profileAPI.bindThreePid(
BindThreePidBody(
clientSecret = identityPendingBinding.clientSecret,
identityServerUrlWithoutProtocol = identityServerUrlWithoutProtocol,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/DeleteThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/DeleteThreePidTask.kt
index 3549f3613f..7b7617aa80 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/DeleteThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/DeleteThreePidTask.kt
@@ -34,12 +34,12 @@ internal class DefaultDeleteThreePidTask @Inject constructor(
private val globalErrorReceiver: GlobalErrorReceiver) : DeleteThreePidTask() {
override suspend fun execute(params: Params) {
- executeRequest(globalErrorReceiver) {
- val body = DeleteThreePidBody(
- medium = params.threePid.toMedium(),
- address = params.threePid.value
- )
- apiCall = profileAPI.deleteThreePid(body)
+ val body = DeleteThreePidBody(
+ medium = params.threePid.toMedium(),
+ address = params.threePid.value
+ )
+ executeRequest(globalErrorReceiver) {
+ profileAPI.deleteThreePid(body)
}
// We do not really care about the result for the moment
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
index c2a38af093..5f063365e0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
@@ -61,13 +61,13 @@ internal class DefaultFinalizeAddingThreePidTask @Inject constructor(
?: throw IllegalArgumentException("unknown threepid")
try {
- executeRequest(globalErrorReceiver) {
+ executeRequest(globalErrorReceiver) {
val body = FinalizeAddThreePidBody(
clientSecret = pendingThreePids.clientSecret,
sid = pendingThreePids.sid,
auth = params.userAuthParam?.asMap()
)
- apiCall = profileAPI.finalizeAddThreePid(body)
+ profileAPI.finalizeAddThreePid(body)
}
true
} catch (throwable: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/GetProfileInfoTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/GetProfileInfoTask.kt
index ed60c4a368..fed4288f84 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/GetProfileInfoTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/GetProfileInfoTask.kt
@@ -34,7 +34,7 @@ internal class DefaultGetProfileInfoTask @Inject constructor(private val profile
override suspend fun execute(params: Params): JsonDict {
return executeRequest(globalErrorReceiver) {
- apiCall = profileAPI.getProfile(params.userId)
+ profileAPI.getProfile(params.userId)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt
index 7794f578b0..5113b821e8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ProfileAPI.kt
@@ -21,7 +21,6 @@ import org.matrix.android.sdk.api.util.JsonDict
import org.matrix.android.sdk.internal.auth.registration.SuccessResult
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
@@ -37,70 +36,70 @@ internal interface ProfileAPI {
* @param userId the user id to fetch profile info
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}")
- fun getProfile(@Path("userId") userId: String): Call
+ suspend fun getProfile(@Path("userId") userId: String): JsonDict
/**
* List all 3PIDs linked to the Matrix user account.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid")
- fun getThreePIDs(): Call
+ suspend fun getThreePIDs(): AccountThreePidsResponse
/**
* Change user display name
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/displayname")
- fun setDisplayName(@Path("userId") userId: String,
- @Body body: SetDisplayNameBody): Call
+ suspend fun setDisplayName(@Path("userId") userId: String,
+ @Body body: SetDisplayNameBody)
/**
* Change user avatar url.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/avatar_url")
- fun setAvatarUrl(@Path("userId") userId: String,
- @Body body: SetAvatarUrlBody): Call
+ suspend fun setAvatarUrl(@Path("userId") userId: String,
+ @Body body: SetAvatarUrlBody)
/**
* Bind a threePid
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-account-3pid-bind
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "account/3pid/bind")
- fun bindThreePid(@Body body: BindThreePidBody): Call
+ suspend fun bindThreePid(@Body body: BindThreePidBody)
/**
* Unbind a threePid
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-account-3pid-unbind
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "account/3pid/unbind")
- fun unbindThreePid(@Body body: UnbindThreePidBody): Call
+ suspend fun unbindThreePid(@Body body: UnbindThreePidBody): UnbindThreePidResponse
/**
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-email-requesttoken
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/email/requestToken")
- fun addEmail(@Body body: AddEmailBody): Call
+ suspend fun addEmail(@Body body: AddEmailBody): AddEmailResponse
/**
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-msisdn-requesttoken
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/msisdn/requestToken")
- fun addMsisdn(@Body body: AddMsisdnBody): Call
+ suspend fun addMsisdn(@Body body: AddMsisdnBody): AddMsisdnResponse
/**
* Validate Msisdn code (same model than for Identity server API)
*/
@POST
- fun validateMsisdn(@Url url: String,
- @Body params: ValidationCodeBody): Call
+ suspend fun validateMsisdn(@Url url: String,
+ @Body params: ValidationCodeBody): SuccessResult
/**
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-add
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/add")
- fun finalizeAddThreePid(@Body body: FinalizeAddThreePidBody): Call
+ suspend fun finalizeAddThreePid(@Body body: FinalizeAddThreePidBody)
/**
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-delete
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/delete")
- fun deleteThreePid(@Body body: DeleteThreePidBody): Call
+ suspend fun deleteThreePid(@Body body: DeleteThreePidBody): DeleteThreePidResponse
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/RefreshUserThreePidsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/RefreshUserThreePidsTask.kt
index 552ad874ee..8a064b4fd1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/RefreshUserThreePidsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/RefreshUserThreePidsTask.kt
@@ -33,8 +33,8 @@ internal class DefaultRefreshUserThreePidsTask @Inject constructor(private val p
private val globalErrorReceiver: GlobalErrorReceiver) : RefreshUserThreePidsTask() {
override suspend fun execute(params: Unit) {
- val accountThreePidsResponse = executeRequest(globalErrorReceiver) {
- apiCall = profileAPI.getThreePIDs()
+ val accountThreePidsResponse = executeRequest(globalErrorReceiver) {
+ profileAPI.getThreePIDs()
}
Timber.d("Get ${accountThreePidsResponse.threePids?.size} threePids")
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetAvatarUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetAvatarUrlTask.kt
index b29153d665..a7d116d919 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetAvatarUrlTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetAvatarUrlTask.kt
@@ -33,11 +33,11 @@ internal class DefaultSetAvatarUrlTask @Inject constructor(
private val globalErrorReceiver: GlobalErrorReceiver) : SetAvatarUrlTask() {
override suspend fun execute(params: Params) {
+ val body = SetAvatarUrlBody(
+ avatarUrl = params.newAvatarUrl
+ )
return executeRequest(globalErrorReceiver) {
- val body = SetAvatarUrlBody(
- avatarUrl = params.newAvatarUrl
- )
- apiCall = profileAPI.setAvatarUrl(params.userId, body)
+ profileAPI.setAvatarUrl(params.userId, body)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetDisplayNameTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetDisplayNameTask.kt
index 3f236bc589..61d3042310 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetDisplayNameTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetDisplayNameTask.kt
@@ -33,11 +33,11 @@ internal class DefaultSetDisplayNameTask @Inject constructor(
private val globalErrorReceiver: GlobalErrorReceiver) : SetDisplayNameTask() {
override suspend fun execute(params: Params) {
+ val body = SetDisplayNameBody(
+ displayName = params.newDisplayName
+ )
return executeRequest(globalErrorReceiver) {
- val body = SetDisplayNameBody(
- displayName = params.newDisplayName
- )
- apiCall = profileAPI.setDisplayName(params.userId, body)
+ profileAPI.setDisplayName(params.userId, body)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/UnbindThreePidsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/UnbindThreePidsTask.kt
index 3439f6f840..df8a1c97ff 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/UnbindThreePidsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/UnbindThreePidsTask.kt
@@ -39,8 +39,8 @@ internal class DefaultUnbindThreePidsTask @Inject constructor(private val profil
val identityServerUrlWithoutProtocol = identityStore.getIdentityServerUrlWithoutProtocol()
?: throw IdentityServiceError.NoIdentityServerConfigured
- return executeRequest(globalErrorReceiver) {
- apiCall = profileAPI.unbindThreePid(
+ return executeRequest(globalErrorReceiver) {
+ profileAPI.unbindThreePid(
UnbindThreePidBody(
identityServerUrlWithoutProtocol,
params.threePid.toMedium(),
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ValidateSmsCodeTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ValidateSmsCodeTask.kt
index efb6c6e836..c898fc6c5c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ValidateSmsCodeTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ValidateSmsCodeTask.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.profile
import com.zhuinden.monarchy.Monarchy
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.identity.ThreePid
-import org.matrix.android.sdk.internal.auth.registration.SuccessResult
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntity
import org.matrix.android.sdk.internal.di.SessionDatabase
@@ -58,8 +57,8 @@ internal class DefaultValidateSmsCodeTask @Inject constructor(
sid = pendingThreePids.sid,
code = params.code
)
- val result = executeRequest(globalErrorReceiver) {
- apiCall = profileAPI.validateMsisdn(url, body)
+ val result = executeRequest(globalErrorReceiver) {
+ profileAPI.validateMsisdn(url, body)
}
if (!result.isSuccess()) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt
index d0f7cbfca3..c9d7ad2193 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt
@@ -81,8 +81,8 @@ internal class AddHttpPusherWorker(context: Context, params: WorkerParameters)
}
private suspend fun setPusher(pusher: JsonPusher) {
- executeRequest(globalErrorReceiver) {
- apiCall = pushersAPI.setPusher(pusher)
+ executeRequest(globalErrorReceiver) {
+ pushersAPI.setPusher(pusher)
}
monarchy.awaitTransaction { realm ->
val echo = PusherEntity.where(realm, pusher.pushKey).findFirst()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPushRuleTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPushRuleTask.kt
index 03748b1528..b217687168 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPushRuleTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPushRuleTask.kt
@@ -36,7 +36,7 @@ internal class DefaultAddPushRuleTask @Inject constructor(
override suspend fun execute(params: AddPushRuleTask.Params) {
return executeRequest(globalErrorReceiver) {
- apiCall = pushRulesApi.addRule(params.kind.value, params.pushRule.ruleId, params.pushRule)
+ pushRulesApi.addRule(params.kind.value, params.pushRule.ruleId, params.pushRule)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushRulesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushRulesTask.kt
index 9fb2d51664..8cf861d285 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushRulesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushRulesTask.kt
@@ -15,7 +15,6 @@
*/
package org.matrix.android.sdk.internal.session.pushers
-import org.matrix.android.sdk.api.pushrules.rest.GetPushRulesResponse
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
@@ -35,8 +34,8 @@ internal class DefaultGetPushRulesTask @Inject constructor(
) : GetPushRulesTask {
override suspend fun execute(params: GetPushRulesTask.Params) {
- val response = executeRequest(globalErrorReceiver) {
- apiCall = pushRulesApi.getAllRules()
+ val response = executeRequest(globalErrorReceiver) {
+ pushRulesApi.getAllRules()
}
savePushRulesTask.execute(SavePushRulesTask.Params(response))
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushersTask.kt
index 125c8f0022..ba413a34db 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushersTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushersTask.kt
@@ -36,8 +36,8 @@ internal class DefaultGetPushersTask @Inject constructor(
) : GetPushersTask {
override suspend fun execute(params: Unit) {
- val response = executeRequest(globalErrorReceiver) {
- apiCall = pushersAPI.getPushers()
+ val response = executeRequest(globalErrorReceiver) {
+ pushersAPI.getPushers()
}
monarchy.awaitTransaction { realm ->
// clear existings?
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/PushRulesApi.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/PushRulesApi.kt
index cbcb7d2b37..daf9397ce8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/PushRulesApi.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/PushRulesApi.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.pushers
import org.matrix.android.sdk.api.pushrules.rest.GetPushRulesResponse
import org.matrix.android.sdk.api.pushrules.rest.PushRule
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
@@ -30,7 +29,7 @@ internal interface PushRulesApi {
* Get all push rules
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/")
- fun getAllRules(): Call
+ suspend fun getAllRules(): GetPushRulesResponse
/**
* Update the ruleID enable status
@@ -40,10 +39,9 @@ internal interface PushRulesApi {
* @param enable the new enable status
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/enabled")
- fun updateEnableRuleStatus(@Path("kind") kind: String,
- @Path("ruleId") ruleId: String,
- @Body enable: Boolean?)
- : Call
+ suspend fun updateEnableRuleStatus(@Path("kind") kind: String,
+ @Path("ruleId") ruleId: String,
+ @Body enable: Boolean?)
/**
* Update the ruleID action
@@ -54,10 +52,9 @@ internal interface PushRulesApi {
* @param actions the actions
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/actions")
- fun updateRuleActions(@Path("kind") kind: String,
- @Path("ruleId") ruleId: String,
- @Body actions: Any)
- : Call
+ suspend fun updateRuleActions(@Path("kind") kind: String,
+ @Path("ruleId") ruleId: String,
+ @Body actions: Any)
/**
* Delete a rule
@@ -66,9 +63,8 @@ internal interface PushRulesApi {
* @param ruleId the ruleId
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}")
- fun deleteRule(@Path("kind") kind: String,
- @Path("ruleId") ruleId: String)
- : Call
+ suspend fun deleteRule(@Path("kind") kind: String,
+ @Path("ruleId") ruleId: String)
/**
* Add the ruleID enable status
@@ -78,8 +74,7 @@ internal interface PushRulesApi {
* @param rule the rule to add.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}")
- fun addRule(@Path("kind") kind: String,
- @Path("ruleId") ruleId: String,
- @Body rule: PushRule)
- : Call
+ suspend fun addRule(@Path("kind") kind: String,
+ @Path("ruleId") ruleId: String,
+ @Body rule: PushRule)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/PushersAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/PushersAPI.kt
index ed4fb73e1b..0afea6996d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/PushersAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/PushersAPI.kt
@@ -16,7 +16,6 @@
package org.matrix.android.sdk.internal.session.pushers
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
@@ -29,7 +28,7 @@ internal interface PushersAPI {
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushers
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushers")
- fun getPushers(): Call
+ suspend fun getPushers(): GetPushersResponse
/**
* This endpoint allows the creation, modification and deletion of pushers for this user ID.
@@ -38,5 +37,5 @@ internal interface PushersAPI {
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushers/set")
- fun setPusher(@Body jsonPusher: JsonPusher): Call
+ suspend fun setPusher(@Body jsonPusher: JsonPusher)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePushRuleTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePushRuleTask.kt
index ff3122f566..23d0515f41 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePushRuleTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePushRuleTask.kt
@@ -36,7 +36,7 @@ internal class DefaultRemovePushRuleTask @Inject constructor(
override suspend fun execute(params: RemovePushRuleTask.Params) {
return executeRequest(globalErrorReceiver) {
- apiCall = pushRulesApi.deleteRule(params.kind.value, params.pushRule.ruleId)
+ pushRulesApi.deleteRule(params.kind.value, params.pushRule.ruleId)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
index e3f4fdb789..3a2ebf40c2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
@@ -62,8 +62,8 @@ internal class DefaultRemovePusherTask @Inject constructor(
data = JsonPusherData(existing.data.url, existing.data.format),
append = false
)
- executeRequest(globalErrorReceiver) {
- apiCall = pushersAPI.setPusher(deleteBody)
+ executeRequest(globalErrorReceiver) {
+ pushersAPI.setPusher(deleteBody)
}
monarchy.awaitTransaction {
PusherEntity.where(it, params.pushKey).findFirst()?.deleteFromRealm()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleActionsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleActionsTask.kt
index a5c220e662..2a24aee892 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleActionsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleActionsTask.kt
@@ -38,8 +38,8 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
override suspend fun execute(params: UpdatePushRuleActionsTask.Params) {
if (params.oldPushRule.enabled != params.newPushRule.enabled) {
// First change enabled state
- executeRequest(globalErrorReceiver) {
- apiCall = pushRulesApi.updateEnableRuleStatus(params.kind.value, params.newPushRule.ruleId, params.newPushRule.enabled)
+ executeRequest(globalErrorReceiver) {
+ pushRulesApi.updateEnableRuleStatus(params.kind.value, params.newPushRule.ruleId, params.newPushRule.enabled)
}
}
@@ -47,8 +47,8 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
// Also ensure the actions are up to date
val body = mapOf("actions" to params.newPushRule.actions)
- executeRequest(globalErrorReceiver) {
- apiCall = pushRulesApi.updateRuleActions(params.kind.value, params.newPushRule.ruleId, body)
+ executeRequest(globalErrorReceiver) {
+ pushRulesApi.updateRuleActions(params.kind.value, params.newPushRule.ruleId, body)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleEnableStatusTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleEnableStatusTask.kt
index f36b5c55fb..9d7a46bede 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleEnableStatusTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleEnableStatusTask.kt
@@ -35,7 +35,7 @@ internal class DefaultUpdatePushRuleEnableStatusTask @Inject constructor(
override suspend fun execute(params: UpdatePushRuleEnableStatusTask.Params) {
return executeRequest(globalErrorReceiver) {
- apiCall = pushRulesApi.updateEnableRuleStatus(params.kind.value, params.pushRule.ruleId, params.enabled)
+ pushRulesApi.updateEnableRuleStatus(params.kind.value, params.pushRule.ruleId, params.enabled)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/gateway/PushGatewayAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/gateway/PushGatewayAPI.kt
index d95587fc22..4333d6c7b8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/gateway/PushGatewayAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/gateway/PushGatewayAPI.kt
@@ -16,7 +16,6 @@
package org.matrix.android.sdk.internal.session.pushers.gateway
import org.matrix.android.sdk.internal.network.NetworkConstants
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.POST
@@ -27,5 +26,5 @@ internal interface PushGatewayAPI {
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#post-matrix-push-v1-notify
*/
@POST(NetworkConstants.URI_PUSH_GATEWAY_PREFIX_PATH + "notify")
- fun notify(@Body body: PushGatewayNotifyBody): Call
+ suspend fun notify(@Body body: PushGatewayNotifyBody): PushGatewayNotifyResponse
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/gateway/PushGatewayNotifyTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/gateway/PushGatewayNotifyTask.kt
index df6f46fa81..316e221b32 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/gateway/PushGatewayNotifyTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/gateway/PushGatewayNotifyTask.kt
@@ -45,8 +45,8 @@ internal class DefaultPushGatewayNotifyTask @Inject constructor(
)
.create(PushGatewayAPI::class.java)
- val response = executeRequest(null) {
- apiCall = sygnalApi.notify(
+ val response = executeRequest(null) {
+ sygnalApi.notify(
PushGatewayNotifyBody(
PushGatewayNotification(
eventId = params.eventId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt
index f510b3c997..22f61bc517 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt
@@ -18,16 +18,19 @@ package org.matrix.android.sdk.internal.session.room
import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
+import androidx.paging.PagedList
import com.zhuinden.monarchy.Monarchy
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.Room
import org.matrix.android.sdk.api.session.room.RoomService
import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams
+import org.matrix.android.sdk.api.session.room.UpdatableFilterLivePageResult
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
import org.matrix.android.sdk.api.session.room.peeking.PeekResult
+import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.api.util.toOptional
import org.matrix.android.sdk.internal.database.mapper.asDomain
@@ -87,6 +90,20 @@ internal class DefaultRoomService @Inject constructor(
return roomSummaryDataSource.getRoomSummariesLive(queryParams)
}
+ override fun getPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, pagedListConfig: PagedList.Config)
+ : LiveData> {
+ return roomSummaryDataSource.getSortedPagedRoomSummariesLive(queryParams, pagedListConfig)
+ }
+
+ override fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, pagedListConfig: PagedList.Config)
+ : UpdatableFilterLivePageResult {
+ return roomSummaryDataSource.getFilteredPagedRoomSummariesLive(queryParams, pagedListConfig)
+ }
+
+ override fun getNotificationCountForRooms(queryParams: RoomSummaryQueryParams): RoomAggregateNotificationCount {
+ return roomSummaryDataSource.getNotificationCountForRooms(queryParams)
+ }
+
override fun getBreadcrumbs(queryParams: RoomSummaryQueryParams): List {
return roomSummaryDataSource.getBreadcrumbs(queryParams)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAPI.kt
index b065a30fc9..6fee630510 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAPI.kt
@@ -38,7 +38,6 @@ import org.matrix.android.sdk.internal.session.room.tags.TagBody
import org.matrix.android.sdk.internal.session.room.timeline.EventContextResponse
import org.matrix.android.sdk.internal.session.room.timeline.PaginationResponse
import org.matrix.android.sdk.internal.session.room.typing.TypingBody
-import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
@@ -57,9 +56,9 @@ internal interface RoomAPI {
* Ref: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-publicrooms
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "publicRooms")
- fun publicRooms(@Query("server") server: String?,
- @Body publicRoomsParams: PublicRoomsParams
- ): Call
+ suspend fun publicRooms(@Query("server") server: String?,
+ @Body publicRoomsParams: PublicRoomsParams
+ ): PublicRoomsResponse
/**
* Create a room.
@@ -71,7 +70,7 @@ internal interface RoomAPI {
*/
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "createRoom")
- fun createRoom(@Body param: CreateRoomBody): Call
+ suspend fun createRoom(@Body param: CreateRoomBody): CreateRoomResponse
/**
* Get a list of messages starting from a reference.
@@ -83,12 +82,12 @@ internal interface RoomAPI {
* @param filter A JSON RoomEventFilter to filter returned events with. Optional.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/messages")
- fun getRoomMessagesFrom(@Path("roomId") roomId: String,
- @Query("from") from: String,
- @Query("dir") dir: String,
- @Query("limit") limit: Int,
- @Query("filter") filter: String?
- ): Call
+ suspend fun getRoomMessagesFrom(@Path("roomId") roomId: String,
+ @Query("from") from: String,
+ @Query("dir") dir: String,
+ @Query("limit") limit: Int,
+ @Query("filter") filter: String?
+ ): PaginationResponse
/**
* Get all members of a room
@@ -99,11 +98,11 @@ internal interface RoomAPI {
* @param notMembership to exclude one type of membership (optional)
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/members")
- fun getMembers(@Path("roomId") roomId: String,
- @Query("at") syncToken: String?,
- @Query("membership") membership: Membership?,
- @Query("not_membership") notMembership: Membership?
- ): Call
+ suspend fun getMembers(@Path("roomId") roomId: String,
+ @Query("at") syncToken: String?,
+ @Query("membership") membership: Membership?,
+ @Query("not_membership") notMembership: Membership?
+ ): RoomMembersResponse
/**
* Send an event to a room.
@@ -114,11 +113,11 @@ internal interface RoomAPI {
* @param content the event content
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send/{eventType}/{txId}")
- fun send(@Path("txId") txId: String,
- @Path("roomId") roomId: String,
- @Path("eventType") eventType: String,
- @Body content: Content?
- ): Call
+ suspend fun send(@Path("txId") txId: String,
+ @Path("roomId") roomId: String,
+ @Path("eventType") eventType: String,
+ @Body content: Content?
+ ): SendResponse
/**
* Get the context surrounding an event.
@@ -129,10 +128,10 @@ internal interface RoomAPI {
* @param filter A JSON RoomEventFilter to filter returned events with. Optional.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/context/{eventId}")
- fun getContextOfEvent(@Path("roomId") roomId: String,
- @Path("eventId") eventId: String,
- @Query("limit") limit: Int,
- @Query("filter") filter: String? = null): Call
+ suspend fun getContextOfEvent(@Path("roomId") roomId: String,
+ @Path("eventId") eventId: String,
+ @Query("limit") limit: Int,
+ @Query("filter") filter: String? = null): EventContextResponse
/**
* Retrieve an event from its room id / events id
@@ -141,8 +140,8 @@ internal interface RoomAPI {
* @param eventId the event Id
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/event/{eventId}")
- fun getEvent(@Path("roomId") roomId: String,
- @Path("eventId") eventId: String): Call
+ suspend fun getEvent(@Path("roomId") roomId: String,
+ @Path("eventId") eventId: String): Event
/**
* Send read markers.
@@ -151,8 +150,16 @@ internal interface RoomAPI {
* @param markers the read markers
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/read_markers")
- fun sendReadMarker(@Path("roomId") roomId: String,
- @Body markers: Map): Call
+ suspend fun sendReadMarker(@Path("roomId") roomId: String,
+ @Body markers: Map)
+
+ /**
+ * Send receipt to a room
+ */
+ @POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/receipt/{receiptType}/{eventId}")
+ suspend fun sendReceipt(@Path("roomId") roomId: String,
+ @Path("receiptType") receiptType: String,
+ @Path("eventId") eventId: String)
/**
* Invite a user to the given room.
@@ -162,8 +169,8 @@ internal interface RoomAPI {
* @param body a object that just contains a user id
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/invite")
- fun invite(@Path("roomId") roomId: String,
- @Body body: InviteBody): Call
+ suspend fun invite(@Path("roomId") roomId: String,
+ @Body body: InviteBody)
/**
* Invite a user to a room, using a ThreePid
@@ -171,8 +178,8 @@ internal interface RoomAPI {
* @param roomId Required. The room identifier (not alias) to which to invite the user.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/invite")
- fun invite3pid(@Path("roomId") roomId: String,
- @Body body: ThreePidInviteBody): Call
+ suspend fun invite3pid(@Path("roomId") roomId: String,
+ @Body body: ThreePidInviteBody)
/**
* Send a generic state event
@@ -182,9 +189,9 @@ internal interface RoomAPI {
* @param params the request parameters
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}")
- fun sendStateEvent(@Path("roomId") roomId: String,
- @Path("state_event_type") stateEventType: String,
- @Body params: JsonDict): Call
+ suspend fun sendStateEvent(@Path("roomId") roomId: String,
+ @Path("state_event_type") stateEventType: String,
+ @Body params: JsonDict)
/**
* Send a generic state event
@@ -195,17 +202,17 @@ internal interface RoomAPI {
* @param params the request parameters
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}/{state_key}")
- fun sendStateEvent(@Path("roomId") roomId: String,
- @Path("state_event_type") stateEventType: String,
- @Path("state_key") stateKey: String,
- @Body params: JsonDict): Call
+ suspend fun sendStateEvent(@Path("roomId") roomId: String,
+ @Path("state_event_type") stateEventType: String,
+ @Path("state_key") stateKey: String,
+ @Body params: JsonDict)
/**
* Get state events of a room
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-state
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state")
- fun getRoomState(@Path("roomId") roomId: String) : Call>
+ suspend fun getRoomState(@Path("roomId") roomId: String): List
/**
* Send a relation event to a room.
@@ -216,12 +223,12 @@ internal interface RoomAPI {
* @param content the event content
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
- fun sendRelation(@Path("roomId") roomId: String,
- @Path("parent_id") parentId: String,
- @Path("relation_type") relationType: String,
- @Path("event_type") eventType: String,
- @Body content: Content?
- ): Call
+ suspend fun sendRelation(@Path("roomId") roomId: String,
+ @Path("parent_id") parentId: String,
+ @Path("relation_type") relationType: String,
+ @Path("event_type") eventType: String,
+ @Body content: Content?
+ ): SendResponse
/**
* Paginate relations for event based in normal topological order
@@ -230,11 +237,11 @@ internal interface RoomAPI {
* @param eventType filter for this event type
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/relations/{eventId}/{relationType}/{eventType}")
- fun getRelations(@Path("roomId") roomId: String,
- @Path("eventId") eventId: String,
- @Path("relationType") relationType: String,
- @Path("eventType") eventType: String
- ): Call
+ suspend fun getRelations(@Path("roomId") roomId: String,
+ @Path("eventId") eventId: String,
+ @Path("relationType") relationType: String,
+ @Path("eventType") eventType: String
+ ): RelationsResponse
/**
* Join the given room.
@@ -244,9 +251,9 @@ internal interface RoomAPI {
* @param params the request body
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "join/{roomIdOrAlias}")
- fun join(@Path("roomIdOrAlias") roomIdOrAlias: String,
- @Query("server_name") viaServers: List,
- @Body params: Map): Call
+ suspend fun join(@Path("roomIdOrAlias") roomIdOrAlias: String,
+ @Query("server_name") viaServers: List,
+ @Body params: Map): JoinRoomResponse
/**
* Leave the given room.
@@ -255,8 +262,8 @@ internal interface RoomAPI {
* @param params the request body
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/leave")
- fun leave(@Path("roomId") roomId: String,
- @Body params: Map): Call
+ suspend fun leave(@Path("roomId") roomId: String,
+ @Body params: Map)
/**
* Ban a user from the given room.
@@ -265,8 +272,8 @@ internal interface RoomAPI {
* @param userIdAndReason the banned user object (userId and reason for ban)
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/ban")
- fun ban(@Path("roomId") roomId: String,
- @Body userIdAndReason: UserIdAndReason): Call
+ suspend fun ban(@Path("roomId") roomId: String,
+ @Body userIdAndReason: UserIdAndReason)
/**
* unban a user from the given room.
@@ -275,8 +282,8 @@ internal interface RoomAPI {
* @param userIdAndReason the unbanned user object (userId and reason for unban)
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/unban")
- fun unban(@Path("roomId") roomId: String,
- @Body userIdAndReason: UserIdAndReason): Call
+ suspend fun unban(@Path("roomId") roomId: String,
+ @Body userIdAndReason: UserIdAndReason)
/**
* Kick a user from the given room.
@@ -285,8 +292,8 @@ internal interface RoomAPI {
* @param userIdAndReason the kicked user object (userId and reason for kicking)
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/kick")
- fun kick(@Path("roomId") roomId: String,
- @Body userIdAndReason: UserIdAndReason): Call
+ suspend fun kick(@Path("roomId") roomId: String,
+ @Body userIdAndReason: UserIdAndReason)
/**
* Strips all information out of an event which isn't critical to the integrity of the server-side representation of the room.
@@ -299,12 +306,12 @@ internal interface RoomAPI {
* @param reason json containing reason key {"reason": "Indecent material"}
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/redact/{eventId}/{txnId}")
- fun redactEvent(
+ suspend fun redactEvent(
@Path("txnId") txId: String,
@Path("roomId") roomId: String,
@Path("eventId") eventId: String,
@Body reason: Map
- ): Call
+ ): SendResponse
/**
* Reports an event as inappropriate to the server, which may then notify the appropriate people.
@@ -314,24 +321,24 @@ internal interface RoomAPI {
* @param body body containing score and reason
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/report/{eventId}")
- fun reportContent(@Path("roomId") roomId: String,
- @Path("eventId") eventId: String,
- @Body body: ReportContentBody): Call
+ suspend fun reportContent(@Path("roomId") roomId: String,
+ @Path("eventId") eventId: String,
+ @Body body: ReportContentBody)
/**
* Get a list of aliases maintained by the local server for the given room.
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-aliases
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc2432/rooms/{roomId}/aliases")
- fun getAliases(@Path("roomId") roomId: String): Call
+ suspend fun getAliases(@Path("roomId") roomId: String): GetAliasesResponse
/**
* Inform that the user is starting to type or has stopped typing
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/typing/{userId}")
- fun sendTypingState(@Path("roomId") roomId: String,
- @Path("userId") userId: String,
- @Body body: TypingBody): Call
+ suspend fun sendTypingState(@Path("roomId") roomId: String,
+ @Path("userId") userId: String,
+ @Body body: TypingBody)
/**
* Room tagging
@@ -341,16 +348,16 @@ internal interface RoomAPI {
* Add a tag to a room.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/tags/{tag}")
- fun putTag(@Path("userId") userId: String,
- @Path("roomId") roomId: String,
- @Path("tag") tag: String,
- @Body body: TagBody): Call
+ suspend fun putTag(@Path("userId") userId: String,
+ @Path("roomId") roomId: String,
+ @Path("tag") tag: String,
+ @Body body: TagBody)
/**
* Delete a tag from a room.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/tags/{tag}")
- fun deleteTag(@Path("userId") userId: String,
- @Path("roomId") roomId: String,
- @Path("tag") tag: String): Call
+ suspend fun deleteTag(@Path("userId") userId: String,
+ @Path("roomId") roomId: String,
+ @Path("tag") tag: String)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAvatarResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAvatarResolver.kt
index 9bcb1eb196..60ad83ee05 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAvatarResolver.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAvatarResolver.kt
@@ -17,10 +17,11 @@
package org.matrix.android.sdk.internal.session.room
import io.realm.Realm
+import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.RoomAvatarContent
-import org.matrix.android.sdk.internal.database.mapper.ContentMapper
+import org.matrix.android.sdk.internal.database.mapper.asDomain
import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntity
import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntityFields
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
@@ -39,24 +40,35 @@ internal class RoomAvatarResolver @Inject constructor(@UserId private val userId
* @return the room avatar url, can be a fallback to a room member avatar or null
*/
fun resolve(realm: Realm, roomId: String): String? {
- var res: String?
- val roomName = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_AVATAR, stateKey = "")?.root
- res = ContentMapper.map(roomName?.content).toModel()?.avatarUrl
- if (!res.isNullOrEmpty()) {
- return res
+ val roomName = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_AVATAR, stateKey = "")
+ ?.root
+ ?.asDomain()
+ ?.content
+ ?.toModel()
+ ?.avatarUrl
+ if (!roomName.isNullOrEmpty()) {
+ return roomName
}
val roomMembers = RoomMemberHelper(realm, roomId)
val members = roomMembers.queryActiveRoomMembersEvent().findAll()
// detect if it is a room with no more than 2 members (i.e. an alone or a 1:1 chat)
- val isDirectRoom = RoomSummaryEntity.where(realm, roomId).findFirst()?.isDirect ?: false
+ val isDirectRoom = RoomSummaryEntity.where(realm, roomId).findFirst()?.isDirect.orFalse()
+
if (isDirectRoom) {
if (members.size == 1) {
- res = members.firstOrNull()?.avatarUrl
+ // Use avatar of a left user
+ val firstLeftAvatarUrl = roomMembers.queryLeftRoomMembersEvent()
+ .findAll()
+ .firstOrNull { !it.avatarUrl.isNullOrEmpty() }
+ ?.avatarUrl
+
+ return firstLeftAvatarUrl ?: members.firstOrNull()?.avatarUrl
} else if (members.size == 2) {
val firstOtherMember = members.where().notEqualTo(RoomMemberSummaryEntityFields.USER_ID, userId).findFirst()
- res = firstOtherMember?.avatarUrl
+ return firstOtherMember?.avatarUrl
}
}
- return res
+
+ return null
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomModule.kt
index 66b7272360..5133f72932 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomModule.kt
@@ -79,9 +79,11 @@ import org.matrix.android.sdk.internal.session.room.tags.DefaultDeleteTagFromRoo
import org.matrix.android.sdk.internal.session.room.tags.DeleteTagFromRoomTask
import org.matrix.android.sdk.internal.session.room.timeline.DefaultFetchTokenAndPaginateTask
import org.matrix.android.sdk.internal.session.room.timeline.DefaultGetContextOfEventTask
+import org.matrix.android.sdk.internal.session.room.timeline.DefaultGetEventTask
import org.matrix.android.sdk.internal.session.room.timeline.DefaultPaginationTask
import org.matrix.android.sdk.internal.session.room.timeline.FetchTokenAndPaginateTask
import org.matrix.android.sdk.internal.session.room.timeline.GetContextOfEventTask
+import org.matrix.android.sdk.internal.session.room.timeline.GetEventTask
import org.matrix.android.sdk.internal.session.room.timeline.PaginationTask
import org.matrix.android.sdk.internal.session.room.typing.DefaultSendTypingTask
import org.matrix.android.sdk.internal.session.room.typing.SendTypingTask
@@ -228,4 +230,7 @@ internal abstract class RoomModule {
@Binds
abstract fun bindPeekRoomTask(task: DefaultPeekRoomTask): PeekRoomTask
+
+ @Binds
+ abstract fun bindGetEventTask(task: DefaultGetEventTask): GetEventTask
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/AddRoomAliasTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/AddRoomAliasTask.kt
index 9e4ec6f777..97ea1d6ad1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/AddRoomAliasTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/AddRoomAliasTask.kt
@@ -45,8 +45,8 @@ internal class DefaultAddRoomAliasTask @Inject constructor(
override suspend fun execute(params: AddRoomAliasTask.Params) {
aliasAvailabilityChecker.check(params.aliasLocalPart)
- executeRequest(globalErrorReceiver) {
- apiCall = directoryAPI.addRoomAlias(
+ executeRequest(globalErrorReceiver) {
+ directoryAPI.addRoomAlias(
roomAlias = params.aliasLocalPart.toFullLocalAlias(userId),
body = AddRoomAliasBody(
roomId = params.roomId
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DeleteRoomAliasTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DeleteRoomAliasTask.kt
index 6ad3db90a9..01ac3fcec8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DeleteRoomAliasTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DeleteRoomAliasTask.kt
@@ -34,8 +34,8 @@ internal class DefaultDeleteRoomAliasTask @Inject constructor(
) : DeleteRoomAliasTask {
override suspend fun execute(params: DeleteRoomAliasTask.Params) {
- executeRequest(globalErrorReceiver) {
- apiCall = directoryAPI.deleteRoomAlias(
+ executeRequest(globalErrorReceiver) {
+ directoryAPI.deleteRoomAlias(
roomAlias = params.roomAlias
)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomIdByAliasTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomIdByAliasTask.kt
index a53ffc4fcd..71c8c9cd38 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomIdByAliasTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomIdByAliasTask.kt
@@ -52,8 +52,8 @@ internal class DefaultGetRoomIdByAliasTask @Inject constructor(
Optional.from(null)
} else {
val description = tryOrNull("## Failed to get roomId from alias") {
- executeRequest(globalErrorReceiver) {
- apiCall = directoryAPI.getRoomIdByAlias(params.roomAlias)
+ executeRequest(globalErrorReceiver) {
+ directoryAPI.getRoomIdByAlias(params.roomAlias)
}
}
Optional.from(description)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt
index 202cb1f6de..1ff4156ed3 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt
@@ -35,8 +35,8 @@ internal class DefaultGetRoomLocalAliasesTask @Inject constructor(
override suspend fun execute(params: GetRoomLocalAliasesTask.Params): List {
// We do not check for "org.matrix.msc2432", so the API may be missing
- val response = executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.getAliases(roomId = params.roomId)
+ val response = executeRequest(globalErrorReceiver) {
+ roomAPI.getAliases(roomId = params.roomId)
}
return response.aliases
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/RoomAliasAvailabilityChecker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/RoomAliasAvailabilityChecker.kt
index 51a849a35e..9faf50dd8b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/RoomAliasAvailabilityChecker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/RoomAliasAvailabilityChecker.kt
@@ -41,8 +41,8 @@ internal class RoomAliasAvailabilityChecker @Inject constructor(
// Check alias availability
val fullAlias = aliasLocalPart.toFullLocalAlias(userId)
try {
- executeRequest(globalErrorReceiver) {
- apiCall = directoryAPI.getRoomIdByAlias(fullAlias)
+ executeRequest(globalErrorReceiver) {
+ directoryAPI.getRoomIdByAlias(fullAlias)
}
} catch (throwable: Throwable) {
if (throwable is Failure.ServerError && throwable.httpCode == 404) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
index 9c16bd1b0f..bafe2b90ae 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
@@ -17,18 +17,19 @@
package org.matrix.android.sdk.internal.session.room.create
import com.zhuinden.monarchy.Monarchy
+import io.realm.Realm
import io.realm.RealmConfiguration
import kotlinx.coroutines.TimeoutCancellationException
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
+import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomPreset
import org.matrix.android.sdk.internal.database.awaitNotEmptyResult
-import org.matrix.android.sdk.internal.database.model.RoomEntity
-import org.matrix.android.sdk.internal.database.model.RoomEntityFields
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
+import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
@@ -75,8 +76,8 @@ internal class DefaultCreateRoomTask @Inject constructor(
val createRoomBody = createRoomBodyBuilder.build(params)
val createRoomResponse = try {
- executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.createRoom(createRoomBody)
+ executeRequest(globalErrorReceiver) {
+ roomAPI.createRoom(createRoomBody)
}
} catch (throwable: Throwable) {
if (throwable is Failure.ServerError) {
@@ -96,12 +97,18 @@ internal class DefaultCreateRoomTask @Inject constructor(
// Wait for room to come back from the sync (but it can maybe be in the DB if the sync response is received before)
try {
awaitNotEmptyResult(realmConfiguration, TimeUnit.MINUTES.toMillis(1L)) { realm ->
- realm.where(RoomEntity::class.java)
- .equalTo(RoomEntityFields.ROOM_ID, roomId)
+ realm.where(RoomSummaryEntity::class.java)
+ .equalTo(RoomSummaryEntityFields.ROOM_ID, roomId)
+ .equalTo(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.JOIN.name)
}
} catch (exception: TimeoutCancellationException) {
throw CreateRoomFailure.CreatedWithTimeout
}
+
+ Realm.getInstance(realmConfiguration).executeTransactionAsync {
+ RoomSummaryEntity.where(it, roomId).findFirst()?.lastActivityTime = System.currentTimeMillis()
+ }
+
if (otherUserId != null) {
handleDirectChatCreation(roomId, otherUserId)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetPublicRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetPublicRoomTask.kt
index edd8ae9b0d..4a6b0703c5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetPublicRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetPublicRoomTask.kt
@@ -38,7 +38,7 @@ internal class DefaultGetPublicRoomTask @Inject constructor(
override suspend fun execute(params: GetPublicRoomTask.Params): PublicRoomsResponse {
return executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.publicRooms(params.server, params.publicRoomsParams)
+ roomAPI.publicRooms(params.server, params.publicRoomsParams)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetRoomDirectoryVisibilityTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetRoomDirectoryVisibilityTask.kt
index 8d71001ef9..77492e429f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetRoomDirectoryVisibilityTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetRoomDirectoryVisibilityTask.kt
@@ -20,7 +20,6 @@ import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.directory.DirectoryAPI
-import org.matrix.android.sdk.internal.session.directory.RoomDirectoryVisibilityJson
import org.matrix.android.sdk.internal.task.Task
import javax.inject.Inject
@@ -36,8 +35,8 @@ internal class DefaultGetRoomDirectoryVisibilityTask @Inject constructor(
) : GetRoomDirectoryVisibilityTask {
override suspend fun execute(params: GetRoomDirectoryVisibilityTask.Params): RoomDirectoryVisibility {
- return executeRequest(globalErrorReceiver) {
- apiCall = directoryAPI.getRoomDirectoryVisibility(params.roomId)
+ return executeRequest(globalErrorReceiver) {
+ directoryAPI.getRoomDirectoryVisibility(params.roomId)
}
.visibility
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/SetRoomDirectoryVisibilityTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/SetRoomDirectoryVisibilityTask.kt
index cbb0b6d5d1..f46d06bd5c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/SetRoomDirectoryVisibilityTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/SetRoomDirectoryVisibilityTask.kt
@@ -37,8 +37,8 @@ internal class DefaultSetRoomDirectoryVisibilityTask @Inject constructor(
) : SetRoomDirectoryVisibilityTask {
override suspend fun execute(params: SetRoomDirectoryVisibilityTask.Params) {
- executeRequest(globalErrorReceiver) {
- apiCall = directoryAPI.setRoomDirectoryVisibility(
+ executeRequest(globalErrorReceiver) {
+ directoryAPI.setRoomDirectoryVisibility(
params.roomId,
RoomDirectoryVisibilityJson(visibility = params.roomDirectoryVisibility)
)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt
index 6adf3c59d1..3d0f51b831 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt
@@ -90,8 +90,8 @@ internal class DefaultLoadRoomMembersTask @Inject constructor(
val lastToken = syncTokenStore.getLastToken()
val response = try {
- executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.getMembers(params.roomId, lastToken, null, params.excludeMembership)
+ executeRequest(globalErrorReceiver) {
+ roomAPI.getMembers(params.roomId, lastToken, null, params.excludeMembership)
}
} catch (throwable: Throwable) {
// Revert status to NONE
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt
index 0e18e30b13..3aa812d93d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt
@@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.room.membership
import io.realm.Realm
import org.matrix.android.sdk.api.MatrixConfiguration
+import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.Membership
@@ -51,14 +52,14 @@ internal class RoomDisplayNameResolver @Inject constructor(
* @param roomId: the roomId to resolve the name of.
* @return the room display name
*/
- fun resolve(realm: Realm, roomId: String): CharSequence {
+ fun resolve(realm: Realm, roomId: String): String {
// this algorithm is the one defined in
// https://github.com/matrix-org/matrix-js-sdk/blob/develop/lib/models/room.js#L617
// calculateRoomName(room, userId)
// For Lazy Loaded room, see algorithm here:
// https://docs.google.com/document/d/11i14UI1cUz-OJ0knD5BFu7fmT6Fo327zvMYqfSAR7xs/edit#heading=h.qif6pkqyjgzn
- var name: CharSequence?
+ var name: String?
val roomEntity = RoomEntity.where(realm, roomId = roomId).findFirst()
val roomName = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_NAME, stateKey = "")?.root
name = ContentMapper.map(roomName?.content).toModel()?.name
@@ -77,14 +78,14 @@ internal class RoomDisplayNameResolver @Inject constructor(
if (roomEntity?.membership == Membership.INVITE) {
val inviteMeEvent = roomMembers.getLastStateEvent(userId)
val inviterId = inviteMeEvent?.sender
- name = if (inviterId != null) {
- activeMembers.where()
- .equalTo(RoomMemberSummaryEntityFields.USER_ID, inviterId)
- .findFirst()
- ?.displayName
- } else {
- roomDisplayNameFallbackProvider.getNameForRoomInvite()
- }
+ name = inviterId
+ ?.let {
+ activeMembers.where()
+ .equalTo(RoomMemberSummaryEntityFields.USER_ID, it)
+ .findFirst()
+ ?.getBestName()
+ }
+ ?: roomDisplayNameFallbackProvider.getNameForRoomInvite()
} else if (roomEntity?.membership == Membership.JOIN) {
val roomSummary = RoomSummaryEntity.where(realm, roomId).findFirst()
val invitedCount = roomSummary?.invitedMembersCount ?: 0
@@ -105,10 +106,17 @@ internal class RoomDisplayNameResolver @Inject constructor(
val otherMembersCount = otherMembersSubset.count()
name = when (otherMembersCount) {
0 -> {
- roomDisplayNameFallbackProvider.getNameForEmptyRoom()
- // TODO (was xx and yyy) ...
+ // Get left members if any
+ val leftMembersNames = roomMembers.queryLeftRoomMembersEvent()
+ .findAll()
+ .map { it.getBestName() }
+ roomDisplayNameFallbackProvider.getNameForEmptyRoom(roomSummary?.isDirect.orFalse(), leftMembersNames)
+ }
+ 1 -> {
+ roomDisplayNameFallbackProvider.getNameFor1member(
+ resolveRoomMemberName(otherMembersSubset[0], roomMembers)
+ )
}
- 1 -> resolveRoomMemberName(otherMembersSubset[0], roomMembers)
2 -> {
roomDisplayNameFallbackProvider.getNameFor2members(
resolveRoomMemberName(otherMembersSubset[0], roomMembers),
@@ -145,12 +153,11 @@ internal class RoomDisplayNameResolver @Inject constructor(
}
/** See [org.matrix.android.sdk.api.session.room.sender.SenderInfo.disambiguatedDisplayName] */
- private fun resolveRoomMemberName(roomMemberSummary: RoomMemberSummaryEntity?,
- roomMemberHelper: RoomMemberHelper): String? {
- if (roomMemberSummary == null) return null
+ private fun resolveRoomMemberName(roomMemberSummary: RoomMemberSummaryEntity,
+ roomMemberHelper: RoomMemberHelper): String {
val isUnique = roomMemberHelper.isUniqueDisplayName(roomMemberSummary.displayName)
return if (isUnique) {
- roomMemberSummary.displayName
+ roomMemberSummary.getBestName()
} else {
"${roomMemberSummary.displayName} (${roomMemberSummary.userId})"
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberEventHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberEventHandler.kt
index 89fe2901c0..2ecacf335b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberEventHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberEventHandler.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.session.room.membership
+import io.realm.Realm
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
-import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
+import org.matrix.android.sdk.internal.session.events.getFixedRoomMemberContent
import org.matrix.android.sdk.internal.session.user.UserEntityFactory
-import io.realm.Realm
import javax.inject.Inject
internal class RoomMemberEventHandler @Inject constructor() {
@@ -31,7 +31,7 @@ internal class RoomMemberEventHandler @Inject constructor() {
return false
}
val userId = event.stateKey ?: return false
- val roomMember = event.content.toModel()
+ val roomMember = event.getFixedRoomMemberContent()
return handle(realm, roomId, userId, roomMember)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberHelper.kt
index 2a7c46bd42..9ce8db25a5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberHelper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomMemberHelper.kt
@@ -75,6 +75,11 @@ internal class RoomMemberHelper(private val realm: Realm,
.equalTo(RoomMemberSummaryEntityFields.MEMBERSHIP_STR, Membership.INVITE.name)
}
+ fun queryLeftRoomMembersEvent(): RealmQuery {
+ return queryRoomMembersEvent()
+ .equalTo(RoomMemberSummaryEntityFields.MEMBERSHIP_STR, Membership.LEAVE.name)
+ }
+
fun queryActiveRoomMembersEvent(): RealmQuery {
return queryRoomMembersEvent()
.beginGroup()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/admin/MembershipAdminTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/admin/MembershipAdminTask.kt
index 4654a28536..d2c21f3520 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/admin/MembershipAdminTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/admin/MembershipAdminTask.kt
@@ -41,8 +41,8 @@ internal class DefaultMembershipAdminTask @Inject constructor(private val roomAP
override suspend fun execute(params: MembershipAdminTask.Params) {
val userIdAndReason = UserIdAndReason(params.userId, params.reason)
- executeRequest(null) {
- apiCall = when (params.type) {
+ executeRequest(null) {
+ when (params.type) {
MembershipAdminTask.Type.BAN -> roomAPI.ban(params.roomId, userIdAndReason)
MembershipAdminTask.Type.UNBAN -> roomAPI.unban(params.roomId, userIdAndReason)
MembershipAdminTask.Type.KICK -> roomAPI.kick(params.roomId, userIdAndReason)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/InviteTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/InviteTask.kt
index 05503bd643..7e7b80baaf 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/InviteTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/InviteTask.kt
@@ -36,11 +36,13 @@ internal class DefaultInviteTask @Inject constructor(
) : InviteTask {
override suspend fun execute(params: InviteTask.Params) {
- return executeRequest(globalErrorReceiver) {
- val body = InviteBody(params.userId, params.reason)
- apiCall = roomAPI.invite(params.roomId, body)
- isRetryable = true
- maxRetryCount = 3
+ val body = InviteBody(params.userId, params.reason)
+ return executeRequest(
+ globalErrorReceiver,
+ canRetry = true,
+ maxRetriesCount = 3
+ ) {
+ roomAPI.invite(params.roomId, body)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
index 3b7639d42f..33776e4f6e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
@@ -16,21 +16,23 @@
package org.matrix.android.sdk.internal.session.room.membership.joining
+import io.realm.Realm
+import io.realm.RealmConfiguration
+import kotlinx.coroutines.TimeoutCancellationException
import org.matrix.android.sdk.api.session.room.failure.JoinRoomFailure
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
+import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.internal.database.awaitNotEmptyResult
-import org.matrix.android.sdk.internal.database.model.RoomEntity
-import org.matrix.android.sdk.internal.database.model.RoomEntityFields
+import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
+import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
+import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
-import org.matrix.android.sdk.internal.session.room.create.JoinRoomResponse
import org.matrix.android.sdk.internal.session.room.membership.RoomChangeMembershipStateDataSource
import org.matrix.android.sdk.internal.session.room.read.SetReadMarkersTask
import org.matrix.android.sdk.internal.task.Task
-import io.realm.RealmConfiguration
-import kotlinx.coroutines.TimeoutCancellationException
-import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@@ -54,8 +56,8 @@ internal class DefaultJoinRoomTask @Inject constructor(
override suspend fun execute(params: JoinRoomTask.Params) {
roomChangeMembershipStateDataSource.updateState(params.roomIdOrAlias, ChangeMembershipState.Joining)
val joinRoomResponse = try {
- executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.join(
+ executeRequest(globalErrorReceiver) {
+ roomAPI.join(
roomIdOrAlias = params.roomIdOrAlias,
viaServers = params.viaServers.take(3),
params = mapOf("reason" to params.reason)
@@ -69,12 +71,18 @@ internal class DefaultJoinRoomTask @Inject constructor(
val roomId = joinRoomResponse.roomId
try {
awaitNotEmptyResult(realmConfiguration, TimeUnit.MINUTES.toMillis(1L)) { realm ->
- realm.where(RoomEntity::class.java)
- .equalTo(RoomEntityFields.ROOM_ID, roomId)
+ realm.where(RoomSummaryEntity::class.java)
+ .equalTo(RoomSummaryEntityFields.ROOM_ID, roomId)
+ .equalTo(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.JOIN.name)
}
} catch (exception: TimeoutCancellationException) {
throw JoinRoomFailure.JoinedWithTimeout
}
+
+ Realm.getInstance(realmConfiguration).executeTransactionAsync {
+ RoomSummaryEntity.where(it, roomId).findFirst()?.lastActivityTime = System.currentTimeMillis()
+ }
+
setReadMarkers(roomId)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/leaving/LeaveRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/leaving/LeaveRoomTask.kt
index 37bb7570d1..1b836e36a6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/leaving/LeaveRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/leaving/LeaveRoomTask.kt
@@ -68,8 +68,8 @@ internal class DefaultLeaveRoomTask @Inject constructor(
leaveRoom(predecessorRoomId, reason)
}
try {
- executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.leave(roomId, mapOf("reason" to reason))
+ executeRequest(globalErrorReceiver) {
+ roomAPI.leave(roomId, mapOf("reason" to reason))
}
} catch (failure: Throwable) {
roomChangeMembershipStateDataSource.updateState(roomId, ChangeMembershipState.FailedLeaving(failure))
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/threepid/InviteThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/threepid/InviteThreePidTask.kt
index d237ec795e..fa0a2d608a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/threepid/InviteThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/threepid/InviteThreePidTask.kt
@@ -59,7 +59,7 @@ internal class DefaultInviteThreePidTask @Inject constructor(
medium = params.threePid.toMedium(),
address = params.threePid.value
)
- apiCall = roomAPI.invite3pid(params.roomId, body)
+ roomAPI.invite3pid(params.roomId, body)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/ResolveRoomStateTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/ResolveRoomStateTask.kt
index dbec6b555c..64cbef23ec 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/ResolveRoomStateTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/ResolveRoomStateTask.kt
@@ -36,7 +36,7 @@ internal class DefaultResolveRoomStateTask @Inject constructor(
override suspend fun execute(params: ResolveRoomStateTask.Params): List {
return executeRequest(globalErrorReceiver) {
- apiCall = roomAPI.getRoomState(params.roomId)
+ roomAPI.getRoomState(params.roomId)
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt
index 54d2307dd4..e4147d55b8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt
@@ -62,7 +62,7 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
) : SetReadMarkersTask {
override suspend fun execute(params: SetReadMarkersTask.Params) {
- val markers = HashMap()
+ val markers = mutableMapOf()
Timber.v("Execute set read marker with params: $params")
val latestSyncedEventId = latestSyncedEventId(params.roomId)
val fullyReadEventId = if (params.forceReadMarker) {
@@ -96,9 +96,18 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
updateDatabase(params.roomId, markers, shouldUpdateRoomSummary)
}
if (markers.isNotEmpty()) {
- executeRequest(globalErrorReceiver) {
- isRetryable = true
- apiCall = roomAPI.sendReadMarker(params.roomId, markers)
+ executeRequest(
+ globalErrorReceiver,
+ canRetry = true
+ ) {
+ if (markers[READ_MARKER] == null) {
+ if (readReceiptEventId != null) {
+ roomAPI.sendReceipt(params.roomId, READ_RECEIPT, readReceiptEventId)
+ }
+ } else {
+ // "m.fully_read" value is mandatory to make this call
+ roomAPI.sendReadMarker(params.roomId, markers)
+ }
}
}
}
@@ -108,7 +117,7 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
TimelineEventEntity.latestEvent(realm, roomId = roomId, includesSending = false)?.eventId
}
- private suspend fun updateDatabase(roomId: String, markers: HashMap, shouldUpdateRoomSummary: Boolean) {
+ private suspend fun updateDatabase(roomId: String, markers: Map, shouldUpdateRoomSummary: Boolean) {
monarchy.awaitTransaction { realm ->
val readMarkerId = markers[READ_MARKER]
val readReceiptId = markers[READ_RECEIPT]
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/FetchEditHistoryTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/FetchEditHistoryTask.kt
index f9fd5f9348..5f5c000171 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/FetchEditHistoryTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/FetchEditHistoryTask.kt
@@ -40,8 +40,8 @@ internal class DefaultFetchEditHistoryTask @Inject constructor(
override suspend fun execute(params: FetchEditHistoryTask.Params): List {
val isRoomEncrypted = cryptoSessionInfoProvider.isRoomEncrypted(params.roomId)
- val response = executeRequest