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,7 +3,9 @@
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<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" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
@ -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.other.UserStatus.ACTIVE
|
||||
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.DisplayUtils
|
||||
import com.nextcloud.talk.utils.OkHttpNetworkFetcherWithCache
|
||||
@ -241,38 +242,47 @@ class NextcloudTalkApplication : Application(), LifecycleObserver {
|
||||
}
|
||||
|
||||
fun migrateUsers() {
|
||||
GlobalScope.launch {
|
||||
val users: List<UserEntity> = userUtils.users as List<UserEntity>
|
||||
var userNg: UserNgEntity
|
||||
val newUsers = mutableListOf<UserNgEntity>()
|
||||
for (user in users) {
|
||||
userNg = UserNgEntity(user.id, user.userId, user.username, user.baseUrl)
|
||||
userNg.token = user.token
|
||||
userNg.displayName = user.displayName
|
||||
try {
|
||||
userNg.pushConfiguration =
|
||||
LoganSquare.parse(user.pushConfigurationState, PushConfigurationState::class.java)
|
||||
} catch (e: Exception) {
|
||||
// no push
|
||||
if (!appPreferences.migrationToRoomFinished) {
|
||||
GlobalScope.launch {
|
||||
val users: List<UserEntity> = userUtils.users as List<UserEntity>
|
||||
var userNg: UserNgEntity
|
||||
val newUsers = mutableListOf<UserNgEntity>()
|
||||
for (user in users) {
|
||||
userNg = UserNgEntity(user.id, user.userId, user.username, user.baseUrl)
|
||||
userNg.token = user.token
|
||||
userNg.displayName = user.displayName
|
||||
try {
|
||||
userNg.pushConfiguration =
|
||||
LoganSquare.parse(user.pushConfigurationState, PushConfigurationState::class.java)
|
||||
} 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) {
|
||||
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 {
|
||||
userNg.status = DORMANT
|
||||
}
|
||||
newUsers.add(userNg)
|
||||
usersDao.saveUsers(*newUsers.toTypedArray())
|
||||
appPreferences.migrationToRoomFinished = true
|
||||
}
|
||||
usersDao.saveUsers(*newUsers.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import com.nextcloud.talk.newarch.local.models.other.UserStatus
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import kotlinx.android.parcel.RawValue
|
||||
import kotlinx.android.parcel.WriteWith
|
||||
|
||||
@Parcelize
|
||||
@Entity(tableName = "users")
|
||||
|
@ -287,6 +287,17 @@ public interface AppPreferences {
|
||||
@UnregisterChangeListenerMethod
|
||||
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
|
||||
void clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user