mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 04:29:45 +01:00
Fix user migration step
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
5945700ffb
commit
d5cf261776
@ -3,6 +3,8 @@
|
|||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/Projects-talk-android.iml" filepath="$PROJECT_DIR$/Projects-talk-android.iml" />
|
<module fileurl="file://$PROJECT_DIR$/Projects-talk-android.iml" filepath="$PROJECT_DIR$/Projects-talk-android.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/talk-android.iml" filepath="$PROJECT_DIR$/talk-android.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/app/talk-android-app.iml" filepath="$PROJECT_DIR$/app/talk-android-app.iml" />
|
<module fileurl="file://$PROJECT_DIR$/app/talk-android-app.iml" filepath="$PROJECT_DIR$/app/talk-android-app.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
@ -63,6 +63,7 @@ import com.nextcloud.talk.newarch.local.dao.UsersDao
|
|||||||
import com.nextcloud.talk.newarch.local.models.UserNgEntity
|
import com.nextcloud.talk.newarch.local.models.UserNgEntity
|
||||||
import com.nextcloud.talk.newarch.local.models.other.UserStatus.ACTIVE
|
import com.nextcloud.talk.newarch.local.models.other.UserStatus.ACTIVE
|
||||||
import com.nextcloud.talk.newarch.local.models.other.UserStatus.DORMANT
|
import com.nextcloud.talk.newarch.local.models.other.UserStatus.DORMANT
|
||||||
|
import com.nextcloud.talk.newarch.local.models.other.UserStatus.PENDING_DELETE
|
||||||
import com.nextcloud.talk.utils.ClosedInterfaceImpl
|
import com.nextcloud.talk.utils.ClosedInterfaceImpl
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
import com.nextcloud.talk.utils.OkHttpNetworkFetcherWithCache
|
import com.nextcloud.talk.utils.OkHttpNetworkFetcherWithCache
|
||||||
@ -241,38 +242,47 @@ class NextcloudTalkApplication : Application(), LifecycleObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun migrateUsers() {
|
fun migrateUsers() {
|
||||||
GlobalScope.launch {
|
if (!appPreferences.migrationToRoomFinished) {
|
||||||
val users: List<UserEntity> = userUtils.users as List<UserEntity>
|
GlobalScope.launch {
|
||||||
var userNg: UserNgEntity
|
val users: List<UserEntity> = userUtils.users as List<UserEntity>
|
||||||
val newUsers = mutableListOf<UserNgEntity>()
|
var userNg: UserNgEntity
|
||||||
for (user in users) {
|
val newUsers = mutableListOf<UserNgEntity>()
|
||||||
userNg = UserNgEntity(user.id, user.userId, user.username, user.baseUrl)
|
for (user in users) {
|
||||||
userNg.token = user.token
|
userNg = UserNgEntity(user.id, user.userId, user.username, user.baseUrl)
|
||||||
userNg.displayName = user.displayName
|
userNg.token = user.token
|
||||||
try {
|
userNg.displayName = user.displayName
|
||||||
userNg.pushConfiguration =
|
try {
|
||||||
LoganSquare.parse(user.pushConfigurationState, PushConfigurationState::class.java)
|
userNg.pushConfiguration =
|
||||||
} catch (e: Exception) {
|
LoganSquare.parse(user.pushConfigurationState, PushConfigurationState::class.java)
|
||||||
// no push
|
} catch (e: Exception) {
|
||||||
|
// no push
|
||||||
|
}
|
||||||
|
if (user.capabilities != null) {
|
||||||
|
userNg.capabilities = LoganSquare.parse(user.capabilities, Capabilities::class.java)
|
||||||
|
}
|
||||||
|
userNg.clientCertificate = user.clientCertificate
|
||||||
|
try {
|
||||||
|
userNg.externalSignaling =
|
||||||
|
LoganSquare.parse(user.externalSignalingServer, ExternalSignalingServer::class.java)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// no external signaling
|
||||||
|
}
|
||||||
|
if (user.current) {
|
||||||
|
userNg.status = ACTIVE
|
||||||
|
} else {
|
||||||
|
if (user.scheduledForDeletion) {
|
||||||
|
userNg.status = PENDING_DELETE
|
||||||
|
} else {
|
||||||
|
userNg.status = DORMANT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
newUsers.add(userNg)
|
||||||
}
|
}
|
||||||
if (user.capabilities != null) {
|
usersDao.saveUsers(*newUsers.toTypedArray())
|
||||||
userNg.capabilities = LoganSquare.parse(user.capabilities, Capabilities::class.java)
|
appPreferences.migrationToRoomFinished = true
|
||||||
}
|
|
||||||
userNg.clientCertificate = user.clientCertificate
|
|
||||||
try {
|
|
||||||
userNg.externalSignaling =
|
|
||||||
LoganSquare.parse(user.externalSignalingServer, ExternalSignalingServer::class.java)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
// no external signaling
|
|
||||||
}
|
|
||||||
if (user.current) {
|
|
||||||
userNg.status = ACTIVE
|
|
||||||
} else {
|
|
||||||
userNg.status = DORMANT
|
|
||||||
}
|
|
||||||
newUsers.add(userNg)
|
|
||||||
}
|
}
|
||||||
usersDao.saveUsers(*newUsers.toTypedArray())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ import com.nextcloud.talk.newarch.local.models.other.UserStatus
|
|||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
import kotlinx.android.parcel.RawValue
|
import kotlinx.android.parcel.RawValue
|
||||||
import kotlinx.android.parcel.WriteWith
|
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@Entity(tableName = "users")
|
@Entity(tableName = "users")
|
||||||
|
@ -287,6 +287,17 @@ public interface AppPreferences {
|
|||||||
@UnregisterChangeListenerMethod
|
@UnregisterChangeListenerMethod
|
||||||
void unregisterThemeChangeListener(OnPreferenceValueChangedListener<String> listener);
|
void unregisterThemeChangeListener(OnPreferenceValueChangedListener<String> listener);
|
||||||
|
|
||||||
|
@KeyByString("migration_to_room")
|
||||||
|
@DefaultValue(R.bool.value_false)
|
||||||
|
boolean getMigrationToRoomFinished();
|
||||||
|
|
||||||
|
@KeyByString("migration_to_room")
|
||||||
|
void setMigrationToRoomFinished(boolean value);
|
||||||
|
|
||||||
|
@KeyByString("migration_to_room")
|
||||||
|
@RemoveMethod
|
||||||
|
void removeMigrationToRoomFinished();
|
||||||
|
|
||||||
@ClearMethod
|
@ClearMethod
|
||||||
void clear();
|
void clear();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user