Merge branch 'develop' into feature/bca/crypto_store_outbound
This commit is contained in:
commit
844fe2c4cd
15
CHANGES.md
15
CHANGES.md
|
@ -3,16 +3,25 @@ Changes in Element 1.0.14 (2020-XX-XX)
|
|||
|
||||
Features ✨:
|
||||
- Enable url previews for notices (#2562)
|
||||
- Edit room permissions (#2471)
|
||||
|
||||
Improvements 🙌:
|
||||
- Add System theme option and set as default (#904) (#2387)
|
||||
- Store megolm outbound session to improve send time of first message after app launch.
|
||||
- Add System theme option and set as default (#904, #2387)
|
||||
- Store megolm outbound session to improve send time of first message after app launch.
|
||||
- Warn user when they are leaving a not public room (#1460)
|
||||
- Option to disable emoji keyboard (#2563)
|
||||
|
||||
Bugfix 🐛:
|
||||
- Unspecced msgType field in m.sticker (#2580)
|
||||
- Wait for all room members to be known before sending a message to a e2e room (#2518)
|
||||
- Url previews sometimes attached to wrong message (#2561)
|
||||
- Room Topic not displayed correctly after visiting a link (#2551)
|
||||
- Hiding membership events works the exact opposite (#2603)
|
||||
- Tapping drawer having more than 1 room in notifications gives "malformed link" error (#2605)
|
||||
- Sent image not displayed when opened immediately after sending (#409)
|
||||
- Initial sync is not retried correctly when there is some network error. (#2632)
|
||||
- Fix switch theme issue, and white field issue (#2599, #2528)
|
||||
- Fix request too large Uri error when joining a room
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
@ -21,7 +30,7 @@ SDK API changes ⚠️:
|
|||
-
|
||||
|
||||
Build 🧱:
|
||||
-
|
||||
- Remove dependency to org.greenrobot.eventbus library
|
||||
|
||||
Test:
|
||||
-
|
||||
|
|
|
@ -27,7 +27,6 @@ $ source env/bin/activate
|
|||
Every time you want to launch these test homeservers, type:
|
||||
|
||||
```shell script
|
||||
$ virtualenv -p python3 env
|
||||
$ source env/bin/activate
|
||||
(env) $ demo/start.sh --no-rate-limit
|
||||
```
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
// TODO
|
||||
Diese neue Version enthält hauptsächlich Fehlerkorrekturen und Verbesserungen. Nachrichten verschicken geht jetzt viel schneller.
|
||||
Vollständige Versionshinweise: https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
||||
|
|
|
@ -0,0 +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.
|
||||
Vollständige Versionshinweise: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1,2 @@
|
|||
Selles uues versioonis leidub põhiliselt veaparandusi ja pisikohendusi. Sõnumite saatmine on nüüd märkatavalt kiirem.
|
||||
Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
|
@ -0,0 +1,2 @@
|
|||
Uues versioonis leidub põhiliselt kasutajaliidese ning kasutajakogemuse parandusi. Nüüd saad sõpradele kutseid saata ning otsevestlusi alustada QR-koodi lugemise abil.
|
||||
Kõik muudatused: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -1 +1,2 @@
|
|||
// برای انجام
|
||||
این نگارش جدید به طور عمده شامل رفع اشکالها و بهبودها است. ارسال پیام اکنون بسیار سریعتر است.
|
||||
گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
این نگارش جدید به طور عمده شامل رابط کاربری و بهبود تجربه کاربر است. اکنون میتوانید با پویش کدهای QR دوستانتان را دعوت کرده و بسیار سریع پیام مستقیم ایجاد کنید.
|
||||
گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -1 +1 @@
|
|||
گپ و تماس نامتمرکز امن. دادههایتان را از شرکتها امن نگه دارید.
|
||||
گپ و تماس نامتمرکز امن. دادههایتان را از اشخاص سوم امن نگه دارید.
|
||||
|
|
|
@ -1 +1 @@
|
|||
المنت (ریوت سابق)
|
||||
Element (پیشتر Riot.im)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Tämä versio sisältää pääosin käyttöliittymä- ja käyttökokemusparannuksia. Voit nyt kutsua kavereita ja luoda yksityisviestejä nopeasti QR-koodeja lukemalla.
|
||||
Täysi muutosloki: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -1,30 +1,30 @@
|
|||
Element on uudenlainen viestinsovellus, joka:
|
||||
|
||||
1. Antaa sinun päättää yksityisyydestäsi.
|
||||
1. Antaa sinun päättää yksityisyydestäsi
|
||||
2. Antaa sinun kommunikoida kenen tahansa kanssa Matrix-verkossa ja jopa sen ulkopuolella siltaamalla sovelluksiin, kuten Slack
|
||||
3. Suojaa sinua mainonnalta, tietojen keräämiseltä ja suljetuilta alustoilta
|
||||
4. Suojaa sinut päästä päähän -salauksella sekä ristiin varmentamisella muiden todentamiseksi
|
||||
|
||||
Element eroaa täysin muista viestintäsovelluksista, koska se on hajautettu ja avointa lähdekoodia.
|
||||
|
||||
Element antaa sinun isännöidä itse - valita isännän - jotta sinulla on yksityisyys ja voit hallita tietojasi sekä keskustelujasi. Se antaa sinulle pääsyn avoimeen verkkoon; joten et ole jumissa Elementin käyttäjissä.
|
||||
Element antaa sinun isännöidä itse - tai valita palveluntarjoajan - jotta sinulla on yksityisyys ja voit hallita tietojasi sekä keskustelujasi. Se antaa sinulle pääsyn avoimeen verkkoon, joten et jää juttelemaan vain toisten Elementin käyttäjien kanssa. Se on myös hyvin turvallinen.
|
||||
|
||||
Element pystyy tekemään kaiken tämän, koska se toimii Matrixilla - avoimella, hajautetun viestinnän standardilla.
|
||||
|
||||
Element antaa sinulle hallinnan antamalla sinun valita, kuka isännöi keskustelujasi. Element-sovelluksessa voit valita isännän eri tavoin:
|
||||
Element antaa sinulle päätösvallan antamalla sinun valita, kuka isännöi keskustelujasi. Element-sovelluksessa voit valita isännän eri tavoin:
|
||||
|
||||
1. Hanki ilmainen tili Matrix-kehittäjien ylläpitämällä matrix.org-palvelimella tai valitse tuhansista vapaaehtoisten ylläpitämistä julkisista palvelimista.
|
||||
2. Isännöi tiliäsi itse suorittamalla palvelinta omalla laitteellasi
|
||||
3. Luo tili mukautetulla palvelimella yksinkertaisesti tilaamalla Element Matrix Services -palvelu
|
||||
2. Isännöi tiliäsi itse ylläpitämällä palvelinta omalla laitteellasi
|
||||
3. Luo tili sinua varten tehdyllä palvelimella tilaamalla Element Matrix Services -palvelu
|
||||
|
||||
<b>Miksi valita Element?</b>
|
||||
|
||||
<b>OMAT TIEDOT</b>: Sinä päätät, missä tietosi ja viestisi säilytetään. Hallitset sitä itse, eikä jokin MEGAYHTIÖ, joka tutkii tietojasi tai antaa niitä kolmansille osapuolille.
|
||||
<b>OMAT TIEDOT</b>: Sinä päätät, missä tietosi ja viestisi säilytetään. Sinä määräät, ei jokin jättiyhtiö, joka tutkii tietojasi tai antaa niitä kolmansille osapuolille.
|
||||
|
||||
<b>AVOIN KOMMUNIKOINYI JA YHTEISTYÖ</b>: Voit keskustella kaikkien muiden Matrix-verkon käyttäjien kanssa, riippumatta siitä käyttävätkö he Elementiä tai muuta Matrix-sovellusta, ja vaikka he käyttäisivät eri viestijärjestelmiä, kuten Slack, IRC tai XMPP.
|
||||
<b>AVOINTA VIESTINTÄÄ JA YHTEISTYÖTÄ</b>: Voit keskustella kaikkien muiden Matrix-verkon käyttäjien kanssa, riippumatta siitä käyttävätkö he Elementiä tai muuta Matrix-sovellusta, ja vaikka he käyttäisivät eri viestijärjestelmiä, kuten Slack, IRC tai XMPP.
|
||||
|
||||
<b>ERITTÄIN TURVALLINEN</b>: Vahva päästä päähän -salaus (vain keskustelussa olevat voivat purkaa viestien salauksen), ja ristiin varmentaminen keskustelun osallistujien laitteiden tarkistamiseksi.
|
||||
|
||||
<b>TÄYDELLISTÄ VIESTINTÄÄ</b>: Viestit, ääni- ja videopuhelut, tiedostojen jakaminen, näytön jakaminen ja koko joukko integraatioita, botteja ja widgettejä. Rakenna huoneita, yhteisöjä, pidä yhteyttä ja tee asioita.
|
||||
<b>KATTAVAA VIESTINTÄÄ</b>: Viestit, ääni- ja videopuhelut, tiedostojen jakaminen, näytön jakaminen ja koko joukko integraatioita, botteja ja sovelmia. Rakenna huoneita ja yhteisöjä, pidä yhteyttä ja hoida asiasi.
|
||||
|
||||
<b>MISSÄ TAHANSA OLETKIN</b>: Pidä yhteyttä missä tahansa, täysin synkronoidun viestihistorian kautta kaikilla laitteillasi ja verkossa osoitteessa https://app.element.io.
|
||||
|
|
|
@ -1 +1 @@
|
|||
Turvallista, hajautettua, keskusteluja ja VoIP-puheluita. Pidä tietosi turvassa.
|
||||
Turvallista, hajautettua keskustelua ja VoIP-puheluita. Pidä tietosi turvassa.
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Cette nouvelle version contient principalement des corrections de bogues et des améliorations. Envoyer un message est maintenant plus rapide.
|
||||
Liste complète des changements : https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
|
@ -0,0 +1,2 @@
|
|||
Ez az új verzió főképp hibajavításokat, és teljesítménybeli fejlesztéseket tartalmaz. Most már sokkal gyorsabb az üzenetek elküldése.
|
||||
A változtatások teljes listája itt található: https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
|
@ -0,0 +1,2 @@
|
|||
Ez az új verzió főleg a felhasználói felülettel és a felhasználói élménnyel kapcsolatos javításokat tartalmaz. Mostantól már sokkal gyorsabban hívhatsz meg új ismerősöket a QR kód beolvasás által.
|
||||
A változtatások teljes listája itt található: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -17,7 +17,7 @@ Az Element a te kezedbe adja az irányítást azáltal, hogy eldöntheted, ki t
|
|||
2. A saját számítógépeden is futtathatsz szervert
|
||||
3. Előfizethetsz egy saját szerverre az Element Matrix Szolgáltatások platformon
|
||||
|
||||
<b>Miért válaszd az Element-et?</b>
|
||||
<b>Miért jó az Element-et választani?</b>
|
||||
|
||||
<b>ADATAID MEGVÉDÉSE</b>: Eldöntheted, hol tárold az adataid és üzeneteid. A te tulajdonodban van, nem valami megacégnél, ami bányássza az adataid, vagy továbbadja másoknak.
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Questa nuova versione contiene principalmente miglioramenti di interfaccia ed esperienza utente. Ora puoi invitare amici e iniziare messaggi diretti rapidamente tramite codici QR.
|
||||
Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1,2 @@
|
|||
Denne nye versjonen inneholder hovedsakelig feilrettinger og forbedringer. Å sende en melding er nå mye raskere.
|
||||
Full endringslogg: https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
|
@ -0,0 +1,2 @@
|
|||
Denne nye versjonen inneholder hovedsakelig forbedringer av brukergrensesnittet og brukeropplevelsen. Nå kan du invitere venner og opprette DM veldig raskt ved å skanne QR-koder.
|
||||
Full endringslogg: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1 @@
|
|||
Sikker desentralisert chat & VoIP. Beskytt dataene dine fra tredjeparter.
|
|
@ -0,0 +1 @@
|
|||
Element (tidligere Riot.im)
|
|
@ -0,0 +1,2 @@
|
|||
Esta nova versão contém principalmente melhorias na interface do usuário e na experiência do usuário. Agora você pode convidar amigos e criar conversas rapidamente, digitalizando códigos QR.
|
||||
Registro completo de alterações: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1,2 @@
|
|||
Эта новая версия в основном содержит исправления ошибок и улучшения. Отправка сообщения стала намного быстрее.
|
||||
Полный список изменений: https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
|
@ -0,0 +1,2 @@
|
|||
Эта новая версия в основном содержит улучшения пользовательского интерфейса и взаимодействия с пользователем. Теперь вы можете приглашать друзей и очень быстро создавать чаты, сканируя QR-коды.
|
||||
Полный список изменений: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1,2 @@
|
|||
Táto verzia obsahuje predovšetkým opravy chýb. Odosielanie správ je odteraz omnoho rýchlejšie.
|
||||
Kompletný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
|
@ -0,0 +1,2 @@
|
|||
Táto verzia obsahuje najmä vylepšenia používateľského rozhrania. Pozývať priateľov alebo vytvárať priame konverzácie môžete veľmi rýchlo naskenovaním QR kódov.
|
||||
Kompletný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1,2 @@
|
|||
Den här nya versionen innehåller mest förbättringar för användargränssnittet och användarupplevelsen. Du kan nu bjuda in vänner och skapa direktmeddelanden väldigt snabbt genom att skanna QR-koder.
|
||||
Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1,2 @@
|
|||
Ця нова версія містить переважно поліпшення інтерфейсу та зручності користування. Тепер ви можете запросити друзів і створити прямі повідомлення дуже швидко, скануючи QR-коди.
|
||||
Повний перелік змін: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1,2 @@
|
|||
Phiên bản mới này chủ yếu bao gồm sửa lỗi và một số cải thiện. Gửi tin nhắn trở nên nhanh chóng hơn trước.
|
||||
Danh sách đầy đủ các thay đổi: https://github.com/vector-im/element-android/releases/tag/v1.0.10
|
|
@ -0,0 +1,2 @@
|
|||
Phiên bản mới này chủ yếu bao gồm các cải thiện về giao diện và trải nghiệm người dùng. Bây giờ bạn có thể mời bạn bè và bắt đầu nói chuyện nhanh chóng bằng cách quét mã QR.
|
||||
Danh sách đầy đủ các thay đổi: https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -0,0 +1 @@
|
|||
Ứng dụng chat và gọi phân tán bảo mật. Bảo vệ dữ liệu của bạn khỏi bên thứ ba.
|
|
@ -0,0 +1 @@
|
|||
Element (trước là Riot.im)
|
|
@ -0,0 +1,2 @@
|
|||
這個新版本主要包含使用者介面與使用者體驗改善。現在您可以邀請朋友,並透過掃描 QR code 來快速建立直接訊息了。
|
||||
完整變更紀錄:https://github.com/vector-im/element-android/releases/tag/v1.0.11
|
|
@ -1,6 +1,6 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=22449f5231796abd892c98b2a07c9ceebe4688d192cd2d6763f8e3bf8acbedeb
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
|
||||
distributionSha256Sum=a7ca23b3ccf265680f2bfd35f1f00b1424f4466292c7337c85d46c9641b3f053
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -167,9 +167,6 @@ dependencies {
|
|||
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
|
||||
|
||||
// Bus
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
|
||||
// Phone number https://github.com/google/libphonenumber
|
||||
implementation 'com.googlecode.libphonenumber:libphonenumber:8.10.23'
|
||||
|
||||
|
|
|
@ -20,14 +20,8 @@
|
|||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
|
||||
### EVENT BUS ###
|
||||
|
||||
# BMA: Not sure I can delete this one without side effect
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class * {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
|
||||
### MOSHI ###
|
||||
|
||||
|
|
|
@ -37,6 +37,6 @@ class SenderNotificationPermissionCondition(
|
|||
|
||||
fun isSatisfied(event: Event, powerLevels: PowerLevelsContent): Boolean {
|
||||
val powerLevelsHelper = PowerLevelsHelper(powerLevels)
|
||||
return event.senderId != null && powerLevelsHelper.getUserPowerLevelValue(event.senderId) >= powerLevelsHelper.notificationLevel(key)
|
||||
return event.senderId != null && powerLevelsHelper.getUserPowerLevelValue(event.senderId) >= powerLevels.notificationLevel(key)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ interface PermalinkService {
|
|||
|
||||
companion object {
|
||||
const val MATRIX_TO_URL_BASE = "https://matrix.to/#/"
|
||||
const val MATRIX_TO_CUSTOM_SCHEME_URL_BASE = "element://"
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,28 +25,85 @@ import org.matrix.android.sdk.api.session.room.powerlevels.Role
|
|||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class PowerLevelsContent(
|
||||
/**
|
||||
* The level required to ban a user. Defaults to 50 if unspecified.
|
||||
*/
|
||||
@Json(name = "ban") val ban: Int = Role.Moderator.value,
|
||||
/**
|
||||
* The level required to kick a user. Defaults to 50 if unspecified.
|
||||
*/
|
||||
@Json(name = "kick") val kick: Int = Role.Moderator.value,
|
||||
/**
|
||||
* The level required to invite a user. Defaults to 50 if unspecified.
|
||||
*/
|
||||
@Json(name = "invite") val invite: Int = Role.Moderator.value,
|
||||
/**
|
||||
* The level required to redact an event. Defaults to 50 if unspecified.
|
||||
*/
|
||||
@Json(name = "redact") val redact: Int = Role.Moderator.value,
|
||||
/**
|
||||
* The default level required to send message events. Can be overridden by the events key. Defaults to 0 if unspecified.
|
||||
*/
|
||||
@Json(name = "events_default") val eventsDefault: Int = Role.Default.value,
|
||||
@Json(name = "events") val events: MutableMap<String, Int> = HashMap(),
|
||||
/**
|
||||
* The level required to send specific event types. This is a mapping from event type to power level required.
|
||||
*/
|
||||
@Json(name = "events") val events: Map<String, Int> = emptyMap(),
|
||||
/**
|
||||
* The default power level for every user in the room, unless their user_id is mentioned in the users key. Defaults to 0 if unspecified.
|
||||
*/
|
||||
@Json(name = "users_default") val usersDefault: Int = Role.Default.value,
|
||||
@Json(name = "users") val users: MutableMap<String, Int> = HashMap(),
|
||||
/**
|
||||
* The power levels for specific users. This is a mapping from user_id to power level for that user.
|
||||
*/
|
||||
@Json(name = "users") val users: Map<String, Int> = emptyMap(),
|
||||
/**
|
||||
* The default level required to send state events. Can be overridden by the events key. Defaults to 50 if unspecified.
|
||||
*/
|
||||
@Json(name = "state_default") val stateDefault: Int = Role.Moderator.value,
|
||||
@Json(name = "notifications") val notifications: Map<String, Any> = HashMap()
|
||||
/**
|
||||
* The power level requirements for specific notification types. This is a mapping from key to power level for that notifications key.
|
||||
*/
|
||||
@Json(name = "notifications") val notifications: Map<String, Any> = emptyMap()
|
||||
) {
|
||||
/**
|
||||
* Alter this content with a new power level for the specified user
|
||||
* Return a copy of this content with a new power level for the specified user
|
||||
*
|
||||
* @param userId the userId to alter the power level of
|
||||
* @param powerLevel the new power level, or null to set the default value.
|
||||
*/
|
||||
fun setUserPowerLevel(userId: String, powerLevel: Int?) {
|
||||
if (powerLevel == null || powerLevel == usersDefault) {
|
||||
users.remove(userId)
|
||||
} else {
|
||||
users[userId] = powerLevel
|
||||
fun setUserPowerLevel(userId: String, powerLevel: Int?): PowerLevelsContent {
|
||||
return copy(
|
||||
users = users.toMutableMap().apply {
|
||||
if (powerLevel == null || powerLevel == usersDefault) {
|
||||
remove(userId)
|
||||
} else {
|
||||
put(userId, powerLevel)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification level for a dedicated key.
|
||||
*
|
||||
* @param key the notification key
|
||||
* @return the level, default to Moderator if the key is not found
|
||||
*/
|
||||
fun notificationLevel(key: String): Int {
|
||||
return when (val value = notifications[key]) {
|
||||
// the first implementation was a string value
|
||||
is String -> value.toInt()
|
||||
is Double -> value.toInt()
|
||||
is Int -> value
|
||||
else -> Role.Moderator.value
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Key to use for content.notifications and get the level required to trigger an @room notification. Defaults to 50 if unspecified.
|
||||
*/
|
||||
const val NOTIFICATIONS_ROOM_KEY = "room"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,19 +108,4 @@ class PowerLevelsHelper(private val powerLevelsContent: PowerLevelsContent) {
|
|||
val powerLevel = getUserPowerLevelValue(userId)
|
||||
return powerLevel >= powerLevelsContent.redact
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification level for a dedicated key.
|
||||
*
|
||||
* @param key the notification key
|
||||
* @return the level
|
||||
*/
|
||||
fun notificationLevel(key: String): Int {
|
||||
return when (val value = powerLevelsContent.notifications[key]) {
|
||||
// the first implementation was a string value
|
||||
is String -> value.toInt()
|
||||
is Int -> value
|
||||
else -> Role.Moderator.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2020 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.state
|
||||
|
||||
import org.matrix.android.sdk.api.query.QueryStringValue
|
||||
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.RoomJoinRules
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesContent
|
||||
|
||||
/**
|
||||
* Return true if a room can be joined by anyone (RoomJoinRules.PUBLIC)
|
||||
*/
|
||||
fun StateService.isPublic(): Boolean {
|
||||
return getStateEvent(EventType.STATE_ROOM_JOIN_RULES, QueryStringValue.NoCondition)
|
||||
?.content
|
||||
?.toModel<RoomJoinRulesContent>()
|
||||
?.joinRules == RoomJoinRules.PUBLIC
|
||||
}
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
|
|||
import android.content.Context
|
||||
import androidx.work.WorkerParameters
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.failure.shouldBeRetried
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
|
@ -60,7 +59,6 @@ internal class CancelGossipRequestWorker(context: Context,
|
|||
|
||||
@Inject lateinit var sendToDeviceTask: SendToDeviceTask
|
||||
@Inject lateinit var cryptoStore: IMXCryptoStore
|
||||
@Inject lateinit var eventBus: EventBus
|
||||
@Inject lateinit var credentials: Credentials
|
||||
|
||||
override fun injectWith(injector: SessionComponent) {
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
|
|||
import android.content.Context
|
||||
import androidx.work.WorkerParameters
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.failure.shouldBeRetried
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
|
@ -52,7 +51,6 @@ internal class SendGossipRequestWorker(context: Context,
|
|||
|
||||
@Inject lateinit var sendToDeviceTask: SendToDeviceTask
|
||||
@Inject lateinit var cryptoStore: IMXCryptoStore
|
||||
@Inject lateinit var eventBus: EventBus
|
||||
@Inject lateinit var credentials: Credentials
|
||||
|
||||
override fun injectWith(injector: SessionComponent) {
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
|
|||
import android.content.Context
|
||||
import androidx.work.WorkerParameters
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.failure.shouldBeRetried
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
|
@ -54,7 +53,6 @@ internal class SendGossipWorker(context: Context,
|
|||
|
||||
@Inject lateinit var sendToDeviceTask: SendToDeviceTask
|
||||
@Inject lateinit var cryptoStore: IMXCryptoStore
|
||||
@Inject lateinit var eventBus: EventBus
|
||||
@Inject lateinit var credentials: Credentials
|
||||
@Inject lateinit var messageEncrypter: MessageEncrypter
|
||||
@Inject lateinit var ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction
|
||||
|
|
|
@ -19,20 +19,20 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.CreateKeysBackupVersionBody
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface CreateKeysBackupVersionTask : Task<CreateKeysBackupVersionBody, KeysVersion>
|
||||
|
||||
internal class DefaultCreateKeysBackupVersionTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : CreateKeysBackupVersionTask {
|
||||
|
||||
override suspend fun execute(params: CreateKeysBackupVersionBody): KeysVersion {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.createKeysBackupVersion(params)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
||||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface DeleteBackupTask : Task<DeleteBackupTask.Params, Unit> {
|
||||
|
@ -30,11 +30,11 @@ internal interface DeleteBackupTask : Task<DeleteBackupTask.Params, Unit> {
|
|||
|
||||
internal class DefaultDeleteBackupTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : DeleteBackupTask {
|
||||
|
||||
override suspend fun execute(params: DeleteBackupTask.Params) {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.deleteBackup(params.version)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
||||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface DeleteRoomSessionDataTask : Task<DeleteRoomSessionDataTask.Params, Unit> {
|
||||
|
@ -32,11 +32,11 @@ internal interface DeleteRoomSessionDataTask : Task<DeleteRoomSessionDataTask.Pa
|
|||
|
||||
internal class DefaultDeleteRoomSessionDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : DeleteRoomSessionDataTask {
|
||||
|
||||
override suspend fun execute(params: DeleteRoomSessionDataTask.Params) {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.deleteRoomSessionData(
|
||||
params.roomId,
|
||||
params.sessionId,
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
||||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface DeleteRoomSessionsDataTask : Task<DeleteRoomSessionsDataTask.Params, Unit> {
|
||||
|
@ -31,11 +31,11 @@ internal interface DeleteRoomSessionsDataTask : Task<DeleteRoomSessionsDataTask.
|
|||
|
||||
internal class DefaultDeleteRoomSessionsDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : DeleteRoomSessionsDataTask {
|
||||
|
||||
override suspend fun execute(params: DeleteRoomSessionsDataTask.Params) {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.deleteRoomSessionsData(
|
||||
params.roomId,
|
||||
params.version)
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
||||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface DeleteSessionsDataTask : Task<DeleteSessionsDataTask.Params, Unit> {
|
||||
|
@ -30,11 +30,11 @@ internal interface DeleteSessionsDataTask : Task<DeleteSessionsDataTask.Params,
|
|||
|
||||
internal class DefaultDeleteSessionsDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : DeleteSessionsDataTask {
|
||||
|
||||
override suspend fun execute(params: DeleteSessionsDataTask.Params) {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.deleteSessionsData(params.version)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,20 +18,20 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetKeysBackupLastVersionTask : Task<Unit, KeysVersionResult>
|
||||
|
||||
internal class DefaultGetKeysBackupLastVersionTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetKeysBackupLastVersionTask {
|
||||
|
||||
override suspend fun execute(params: Unit): KeysVersionResult {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.getKeysBackupLastVersion()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,20 +18,20 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetKeysBackupVersionTask : Task<String, KeysVersionResult>
|
||||
|
||||
internal class DefaultGetKeysBackupVersionTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetKeysBackupVersionTask {
|
||||
|
||||
override suspend fun execute(params: String): KeysVersionResult {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.getKeysBackupVersion(params)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeyBackupData
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetRoomSessionDataTask : Task<GetRoomSessionDataTask.Params, KeyBackupData> {
|
||||
|
@ -33,11 +33,11 @@ internal interface GetRoomSessionDataTask : Task<GetRoomSessionDataTask.Params,
|
|||
|
||||
internal class DefaultGetRoomSessionDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetRoomSessionDataTask {
|
||||
|
||||
override suspend fun execute(params: GetRoomSessionDataTask.Params): KeyBackupData {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.getRoomSessionData(
|
||||
params.roomId,
|
||||
params.sessionId,
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.RoomKeysBackupData
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetRoomSessionsDataTask : Task<GetRoomSessionsDataTask.Params, RoomKeysBackupData> {
|
||||
|
@ -32,11 +32,11 @@ internal interface GetRoomSessionsDataTask : Task<GetRoomSessionsDataTask.Params
|
|||
|
||||
internal class DefaultGetRoomSessionsDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetRoomSessionsDataTask {
|
||||
|
||||
override suspend fun execute(params: GetRoomSessionsDataTask.Params): RoomKeysBackupData {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.getRoomSessionsData(
|
||||
params.roomId,
|
||||
params.version)
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysBackupData
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetSessionsDataTask : Task<GetSessionsDataTask.Params, KeysBackupData> {
|
||||
|
@ -31,11 +31,11 @@ internal interface GetSessionsDataTask : Task<GetSessionsDataTask.Params, KeysBa
|
|||
|
||||
internal class DefaultGetSessionsDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetSessionsDataTask {
|
||||
|
||||
override suspend fun execute(params: GetSessionsDataTask.Params): KeysBackupData {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.getSessionsData(params.version)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.BackupKeysResult
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeyBackupData
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface StoreRoomSessionDataTask : Task<StoreRoomSessionDataTask.Params, BackupKeysResult> {
|
||||
|
@ -35,11 +35,11 @@ internal interface StoreRoomSessionDataTask : Task<StoreRoomSessionDataTask.Para
|
|||
|
||||
internal class DefaultStoreRoomSessionDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : StoreRoomSessionDataTask {
|
||||
|
||||
override suspend fun execute(params: StoreRoomSessionDataTask.Params): BackupKeysResult {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.storeRoomSessionData(
|
||||
params.roomId,
|
||||
params.sessionId,
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.BackupKeysResult
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.RoomKeysBackupData
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface StoreRoomSessionsDataTask : Task<StoreRoomSessionsDataTask.Params, BackupKeysResult> {
|
||||
|
@ -34,11 +34,11 @@ internal interface StoreRoomSessionsDataTask : Task<StoreRoomSessionsDataTask.Pa
|
|||
|
||||
internal class DefaultStoreRoomSessionsDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : StoreRoomSessionsDataTask {
|
||||
|
||||
override suspend fun execute(params: StoreRoomSessionsDataTask.Params): BackupKeysResult {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.storeRoomSessionsData(
|
||||
params.roomId,
|
||||
params.version,
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.BackupKeysResult
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysBackupData
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface StoreSessionsDataTask : Task<StoreSessionsDataTask.Params, BackupKeysResult> {
|
||||
|
@ -33,11 +33,11 @@ internal interface StoreSessionsDataTask : Task<StoreSessionsDataTask.Params, Ba
|
|||
|
||||
internal class DefaultStoreSessionsDataTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : StoreSessionsDataTask {
|
||||
|
||||
override suspend fun execute(params: StoreSessionsDataTask.Params): BackupKeysResult {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.storeSessionsData(
|
||||
params.version,
|
||||
params.keysBackupData)
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.UpdateKeysBackupVersionBody
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface UpdateKeysBackupVersionTask : Task<UpdateKeysBackupVersionTask.Params, Unit> {
|
||||
|
@ -32,11 +32,11 @@ internal interface UpdateKeysBackupVersionTask : Task<UpdateKeysBackupVersionTas
|
|||
|
||||
internal class DefaultUpdateKeysBackupVersionTask @Inject constructor(
|
||||
private val roomKeysApi: RoomKeysApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : UpdateKeysBackupVersionTask {
|
||||
|
||||
override suspend fun execute(params: UpdateKeysBackupVersionTask.Params) {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = roomKeysApi.updateKeysBackupVersion(params.version, params.keysBackupVersionBody)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ 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
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -36,13 +36,13 @@ internal interface ClaimOneTimeKeysForUsersDeviceTask : Task<ClaimOneTimeKeysFor
|
|||
|
||||
internal class DefaultClaimOneTimeKeysForUsersDevice @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : ClaimOneTimeKeysForUsersDeviceTask {
|
||||
|
||||
override suspend fun execute(params: ClaimOneTimeKeysForUsersDeviceTask.Params): MXUsersDevicesMap<MXKey> {
|
||||
val body = KeysClaimBody(oneTimeKeys = params.usersDevicesKeyTypesMap.map)
|
||||
|
||||
val keysClaimResponse = executeRequest<KeysClaimResponse>(eventBus) {
|
||||
val keysClaimResponse = executeRequest<KeysClaimResponse>(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.claimOneTimeKeysForUsersDevices(body)
|
||||
}
|
||||
val map = MXUsersDevicesMap<MXKey>()
|
||||
|
|
|
@ -20,9 +20,9 @@ import org.matrix.android.sdk.api.failure.Failure
|
|||
import org.matrix.android.sdk.api.failure.toRegistrationFlowResponse
|
||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeleteDeviceParams
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface DeleteDeviceTask : Task<DeleteDeviceTask.Params, Unit> {
|
||||
|
@ -33,12 +33,12 @@ internal interface DeleteDeviceTask : Task<DeleteDeviceTask.Params, Unit> {
|
|||
|
||||
internal class DefaultDeleteDeviceTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : DeleteDeviceTask {
|
||||
|
||||
override suspend fun execute(params: DeleteDeviceTask.Params) {
|
||||
try {
|
||||
executeRequest<Unit>(eventBus) {
|
||||
executeRequest<Unit>(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.deleteDevice(params.deviceId, DeleteDeviceParams())
|
||||
}
|
||||
} catch (throwable: Throwable) {
|
||||
|
|
|
@ -21,9 +21,9 @@ import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
|||
import org.matrix.android.sdk.internal.crypto.model.rest.DeleteDeviceParams
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.UserPasswordAuth
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface DeleteDeviceWithUserPasswordTask : Task<DeleteDeviceWithUserPasswordTask.Params, Unit> {
|
||||
|
@ -37,11 +37,11 @@ internal interface DeleteDeviceWithUserPasswordTask : Task<DeleteDeviceWithUserP
|
|||
internal class DefaultDeleteDeviceWithUserPasswordTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
@UserId private val userId: String,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : DeleteDeviceWithUserPasswordTask {
|
||||
|
||||
override suspend fun execute(params: DeleteDeviceWithUserPasswordTask.Params) {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.deleteDevice(params.deviceId,
|
||||
DeleteDeviceParams(
|
||||
userPasswordAuth = UserPasswordAuth(
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
|||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeysQueryBody
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeysQueryResponse
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface DownloadKeysForUsersTask : Task<DownloadKeysForUsersTask.Params, KeysQueryResponse> {
|
||||
|
@ -35,7 +35,7 @@ internal interface DownloadKeysForUsersTask : Task<DownloadKeysForUsersTask.Para
|
|||
|
||||
internal class DefaultDownloadKeysForUsers @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : DownloadKeysForUsersTask {
|
||||
|
||||
override suspend fun execute(params: DownloadKeysForUsersTask.Params): KeysQueryResponse {
|
||||
|
@ -46,7 +46,7 @@ internal class DefaultDownloadKeysForUsers @Inject constructor(
|
|||
token = params.token?.takeIf { it.isNotEmpty() }
|
||||
)
|
||||
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.downloadKeysForUsers(body)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetDeviceInfoTask : Task<GetDeviceInfoTask.Params, DeviceInfo> {
|
||||
|
@ -29,11 +29,11 @@ internal interface GetDeviceInfoTask : Task<GetDeviceInfoTask.Params, DeviceInfo
|
|||
|
||||
internal class DefaultGetDeviceInfoTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetDeviceInfoTask {
|
||||
|
||||
override suspend fun execute(params: GetDeviceInfoTask.Params): DeviceInfo {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.getDeviceInfo(params.deviceId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,20 +18,20 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.DevicesListResponse
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetDevicesTask : Task<Unit, DevicesListResponse>
|
||||
|
||||
internal class DefaultGetDevicesTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetDevicesTask {
|
||||
|
||||
override suspend fun execute(params: Unit): DevicesListResponse {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.getDevices()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeyChangesResponse
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetKeyChangesTask : Task<GetKeyChangesTask.Params, KeyChangesResponse> {
|
||||
|
@ -34,11 +34,11 @@ internal interface GetKeyChangesTask : Task<GetKeyChangesTask.Params, KeyChanges
|
|||
|
||||
internal class DefaultGetKeyChangesTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetKeyChangesTask {
|
||||
|
||||
override suspend fun execute(params: GetKeyChangesTask.Params): KeyChangesResponse {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.getKeyChanges(params.from, params.to)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package org.matrix.android.sdk.internal.crypto.tasks
|
||||
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
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
|
||||
|
@ -33,10 +33,10 @@ internal interface RedactEventTask : Task<RedactEventTask.Params, String> {
|
|||
|
||||
internal class DefaultRedactEventTask @Inject constructor(
|
||||
private val roomAPI: RoomAPI,
|
||||
private val eventBus: EventBus) : RedactEventTask {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : RedactEventTask {
|
||||
|
||||
override suspend fun execute(params: RedactEventTask.Params): String {
|
||||
val executeRequest = executeRequest<SendResponse>(eventBus) {
|
||||
val executeRequest = executeRequest<SendResponse>(globalErrorReceiver) {
|
||||
apiCall = roomAPI.redactEvent(
|
||||
txId = params.txID,
|
||||
roomId = params.roomId,
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
*/
|
||||
package org.matrix.android.sdk.internal.crypto.tasks
|
||||
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||
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.membership.LoadRoomMembersTask
|
||||
|
@ -38,7 +38,7 @@ internal class DefaultSendEventTask @Inject constructor(
|
|||
private val encryptEventTask: DefaultEncryptEventTask,
|
||||
private val loadRoomMembersTask: LoadRoomMembersTask,
|
||||
private val roomAPI: RoomAPI,
|
||||
private val eventBus: EventBus) : SendEventTask {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : SendEventTask {
|
||||
|
||||
override suspend fun execute(params: SendEventTask.Params): String {
|
||||
try {
|
||||
|
@ -53,7 +53,7 @@ internal class DefaultSendEventTask @Inject constructor(
|
|||
val localId = event.eventId!!
|
||||
|
||||
localEchoRepository.updateSendState(localId, params.event.roomId, SendState.SENDING)
|
||||
val executeRequest = executeRequest<SendResponse>(eventBus) {
|
||||
val executeRequest = executeRequest<SendResponse>(globalErrorReceiver) {
|
||||
apiCall = roomAPI.send(
|
||||
localId,
|
||||
roomId = event.roomId ?: "",
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
|||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.SendToDeviceBody
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
import kotlin.random.Random
|
||||
|
||||
|
@ -38,7 +38,7 @@ internal interface SendToDeviceTask : Task<SendToDeviceTask.Params, Unit> {
|
|||
|
||||
internal class DefaultSendToDeviceTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : SendToDeviceTask {
|
||||
|
||||
override suspend fun execute(params: SendToDeviceTask.Params) {
|
||||
|
@ -46,7 +46,7 @@ internal class DefaultSendToDeviceTask @Inject constructor(
|
|||
messages = params.contentMap.map
|
||||
)
|
||||
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.sendToDevice(
|
||||
params.eventType,
|
||||
params.transactionId ?: Random.nextInt(Integer.MAX_VALUE).toString(),
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
*/
|
||||
package org.matrix.android.sdk.internal.crypto.tasks
|
||||
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||
import org.matrix.android.sdk.internal.crypto.CryptoSessionInfoProvider
|
||||
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
|
||||
|
@ -37,7 +37,7 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
|
|||
private val encryptEventTask: DefaultEncryptEventTask,
|
||||
private val roomAPI: RoomAPI,
|
||||
private val cryptoSessionInfoProvider: CryptoSessionInfoProvider,
|
||||
private val eventBus: EventBus) : SendVerificationMessageTask {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : SendVerificationMessageTask {
|
||||
|
||||
override suspend fun execute(params: SendVerificationMessageTask.Params): String {
|
||||
val event = handleEncryption(params)
|
||||
|
@ -45,7 +45,7 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
|
|||
|
||||
try {
|
||||
localEchoRepository.updateSendState(localId, event.roomId, SendState.SENDING)
|
||||
val executeRequest = executeRequest<SendResponse>(eventBus) {
|
||||
val executeRequest = executeRequest<SendResponse>(globalErrorReceiver) {
|
||||
apiCall = roomAPI.send(
|
||||
localId,
|
||||
roomId = event.roomId ?: "",
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.UpdateDeviceInfoBody
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface SetDeviceNameTask : Task<SetDeviceNameTask.Params, Unit> {
|
||||
|
@ -34,14 +34,14 @@ internal interface SetDeviceNameTask : Task<SetDeviceNameTask.Params, Unit> {
|
|||
|
||||
internal class DefaultSetDeviceNameTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : SetDeviceNameTask {
|
||||
|
||||
override suspend fun execute(params: SetDeviceNameTask.Params) {
|
||||
val body = UpdateDeviceInfoBody(
|
||||
displayName = params.deviceName
|
||||
)
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.updateDeviceInfo(params.deviceId, body)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
|||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceKeys
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeysUploadBody
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeysUploadResponse
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -38,7 +38,7 @@ internal interface UploadKeysTask : Task<UploadKeysTask.Params, KeysUploadRespon
|
|||
|
||||
internal class DefaultUploadKeysTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : UploadKeysTask {
|
||||
|
||||
override suspend fun execute(params: UploadKeysTask.Params): KeysUploadResponse {
|
||||
|
@ -49,7 +49,7 @@ internal class DefaultUploadKeysTask @Inject constructor(
|
|||
|
||||
Timber.i("## Uploading device keys -> $body")
|
||||
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.uploadKeys(body)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ 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
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface UploadSignaturesTask : Task<UploadSignaturesTask.Params, Unit> {
|
||||
|
@ -31,12 +31,12 @@ internal interface UploadSignaturesTask : Task<UploadSignaturesTask.Params, Unit
|
|||
|
||||
internal class DefaultUploadSignaturesTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : UploadSignaturesTask {
|
||||
|
||||
override suspend fun execute(params: UploadSignaturesTask.Params) {
|
||||
try {
|
||||
val response = executeRequest<SignatureUploadResponse>(eventBus) {
|
||||
val response = executeRequest<SignatureUploadResponse>(globalErrorReceiver) {
|
||||
this.isRetryable = true
|
||||
this.maxRetryCount = 10
|
||||
this.apiCall = cryptoApi.uploadSignatures(params.signatures)
|
||||
|
|
|
@ -25,9 +25,9 @@ import org.matrix.android.sdk.internal.crypto.model.rest.KeysQueryResponse
|
|||
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.UserPasswordAuth
|
||||
import org.matrix.android.sdk.internal.crypto.model.toRest
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface UploadSigningKeysTask : Task<UploadSigningKeysTask.Params, Unit> {
|
||||
|
@ -55,7 +55,7 @@ data class UploadSigningKeys(val failures: Map<String, Any>?) : Failure.FeatureF
|
|||
|
||||
internal class DefaultUploadSigningKeysTask @Inject constructor(
|
||||
private val cryptoApi: CryptoApi,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : UploadSigningKeysTask {
|
||||
|
||||
override suspend fun execute(params: UploadSigningKeysTask.Params) {
|
||||
|
@ -87,7 +87,7 @@ internal class DefaultUploadSigningKeysTask @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun doRequest(uploadQuery: UploadSigningKeysBody) {
|
||||
val keysQueryResponse = executeRequest<KeysQueryResponse>(eventBus) {
|
||||
val keysQueryResponse = executeRequest<KeysQueryResponse>(globalErrorReceiver) {
|
||||
apiCall = cryptoApi.uploadSigningKeys(uploadQuery)
|
||||
}
|
||||
if (keysQueryResponse.failures?.isNotEmpty() == true) {
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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.network
|
||||
|
||||
import org.matrix.android.sdk.api.failure.GlobalError
|
||||
import org.matrix.android.sdk.internal.auth.SessionParamsStore
|
||||
import org.matrix.android.sdk.internal.di.SessionId
|
||||
import org.matrix.android.sdk.internal.session.SessionScope
|
||||
import org.matrix.android.sdk.internal.task.TaskExecutor
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@SessionScope
|
||||
internal class GlobalErrorHandler @Inject constructor(
|
||||
private val taskExecutor: TaskExecutor,
|
||||
private val sessionParamsStore: SessionParamsStore,
|
||||
@SessionId private val sessionId: String
|
||||
) : GlobalErrorReceiver {
|
||||
|
||||
var listener: Listener? = null
|
||||
|
||||
override fun handleGlobalError(globalError: GlobalError) {
|
||||
Timber.e("Global error received: $globalError")
|
||||
|
||||
if (globalError is GlobalError.InvalidToken && globalError.softLogout) {
|
||||
// Mark the token has invalid
|
||||
taskExecutor.executorScope.launch(Dispatchers.IO) {
|
||||
sessionParamsStore.setTokenInvalid(sessionId)
|
||||
}
|
||||
}
|
||||
|
||||
listener?.onGlobalError(globalError)
|
||||
}
|
||||
|
||||
internal interface Listener {
|
||||
fun onGlobalError(globalError: GlobalError)
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
* 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.
|
||||
|
@ -14,18 +14,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.eventbus
|
||||
package org.matrix.android.sdk.internal.network
|
||||
|
||||
import org.greenrobot.eventbus.Logger
|
||||
import timber.log.Timber
|
||||
import java.util.logging.Level
|
||||
import org.matrix.android.sdk.api.failure.GlobalError
|
||||
|
||||
class EventBusTimberLogger : Logger {
|
||||
override fun log(level: Level, msg: String) {
|
||||
Timber.d(msg)
|
||||
}
|
||||
|
||||
override fun log(level: Level, msg: String, th: Throwable) {
|
||||
Timber.e(th, msg)
|
||||
}
|
||||
internal interface GlobalErrorReceiver {
|
||||
fun handleGlobalError(globalError: GlobalError)
|
||||
}
|
|
@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.network
|
|||
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.delay
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.failure.shouldBeRetried
|
||||
import org.matrix.android.sdk.internal.network.ssl.CertUtil
|
||||
|
@ -27,10 +26,10 @@ import retrofit2.awaitResponse
|
|||
import timber.log.Timber
|
||||
import java.io.IOException
|
||||
|
||||
internal suspend inline fun <DATA : Any> executeRequest(eventBus: EventBus?,
|
||||
block: Request<DATA>.() -> Unit) = Request<DATA>(eventBus).apply(block).execute()
|
||||
internal suspend inline fun <DATA : Any> executeRequest(globalErrorReceiver: GlobalErrorReceiver?,
|
||||
block: Request<DATA>.() -> Unit) = Request<DATA>(globalErrorReceiver).apply(block).execute()
|
||||
|
||||
internal class Request<DATA : Any>(private val eventBus: EventBus?) {
|
||||
internal class Request<DATA : Any>(private val globalErrorReceiver: GlobalErrorReceiver?) {
|
||||
|
||||
var isRetryable = false
|
||||
var initialDelay: Long = 100L
|
||||
|
@ -47,7 +46,7 @@ internal class Request<DATA : Any>(private val eventBus: EventBus?) {
|
|||
response.body()
|
||||
?: throw IllegalStateException("The request returned a null body")
|
||||
} else {
|
||||
throw response.toFailure(eventBus)
|
||||
throw response.toFailure(globalErrorReceiver)
|
||||
}
|
||||
} catch (exception: Throwable) {
|
||||
// Log some details about the request which has failed
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.matrix.android.sdk.api.failure.MatrixError
|
|||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import okhttp3.ResponseBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import retrofit2.Response
|
||||
import timber.log.Timber
|
||||
import java.io.IOException
|
||||
|
@ -54,18 +53,18 @@ internal suspend fun okhttp3.Call.awaitResponse(): okhttp3.Response {
|
|||
/**
|
||||
* Convert a retrofit Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
|
||||
*/
|
||||
internal fun <T> Response<T>.toFailure(eventBus: EventBus?): Failure {
|
||||
return toFailure(errorBody(), code(), eventBus)
|
||||
internal fun <T> Response<T>.toFailure(globalErrorReceiver: GlobalErrorReceiver?): Failure {
|
||||
return toFailure(errorBody(), code(), globalErrorReceiver)
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a okhttp3 Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
|
||||
*/
|
||||
internal fun okhttp3.Response.toFailure(eventBus: EventBus?): Failure {
|
||||
return toFailure(body, code, eventBus)
|
||||
internal fun okhttp3.Response.toFailure(globalErrorReceiver: GlobalErrorReceiver?): Failure {
|
||||
return toFailure(body, code, globalErrorReceiver)
|
||||
}
|
||||
|
||||
private fun toFailure(errorBody: ResponseBody?, httpCode: Int, eventBus: EventBus?): Failure {
|
||||
private fun toFailure(errorBody: ResponseBody?, httpCode: Int, globalErrorReceiver: GlobalErrorReceiver?): Failure {
|
||||
if (errorBody == null) {
|
||||
return Failure.Unknown(RuntimeException("errorBody should not be null"))
|
||||
}
|
||||
|
@ -79,12 +78,12 @@ private fun toFailure(errorBody: ResponseBody?, httpCode: Int, eventBus: EventBu
|
|||
|
||||
if (matrixError != null) {
|
||||
if (matrixError.code == MatrixError.M_CONSENT_NOT_GIVEN && !matrixError.consentUri.isNullOrBlank()) {
|
||||
// Also send this error to the bus, for a global management
|
||||
eventBus?.post(GlobalError.ConsentNotGivenError(matrixError.consentUri))
|
||||
// Also send this error to the globalErrorReceiver, for a global management
|
||||
globalErrorReceiver?.handleGlobalError(GlobalError.ConsentNotGivenError(matrixError.consentUri))
|
||||
} else if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
|
||||
&& matrixError.code == MatrixError.M_UNKNOWN_TOKEN) {
|
||||
// Also send this error to the bus, for a global management
|
||||
eventBus?.post(GlobalError.InvalidToken(matrixError.isSoftLogout))
|
||||
// Also send this error to the globalErrorReceiver, for a global management
|
||||
globalErrorReceiver?.handleGlobalError(GlobalError.InvalidToken(matrixError.isSoftLogout))
|
||||
}
|
||||
|
||||
return Failure.ServerError(matrixError, httpCode)
|
||||
|
|
|
@ -19,12 +19,7 @@ package org.matrix.android.sdk.internal.session
|
|||
import androidx.annotation.MainThread
|
||||
import dagger.Lazy
|
||||
import io.realm.RealmConfiguration
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.OkHttpClient
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import org.matrix.android.sdk.api.MatrixCallback
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.api.failure.GlobalError
|
||||
|
@ -65,13 +60,12 @@ import org.matrix.android.sdk.internal.di.SessionDatabase
|
|||
import org.matrix.android.sdk.internal.di.SessionId
|
||||
import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificate
|
||||
import org.matrix.android.sdk.internal.di.WorkManagerProvider
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorHandler
|
||||
import org.matrix.android.sdk.internal.session.identity.DefaultIdentityService
|
||||
import org.matrix.android.sdk.internal.session.room.send.queue.EventSenderProcessor
|
||||
import org.matrix.android.sdk.internal.session.sync.SyncTokenStore
|
||||
import org.matrix.android.sdk.internal.session.sync.job.SyncThread
|
||||
import org.matrix.android.sdk.internal.session.sync.job.SyncWorker
|
||||
import org.matrix.android.sdk.internal.task.TaskExecutor
|
||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||
import org.matrix.android.sdk.internal.util.createUIHandler
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
@ -81,7 +75,7 @@ import javax.inject.Provider
|
|||
internal class DefaultSession @Inject constructor(
|
||||
override val sessionParams: SessionParams,
|
||||
private val workManagerProvider: WorkManagerProvider,
|
||||
private val eventBus: EventBus,
|
||||
private val globalErrorHandler: GlobalErrorHandler,
|
||||
@SessionId
|
||||
override val sessionId: String,
|
||||
@SessionDatabase private val realmConfiguration: RealmConfiguration,
|
||||
|
@ -117,10 +111,8 @@ internal class DefaultSession @Inject constructor(
|
|||
private val accountDataService: Lazy<AccountDataService>,
|
||||
private val _sharedSecretStorageService: Lazy<SharedSecretStorageService>,
|
||||
private val accountService: Lazy<AccountService>,
|
||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||
private val defaultIdentityService: DefaultIdentityService,
|
||||
private val integrationManagerService: IntegrationManagerService,
|
||||
private val taskExecutor: TaskExecutor,
|
||||
private val callSignalingService: Lazy<CallSignalingService>,
|
||||
@UnauthenticatedWithCertificate
|
||||
private val unauthenticatedWithCertificateOkHttpClient: Lazy<OkHttpClient>,
|
||||
|
@ -140,7 +132,8 @@ internal class DefaultSession @Inject constructor(
|
|||
HomeServerCapabilitiesService by homeServerCapabilitiesService.get(),
|
||||
ProfileService by profileService.get(),
|
||||
AccountDataService by accountDataService.get(),
|
||||
AccountService by accountService.get() {
|
||||
AccountService by accountService.get(),
|
||||
GlobalErrorHandler.Listener {
|
||||
|
||||
override val sharedSecretStorageService: SharedSecretStorageService
|
||||
get() = _sharedSecretStorageService.get()
|
||||
|
@ -162,7 +155,7 @@ internal class DefaultSession @Inject constructor(
|
|||
uiHandler.post {
|
||||
lifecycleObservers.forEach { it.onStart() }
|
||||
}
|
||||
eventBus.register(this)
|
||||
globalErrorHandler.listener = this
|
||||
eventSenderProcessor.start()
|
||||
}
|
||||
|
||||
|
@ -206,7 +199,7 @@ internal class DefaultSession @Inject constructor(
|
|||
}
|
||||
cryptoService.get().close()
|
||||
isOpen = false
|
||||
eventBus.unregister(this)
|
||||
globalErrorHandler.listener = null
|
||||
eventSenderProcessor.interrupt()
|
||||
}
|
||||
|
||||
|
@ -234,16 +227,7 @@ internal class DefaultSession @Inject constructor(
|
|||
workManagerProvider.cancelAllWorks()
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onGlobalError(globalError: GlobalError) {
|
||||
if (globalError is GlobalError.InvalidToken
|
||||
&& globalError.softLogout) {
|
||||
// Mark the token has invalid
|
||||
taskExecutor.executorScope.launch(Dispatchers.IO) {
|
||||
sessionParamsStore.setTokenInvalid(sessionId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onGlobalError(globalError: GlobalError) {
|
||||
sessionListeners.dispatchGlobalError(globalError)
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import dagger.Provides
|
|||
import dagger.multibindings.IntoSet
|
||||
import io.realm.RealmConfiguration
|
||||
import okhttp3.OkHttpClient
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
|
@ -61,9 +60,10 @@ import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificate
|
|||
import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificateWithProgress
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.di.UserMd5
|
||||
import org.matrix.android.sdk.internal.eventbus.EventBusTimberLogger
|
||||
import org.matrix.android.sdk.internal.network.DefaultNetworkConnectivityChecker
|
||||
import org.matrix.android.sdk.internal.network.FallbackNetworkCallbackStrategy
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorHandler
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.NetworkCallbackStrategy
|
||||
import org.matrix.android.sdk.internal.network.NetworkConnectivityChecker
|
||||
import org.matrix.android.sdk.internal.network.PreferredNetworkCallbackStrategy
|
||||
|
@ -256,16 +256,6 @@ internal abstract class SessionModule {
|
|||
.create(okHttpClient, sessionParams.homeServerConnectionConfig.homeServerUri.toString())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@SessionScope
|
||||
fun providesEventBus(): EventBus {
|
||||
return EventBus
|
||||
.builder()
|
||||
.logger(EventBusTimberLogger())
|
||||
.build()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@SessionScope
|
||||
|
@ -294,6 +284,9 @@ internal abstract class SessionModule {
|
|||
@Binds
|
||||
abstract fun bindSession(session: DefaultSession): Session
|
||||
|
||||
@Binds
|
||||
abstract fun bindGlobalErrorReceiver(handler: GlobalErrorHandler): GlobalErrorReceiver
|
||||
|
||||
@Binds
|
||||
abstract fun bindNetworkConnectivityChecker(checker: DefaultNetworkConnectivityChecker): NetworkConnectivityChecker
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.session.account
|
|||
|
||||
import org.matrix.android.sdk.api.failure.toRegistrationFlowResponse
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface ChangePasswordTask : Task<ChangePasswordTask.Params, Unit> {
|
||||
|
@ -32,14 +32,14 @@ internal interface ChangePasswordTask : Task<ChangePasswordTask.Params, Unit> {
|
|||
|
||||
internal class DefaultChangePasswordTask @Inject constructor(
|
||||
private val accountAPI: AccountAPI,
|
||||
private val eventBus: EventBus,
|
||||
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||
@UserId private val userId: String
|
||||
) : ChangePasswordTask {
|
||||
|
||||
override suspend fun execute(params: ChangePasswordTask.Params) {
|
||||
val changePasswordParams = ChangePasswordParams.create(userId, params.password, params.newPassword)
|
||||
try {
|
||||
executeRequest<Unit>(eventBus) {
|
||||
executeRequest<Unit>(globalErrorReceiver) {
|
||||
apiCall = accountAPI.changePassword(changePasswordParams)
|
||||
}
|
||||
} catch (throwable: Throwable) {
|
||||
|
@ -49,7 +49,7 @@ internal class DefaultChangePasswordTask @Inject constructor(
|
|||
/* Avoid infinite loop */
|
||||
&& changePasswordParams.auth?.session == null) {
|
||||
// Retry with authentication
|
||||
executeRequest<Unit>(eventBus) {
|
||||
executeRequest<Unit>(globalErrorReceiver) {
|
||||
apiCall = accountAPI.changePassword(
|
||||
changePasswordParams.copy(auth = changePasswordParams.auth?.copy(session = registrationFlowResponse.session))
|
||||
)
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
package org.matrix.android.sdk.internal.session.account
|
||||
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.session.cleanup.CleanupSession
|
||||
import org.matrix.android.sdk.internal.session.identity.IdentityDisconnectTask
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -34,7 +34,7 @@ internal interface DeactivateAccountTask : Task<DeactivateAccountTask.Params, Un
|
|||
|
||||
internal class DefaultDeactivateAccountTask @Inject constructor(
|
||||
private val accountAPI: AccountAPI,
|
||||
private val eventBus: EventBus,
|
||||
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||
@UserId private val userId: String,
|
||||
private val identityDisconnectTask: IdentityDisconnectTask,
|
||||
private val cleanupSession: CleanupSession
|
||||
|
@ -43,7 +43,7 @@ internal class DefaultDeactivateAccountTask @Inject constructor(
|
|||
override suspend fun execute(params: DeactivateAccountTask.Params) {
|
||||
val deactivateAccountParams = DeactivateAccountParams.create(userId, params.password, params.eraseAllData)
|
||||
|
||||
executeRequest<Unit>(eventBus) {
|
||||
executeRequest<Unit>(globalErrorReceiver) {
|
||||
apiCall = accountAPI.deactivate(deactivateAccountParams)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package org.matrix.android.sdk.internal.session.call
|
||||
|
||||
import org.matrix.android.sdk.api.session.call.TurnServerResponse
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal abstract class GetTurnServerTask : Task<GetTurnServerTask.Params, TurnServerResponse> {
|
||||
|
@ -27,10 +27,10 @@ internal abstract class GetTurnServerTask : Task<GetTurnServerTask.Params, TurnS
|
|||
}
|
||||
|
||||
internal class DefaultGetTurnServerTask @Inject constructor(private val voipAPI: VoipApi,
|
||||
private val eventBus: EventBus) : GetTurnServerTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : GetTurnServerTask() {
|
||||
|
||||
override suspend fun execute(params: Params): TurnServerResponse {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = voipAPI.getTurnServer()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ import okhttp3.RequestBody
|
|||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okio.BufferedSink
|
||||
import okio.source
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
||||
import org.matrix.android.sdk.internal.di.Authenticated
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.ProgressRequestBody
|
||||
import org.matrix.android.sdk.internal.network.awaitResponse
|
||||
import org.matrix.android.sdk.internal.network.toFailure
|
||||
|
@ -45,7 +45,7 @@ import javax.inject.Inject
|
|||
|
||||
internal class FileUploader @Inject constructor(@Authenticated
|
||||
private val okHttpClient: OkHttpClient,
|
||||
private val eventBus: EventBus,
|
||||
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||
private val context: Context,
|
||||
contentUrlResolver: ContentUrlResolver,
|
||||
moshi: Moshi) {
|
||||
|
@ -115,7 +115,7 @@ internal class FileUploader @Inject constructor(@Authenticated
|
|||
|
||||
return okHttpClient.newCall(request).awaitResponse().use { response ->
|
||||
if (!response.isSuccessful) {
|
||||
throw response.toFailure(eventBus)
|
||||
throw response.toFailure(globalErrorReceiver)
|
||||
} else {
|
||||
response.body?.source()?.let {
|
||||
responseAdapter.fromJson(it)
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.session.filter
|
|||
|
||||
import org.matrix.android.sdk.api.session.sync.FilterService
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ internal class DefaultSaveFilterTask @Inject constructor(
|
|||
@UserId private val userId: String,
|
||||
private val filterAPI: FilterApi,
|
||||
private val filterRepository: FilterRepository,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : SaveFilterTask {
|
||||
|
||||
override suspend fun execute(params: SaveFilterTask.Params) {
|
||||
|
@ -59,7 +59,7 @@ internal class DefaultSaveFilterTask @Inject constructor(
|
|||
}
|
||||
val updated = filterRepository.storeFilter(filterBody, roomFilter)
|
||||
if (updated) {
|
||||
val filterResponse = executeRequest<FilterResponse>(eventBus) {
|
||||
val filterResponse = executeRequest<FilterResponse>(globalErrorReceiver) {
|
||||
// TODO auto retry
|
||||
apiCall = filterAPI.uploadFilter(userId, filterBody)
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ import org.matrix.android.sdk.internal.database.model.GroupSummaryEntity
|
|||
import org.matrix.android.sdk.internal.database.query.getOrCreate
|
||||
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.group.model.GroupRooms
|
||||
import org.matrix.android.sdk.internal.session.group.model.GroupSummaryResponse
|
||||
import org.matrix.android.sdk.internal.session.group.model.GroupUsers
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.matrix.android.sdk.internal.util.awaitTransaction
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -43,7 +43,7 @@ internal interface GetGroupDataTask : Task<GetGroupDataTask.Params, Unit> {
|
|||
internal class DefaultGetGroupDataTask @Inject constructor(
|
||||
private val groupAPI: GroupAPI,
|
||||
@SessionDatabase private val monarchy: Monarchy,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetGroupDataTask {
|
||||
|
||||
private data class GroupData(
|
||||
|
@ -64,13 +64,13 @@ internal class DefaultGetGroupDataTask @Inject constructor(
|
|||
}
|
||||
Timber.v("Fetch data for group with ids: ${groupIds.joinToString(";")}")
|
||||
val data = groupIds.map { groupId ->
|
||||
val groupSummary = executeRequest<GroupSummaryResponse>(eventBus) {
|
||||
val groupSummary = executeRequest<GroupSummaryResponse>(globalErrorReceiver) {
|
||||
apiCall = groupAPI.getSummary(groupId)
|
||||
}
|
||||
val groupRooms = executeRequest<GroupRooms>(eventBus) {
|
||||
val groupRooms = executeRequest<GroupRooms>(globalErrorReceiver) {
|
||||
apiCall = groupAPI.getRooms(groupId)
|
||||
}
|
||||
val groupUsers = executeRequest<GroupUsers>(eventBus) {
|
||||
val groupUsers = executeRequest<GroupUsers>(globalErrorReceiver) {
|
||||
apiCall = groupAPI.getUsers(groupId)
|
||||
}
|
||||
GroupData(groupId, groupSummary, groupRooms, groupUsers)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.matrix.android.sdk.internal.session.homeserver
|
||||
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.auth.wellknown.WellknownResult
|
||||
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilities
|
||||
|
@ -27,6 +26,7 @@ import org.matrix.android.sdk.internal.database.model.HomeServerCapabilitiesEnti
|
|||
import org.matrix.android.sdk.internal.database.query.getOrCreate
|
||||
import org.matrix.android.sdk.internal.di.SessionDatabase
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.session.integrationmanager.IntegrationManagerConfigExtractor
|
||||
import org.matrix.android.sdk.internal.session.media.GetMediaConfigResult
|
||||
|
@ -44,7 +44,7 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
|
|||
private val capabilitiesAPI: CapabilitiesAPI,
|
||||
private val mediaAPI: MediaAPI,
|
||||
@SessionDatabase private val monarchy: Monarchy,
|
||||
private val eventBus: EventBus,
|
||||
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||
private val getWellknownTask: GetWellknownTask,
|
||||
private val configExtractor: IntegrationManagerConfigExtractor,
|
||||
private val homeServerConnectionConfig: HomeServerConnectionConfig,
|
||||
|
@ -65,13 +65,13 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
|
|||
}
|
||||
|
||||
val capabilities = runCatching {
|
||||
executeRequest<GetCapabilitiesResult>(eventBus) {
|
||||
executeRequest<GetCapabilitiesResult>(globalErrorReceiver) {
|
||||
apiCall = capabilitiesAPI.getCapabilities()
|
||||
}
|
||||
}.getOrNull()
|
||||
|
||||
val mediaConfig = runCatching {
|
||||
executeRequest<GetMediaConfigResult>(eventBus) {
|
||||
executeRequest<GetMediaConfigResult>(globalErrorReceiver) {
|
||||
apiCall = mediaAPI.getMediaConfig()
|
||||
}
|
||||
}.getOrNull()
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.matrix.android.sdk.internal.session.media
|
||||
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.cache.CacheStrategy
|
||||
import org.matrix.android.sdk.api.session.media.PreviewUrlData
|
||||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
|
@ -25,6 +24,7 @@ import org.matrix.android.sdk.internal.database.model.PreviewUrlCacheEntity
|
|||
import org.matrix.android.sdk.internal.database.query.get
|
||||
import org.matrix.android.sdk.internal.database.query.getOrCreate
|
||||
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.task.Task
|
||||
import org.matrix.android.sdk.internal.util.awaitTransaction
|
||||
|
@ -41,7 +41,7 @@ internal interface GetPreviewUrlTask : Task<GetPreviewUrlTask.Params, PreviewUrl
|
|||
|
||||
internal class DefaultGetPreviewUrlTask @Inject constructor(
|
||||
private val mediaAPI: MediaAPI,
|
||||
private val eventBus: EventBus,
|
||||
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||
@SessionDatabase private val monarchy: Monarchy
|
||||
) : GetPreviewUrlTask {
|
||||
|
||||
|
@ -64,7 +64,7 @@ internal class DefaultGetPreviewUrlTask @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun doRequest(url: String, timestamp: Long?): PreviewUrlData {
|
||||
return executeRequest<JsonDict>(eventBus) {
|
||||
return executeRequest<JsonDict>(globalErrorReceiver) {
|
||||
apiCall = mediaAPI.getPreviewUrlData(url, timestamp)
|
||||
}
|
||||
.toPreviewUrlData(url)
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
package org.matrix.android.sdk.internal.session.media
|
||||
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import javax.inject.Inject
|
||||
|
@ -31,11 +31,11 @@ internal interface GetRawPreviewUrlTask : Task<GetRawPreviewUrlTask.Params, Json
|
|||
|
||||
internal class DefaultGetRawPreviewUrlTask @Inject constructor(
|
||||
private val mediaAPI: MediaAPI,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : GetRawPreviewUrlTask {
|
||||
|
||||
override suspend fun execute(params: GetRawPreviewUrlTask.Params): JsonDict {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = mediaAPI.getPreviewUrlData(params.url, params.timestamp)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package org.matrix.android.sdk.internal.session.openid
|
||||
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface GetOpenIdTokenTask : Task<Unit, RequestOpenIdTokenResponse>
|
||||
|
@ -27,10 +27,10 @@ internal interface GetOpenIdTokenTask : Task<Unit, RequestOpenIdTokenResponse>
|
|||
internal class DefaultGetOpenIdTokenTask @Inject constructor(
|
||||
@UserId private val userId: String,
|
||||
private val openIdAPI: OpenIdAPI,
|
||||
private val eventBus: EventBus) : GetOpenIdTokenTask {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : GetOpenIdTokenTask {
|
||||
|
||||
override suspend fun execute(params: Unit): RequestOpenIdTokenResponse {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = openIdAPI.openIdToken(userId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.session.profile
|
|||
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
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.task.Task
|
||||
import org.matrix.android.sdk.internal.util.awaitTransaction
|
||||
|
@ -37,7 +37,7 @@ internal class DefaultAddThreePidTask @Inject constructor(
|
|||
private val profileAPI: ProfileAPI,
|
||||
@SessionDatabase private val monarchy: Monarchy,
|
||||
private val pendingThreePidMapper: PendingThreePidMapper,
|
||||
private val eventBus: EventBus) : AddThreePidTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : AddThreePidTask() {
|
||||
|
||||
override suspend fun execute(params: Params) {
|
||||
when (params.threePid) {
|
||||
|
@ -50,7 +50,7 @@ internal class DefaultAddThreePidTask @Inject constructor(
|
|||
val clientSecret = UUID.randomUUID().toString()
|
||||
val sendAttempt = 1
|
||||
|
||||
val result = executeRequest<AddEmailResponse>(eventBus) {
|
||||
val result = executeRequest<AddEmailResponse>(globalErrorReceiver) {
|
||||
val body = AddEmailBody(
|
||||
clientSecret = clientSecret,
|
||||
email = threePid.email,
|
||||
|
@ -84,7 +84,7 @@ internal class DefaultAddThreePidTask @Inject constructor(
|
|||
val countryCode = parsedNumber.countryCode
|
||||
val country = phoneNumberUtil.getRegionCodeForCountryCode(countryCode)
|
||||
|
||||
val result = executeRequest<AddMsisdnResponse>(eventBus) {
|
||||
val result = executeRequest<AddMsisdnResponse>(globalErrorReceiver) {
|
||||
val body = AddMsisdnBody(
|
||||
clientSecret = clientSecret,
|
||||
country = country,
|
||||
|
|
|
@ -19,12 +19,12 @@ package org.matrix.android.sdk.internal.session.profile
|
|||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
import org.matrix.android.sdk.internal.di.AuthenticatedIdentity
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.network.token.AccessTokenProvider
|
||||
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
|
||||
import org.matrix.android.sdk.internal.session.identity.data.getIdentityServerUrlWithoutProtocol
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal abstract class BindThreePidsTask : Task<BindThreePidsTask.Params, Unit> {
|
||||
|
@ -37,13 +37,13 @@ internal class DefaultBindThreePidsTask @Inject constructor(private val profileA
|
|||
private val identityStore: IdentityStore,
|
||||
@AuthenticatedIdentity
|
||||
private val accessTokenProvider: AccessTokenProvider,
|
||||
private val eventBus: EventBus) : BindThreePidsTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : BindThreePidsTask() {
|
||||
override suspend fun execute(params: Params) {
|
||||
val identityServerUrlWithoutProtocol = identityStore.getIdentityServerUrlWithoutProtocol() ?: throw IdentityServiceError.NoIdentityServerConfigured
|
||||
val identityServerAccessToken = accessTokenProvider.getToken() ?: throw IdentityServiceError.NoIdentityServerConfigured
|
||||
val identityPendingBinding = identityStore.getPendingBinding(params.threePid) ?: throw IdentityServiceError.NoCurrentBindingError
|
||||
|
||||
executeRequest<Unit>(eventBus) {
|
||||
executeRequest<Unit>(globalErrorReceiver) {
|
||||
apiCall = profileAPI.bindThreePid(
|
||||
BindThreePidBody(
|
||||
clientSecret = identityPendingBinding.clientSecret,
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.matrix.android.sdk.internal.session.profile
|
||||
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
import org.matrix.android.sdk.api.session.identity.toMedium
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import javax.inject.Inject
|
||||
|
@ -31,10 +31,10 @@ internal abstract class DeleteThreePidTask : Task<DeleteThreePidTask.Params, Uni
|
|||
|
||||
internal class DefaultDeleteThreePidTask @Inject constructor(
|
||||
private val profileAPI: ProfileAPI,
|
||||
private val eventBus: EventBus) : DeleteThreePidTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : DeleteThreePidTask() {
|
||||
|
||||
override suspend fun execute(params: Params) {
|
||||
executeRequest<DeleteThreePidResponse>(eventBus) {
|
||||
executeRequest<DeleteThreePidResponse>(globalErrorReceiver) {
|
||||
val body = DeleteThreePidBody(
|
||||
medium = params.threePid.toMedium(),
|
||||
address = params.threePid.value
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.matrix.android.sdk.internal.session.profile
|
||||
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.failure.toRegistrationFlowResponse
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
|
@ -26,6 +25,7 @@ import org.matrix.android.sdk.internal.database.model.PendingThreePidEntity
|
|||
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntityFields
|
||||
import org.matrix.android.sdk.internal.di.SessionDatabase
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.matrix.android.sdk.internal.util.awaitTransaction
|
||||
|
@ -45,7 +45,7 @@ internal class DefaultFinalizeAddingThreePidTask @Inject constructor(
|
|||
@SessionDatabase private val monarchy: Monarchy,
|
||||
private val pendingThreePidMapper: PendingThreePidMapper,
|
||||
@UserId private val userId: String,
|
||||
private val eventBus: EventBus) : FinalizeAddingThreePidTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : FinalizeAddingThreePidTask() {
|
||||
|
||||
override suspend fun execute(params: Params) {
|
||||
if (params.userWantsToCancel.not()) {
|
||||
|
@ -58,7 +58,7 @@ internal class DefaultFinalizeAddingThreePidTask @Inject constructor(
|
|||
?: throw IllegalArgumentException("unknown threepid")
|
||||
|
||||
try {
|
||||
executeRequest<Unit>(eventBus) {
|
||||
executeRequest<Unit>(globalErrorReceiver) {
|
||||
val body = FinalizeAddThreePidBody(
|
||||
clientSecret = pendingThreePids.clientSecret,
|
||||
sid = pendingThreePids.sid,
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
package org.matrix.android.sdk.internal.session.profile
|
||||
|
||||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal abstract class GetProfileInfoTask : Task<GetProfileInfoTask.Params, JsonDict> {
|
||||
|
@ -30,10 +30,10 @@ internal abstract class GetProfileInfoTask : Task<GetProfileInfoTask.Params, Jso
|
|||
}
|
||||
|
||||
internal class DefaultGetProfileInfoTask @Inject constructor(private val profileAPI: ProfileAPI,
|
||||
private val eventBus: EventBus) : GetProfileInfoTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : GetProfileInfoTask() {
|
||||
|
||||
override suspend fun execute(params: Params): JsonDict {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
apiCall = profileAPI.getProfile(params.userId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.session.profile
|
|||
import com.zhuinden.monarchy.Monarchy
|
||||
import org.matrix.android.sdk.internal.database.model.UserThreePidEntity
|
||||
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.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.internal.util.awaitTransaction
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
@ -30,10 +30,10 @@ internal abstract class RefreshUserThreePidsTask : Task<Unit, Unit>
|
|||
|
||||
internal class DefaultRefreshUserThreePidsTask @Inject constructor(private val profileAPI: ProfileAPI,
|
||||
@SessionDatabase private val monarchy: Monarchy,
|
||||
private val eventBus: EventBus) : RefreshUserThreePidsTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : RefreshUserThreePidsTask() {
|
||||
|
||||
override suspend fun execute(params: Unit) {
|
||||
val accountThreePidsResponse = executeRequest<AccountThreePidsResponse>(eventBus) {
|
||||
val accountThreePidsResponse = executeRequest<AccountThreePidsResponse>(globalErrorReceiver) {
|
||||
apiCall = profileAPI.getThreePIDs()
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.matrix.android.sdk.internal.session.profile
|
||||
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal abstract class SetAvatarUrlTask : Task<SetAvatarUrlTask.Params, Unit> {
|
||||
|
@ -30,10 +30,10 @@ internal abstract class SetAvatarUrlTask : Task<SetAvatarUrlTask.Params, Unit> {
|
|||
|
||||
internal class DefaultSetAvatarUrlTask @Inject constructor(
|
||||
private val profileAPI: ProfileAPI,
|
||||
private val eventBus: EventBus) : SetAvatarUrlTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : SetAvatarUrlTask() {
|
||||
|
||||
override suspend fun execute(params: Params) {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
val body = SetAvatarUrlBody(
|
||||
avatarUrl = params.newAvatarUrl
|
||||
)
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.matrix.android.sdk.internal.session.profile
|
||||
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal abstract class SetDisplayNameTask : Task<SetDisplayNameTask.Params, Unit> {
|
||||
|
@ -30,10 +30,10 @@ internal abstract class SetDisplayNameTask : Task<SetDisplayNameTask.Params, Uni
|
|||
|
||||
internal class DefaultSetDisplayNameTask @Inject constructor(
|
||||
private val profileAPI: ProfileAPI,
|
||||
private val eventBus: EventBus) : SetDisplayNameTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : SetDisplayNameTask() {
|
||||
|
||||
override suspend fun execute(params: Params) {
|
||||
return executeRequest(eventBus) {
|
||||
return executeRequest(globalErrorReceiver) {
|
||||
val body = SetDisplayNameBody(
|
||||
displayName = params.newDisplayName
|
||||
)
|
||||
|
|
|
@ -19,11 +19,11 @@ package org.matrix.android.sdk.internal.session.profile
|
|||
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.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
|
||||
import org.matrix.android.sdk.internal.session.identity.data.getIdentityServerUrlWithoutProtocol
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal abstract class UnbindThreePidsTask : Task<UnbindThreePidsTask.Params, Boolean> {
|
||||
|
@ -34,12 +34,12 @@ internal abstract class UnbindThreePidsTask : Task<UnbindThreePidsTask.Params, B
|
|||
|
||||
internal class DefaultUnbindThreePidsTask @Inject constructor(private val profileAPI: ProfileAPI,
|
||||
private val identityStore: IdentityStore,
|
||||
private val eventBus: EventBus) : UnbindThreePidsTask() {
|
||||
private val globalErrorReceiver: GlobalErrorReceiver) : UnbindThreePidsTask() {
|
||||
override suspend fun execute(params: Params): Boolean {
|
||||
val identityServerUrlWithoutProtocol = identityStore.getIdentityServerUrlWithoutProtocol()
|
||||
?: throw IdentityServiceError.NoIdentityServerConfigured
|
||||
|
||||
return executeRequest<UnbindThreePidResponse>(eventBus) {
|
||||
return executeRequest<UnbindThreePidResponse>(globalErrorReceiver) {
|
||||
apiCall = profileAPI.unbindThreePid(
|
||||
UnbindThreePidBody(
|
||||
identityServerUrlWithoutProtocol,
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
package org.matrix.android.sdk.internal.session.profile
|
||||
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
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
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import javax.inject.Inject
|
||||
|
@ -40,7 +40,7 @@ internal class DefaultValidateSmsCodeTask @Inject constructor(
|
|||
@SessionDatabase
|
||||
private val monarchy: Monarchy,
|
||||
private val pendingThreePidMapper: PendingThreePidMapper,
|
||||
private val eventBus: EventBus
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
) : ValidateSmsCodeTask {
|
||||
|
||||
override suspend fun execute(params: ValidateSmsCodeTask.Params) {
|
||||
|
@ -58,7 +58,7 @@ internal class DefaultValidateSmsCodeTask @Inject constructor(
|
|||
sid = pendingThreePids.sid,
|
||||
code = params.code
|
||||
)
|
||||
val result = executeRequest<SuccessResult>(eventBus) {
|
||||
val result = executeRequest<SuccessResult>(globalErrorReceiver) {
|
||||
apiCall = profileAPI.validateMsisdn(url, body)
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue