diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Account.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Account.kt index 6f2f17c297..e0714b3f60 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Account.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Account.kt @@ -2,14 +2,6 @@ package com.anytypeio.anytype.core_models /** * User account. - * @property id account's id - * @property name account's name - * @property avatar optional avatar url - * @property color optional color (for avatar placeholder) */ -data class Account( - val id: String, - val name: String, - val avatar: Url?, - val color: String? -) \ No newline at end of file +@JvmInline +value class Account(val id: Id) \ No newline at end of file diff --git a/data/src/main/java/com/anytypeio/anytype/data/auth/mapper/MapperExtension.kt b/data/src/main/java/com/anytypeio/anytype/data/auth/mapper/MapperExtension.kt index 26167e45a7..9467598211 100644 --- a/data/src/main/java/com/anytypeio/anytype/data/auth/mapper/MapperExtension.kt +++ b/data/src/main/java/com/anytypeio/anytype/data/auth/mapper/MapperExtension.kt @@ -7,18 +7,13 @@ import com.anytypeio.anytype.domain.auth.model.Wallet fun AccountEntity.toDomain(): Account { return Account( - id = id, - name = name, - color = color, - avatar = null + id = id ) } fun Account.toEntity(): AccountEntity { return AccountEntity( - id = id, - name = name, - color = color + id = id ) } diff --git a/data/src/main/java/com/anytypeio/anytype/data/auth/model/AccountEntity.kt b/data/src/main/java/com/anytypeio/anytype/data/auth/model/AccountEntity.kt index 1420c7f5e1..e5db9813af 100644 --- a/data/src/main/java/com/anytypeio/anytype/data/auth/model/AccountEntity.kt +++ b/data/src/main/java/com/anytypeio/anytype/data/auth/model/AccountEntity.kt @@ -1,7 +1,5 @@ package com.anytypeio.anytype.data.auth.model data class AccountEntity( - val id: String, - val name: String, - val color: String? + val id: String ) \ No newline at end of file diff --git a/data/src/test/java/com/anytypeio/anytype/data/AuthDataRepositoryTest.kt b/data/src/test/java/com/anytypeio/anytype/data/AuthDataRepositoryTest.kt index cd27e81dcd..798749ef51 100644 --- a/data/src/test/java/com/anytypeio/anytype/data/AuthDataRepositoryTest.kt +++ b/data/src/test/java/com/anytypeio/anytype/data/AuthDataRepositoryTest.kt @@ -191,9 +191,7 @@ class AuthDataRepositoryTest { fun `should call only cache in order to get current account`() = runBlocking { val account = AccountEntity( - id = MockDataFactory.randomUuid(), - name = MockDataFactory.randomString(), - color = null + id = MockDataFactory.randomUuid() ) authCache.stub { @@ -275,9 +273,7 @@ class AuthDataRepositoryTest { fun `should call only cache in order to get available accounts`() = runBlocking { val account = AccountEntity( - id = MockDataFactory.randomUuid(), - name = MockDataFactory.randomString(), - color = null + id = MockDataFactory.randomUuid() ) val accounts = listOf(account) diff --git a/data/src/test/java/com/anytypeio/anytype/data/MapperExtensionTest.kt b/data/src/test/java/com/anytypeio/anytype/data/MapperExtensionTest.kt index 3388a34038..97a0e69c3a 100644 --- a/data/src/test/java/com/anytypeio/anytype/data/MapperExtensionTest.kt +++ b/data/src/test/java/com/anytypeio/anytype/data/MapperExtensionTest.kt @@ -27,16 +27,11 @@ class MapperExtensionTest { fun `should map correctly account from domain to data layer`() { val account = Account( - id = MockDataFactory.randomUuid(), - name = MockDataFactory.randomString(), - color = MockDataFactory.randomString(), - avatar = MockDataFactory.randomString() + id = MockDataFactory.randomUuid() ) account.toEntity().let { result -> assertTrue { result.id == account.id } - assertTrue { result.name == account.name } - assertTrue { result.color == account.color } } } @@ -44,16 +39,11 @@ class MapperExtensionTest { fun `should map correctly account from data to domain layer`() { val account = AccountEntity( - id = MockDataFactory.randomUuid(), - name = MockDataFactory.randomString(), - color = MockDataFactory.randomString() + id = MockDataFactory.randomUuid() ) account.toDomain().let { result -> assertTrue { result.id == account.id } - assertTrue { result.name == account.name } - assertTrue { result.avatar == null } - assertTrue { result.color == account.color } } } } \ No newline at end of file diff --git a/domain/src/test/java/com/anytypeio/anytype/domain/auth/CheckAuthorizationStatusTest.kt b/domain/src/test/java/com/anytypeio/anytype/domain/auth/CheckAuthorizationStatusTest.kt index 6659392f08..7f397e9beb 100644 --- a/domain/src/test/java/com/anytypeio/anytype/domain/auth/CheckAuthorizationStatusTest.kt +++ b/domain/src/test/java/com/anytypeio/anytype/domain/auth/CheckAuthorizationStatusTest.kt @@ -57,10 +57,7 @@ class CheckAuthorizationStatusTest { fun `should return authorized status if account list is not empty`() = runBlocking { val account = Account( - name = MockDataFactory.randomString(), - id = MockDataFactory.randomString(), - avatar = null, - color = null + id = MockDataFactory.randomString() ) repo.stub { diff --git a/domain/src/test/java/com/anytypeio/anytype/domain/auth/ObserveAccountsTest.kt b/domain/src/test/java/com/anytypeio/anytype/domain/auth/ObserveAccountsTest.kt index 79ea2ebea6..d5fb6a51aa 100644 --- a/domain/src/test/java/com/anytypeio/anytype/domain/auth/ObserveAccountsTest.kt +++ b/domain/src/test/java/com/anytypeio/anytype/domain/auth/ObserveAccountsTest.kt @@ -41,10 +41,7 @@ class ObserveAccountsTest { fun `should collect one account when stream is called`() = runBlocking { val account = Account( - id = MockDataFactory.randomUuid(), - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = MockDataFactory.randomUuid() ) repo.stub { @@ -62,16 +59,10 @@ class ObserveAccountsTest { val accounts = listOf( Account( - id = MockDataFactory.randomUuid(), - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = MockDataFactory.randomUuid() ), Account( - id = MockDataFactory.randomUuid(), - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = MockDataFactory.randomUuid() ) ) diff --git a/domain/src/test/java/com/anytypeio/anytype/domain/auth/StartAccountTest.kt b/domain/src/test/java/com/anytypeio/anytype/domain/auth/StartAccountTest.kt index 6676588c4a..7ae34c2a8b 100644 --- a/domain/src/test/java/com/anytypeio/anytype/domain/auth/StartAccountTest.kt +++ b/domain/src/test/java/com/anytypeio/anytype/domain/auth/StartAccountTest.kt @@ -81,10 +81,7 @@ class StartAccountTest { ) val account = Account( - id = id, - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = id ) repo.stub { @@ -152,10 +149,7 @@ class StartAccountTest { ) val account = Account( - id = id, - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = id ) repo.stub { @@ -199,10 +193,7 @@ class StartAccountTest { ) val account = Account( - id = id, - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = id ) repo.stub { @@ -246,10 +237,7 @@ class StartAccountTest { ) val account = Account( - id = id, - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = id ) repo.stub { @@ -293,10 +281,7 @@ class StartAccountTest { ) val account = Account( - id = id, - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = id ) repo.stub { @@ -340,10 +325,7 @@ class StartAccountTest { ) val account = Account( - id = id, - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = id ) val storedFilePath = MockDataFactory.randomString() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ec47169166..6acdd6435c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -middlewareVersion = "v0.35.0-rc2" +middlewareVersion = "v0.35.0-rc5" kotlinVersion = '2.0.0' kspVersion = "2.0.0-1.0.22" diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/auth/AuthMappers.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/auth/AuthMappers.kt index 0c4e48f13d..a589957a8b 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/auth/AuthMappers.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/auth/AuthMappers.kt @@ -17,10 +17,7 @@ fun Rpc.Account.Create.Response.toAccountSetup() : AccountSetup { return AccountSetup( account = Account( - id = acc.id, - name = acc.name, - color = acc.avatar?.color, - avatar = null + id = acc.id ), config = info.config(), status = status?.core() ?: AccountStatus.Unknown @@ -36,10 +33,7 @@ fun Rpc.Account.Select.Response.toAccountSetup(): AccountSetup { return AccountSetup( account = Account( - id = acc.id, - name = acc.name, - color = acc.avatar?.color, - avatar = null + id = acc.id ), config = Config( home = info.homeObjectId, diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/converters/MapperExtension.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/converters/MapperExtension.kt index f514d33bbf..280113ed8d 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/converters/MapperExtension.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/converters/MapperExtension.kt @@ -7,8 +7,6 @@ fun Event.Account.Show.toAccountEntity(): AccountEntity { val acc = account checkNotNull(acc) return AccountEntity( - id = acc.id, - name = acc.name, - color = acc.avatar?.color + id = acc.id ) } \ No newline at end of file diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/model/CreateAccountResponse.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/model/CreateAccountResponse.kt deleted file mode 100644 index 1eae9ca47f..0000000000 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/model/CreateAccountResponse.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.anytypeio.anytype.middleware.model - -import anytype.model.Account.Avatar - -class CreateAccountResponse( - val id: String, - val name: String, - val avatar: Avatar? = null -) \ No newline at end of file diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/model/SelectAccountResponse.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/model/SelectAccountResponse.kt deleted file mode 100644 index 0e0d8dd3f8..0000000000 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/model/SelectAccountResponse.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.anytypeio.anytype.middleware.model - -import anytype.model.Account -import com.anytypeio.anytype.core_models.AccountStatus - - -class SelectAccountResponse( - val id: String, - val name: String, - val avatar: Account.Avatar?, - val enableDataView: Boolean?, - val enableDebug: Boolean?, - val enableChannelSwitch: Boolean?, - val enableSpaces: Boolean?, - val accountStatus: AccountStatus? -) \ No newline at end of file diff --git a/payments/src/test/java/com/anytypeio/anytype/payments/MembershipTestsSetup.kt b/payments/src/test/java/com/anytypeio/anytype/payments/MembershipTestsSetup.kt index fa386f9b65..c515dabd95 100644 --- a/payments/src/test/java/com/anytypeio/anytype/payments/MembershipTestsSetup.kt +++ b/payments/src/test/java/com/anytypeio/anytype/payments/MembershipTestsSetup.kt @@ -177,10 +177,7 @@ open class MembershipTestsSetup { getAccount.stub { onBlocking { async(Unit) } doReturn Resultat.success( Account( - id = accountId, - name = MockDataFactory.randomString(), - avatar = null, - color = null + id = accountId ) ) } diff --git a/persistence/src/main/java/com/anytypeio/anytype/persistence/mapper/MapperExtension.kt b/persistence/src/main/java/com/anytypeio/anytype/persistence/mapper/MapperExtension.kt index 752bdea21d..407b522f39 100644 --- a/persistence/src/main/java/com/anytypeio/anytype/persistence/mapper/MapperExtension.kt +++ b/persistence/src/main/java/com/anytypeio/anytype/persistence/mapper/MapperExtension.kt @@ -5,16 +5,15 @@ import com.anytypeio.anytype.persistence.model.AccountTable fun AccountTable.toEntity(): AccountEntity { return AccountEntity( - id = id, - name = name, - color = color + id = id ) } fun AccountEntity.toTable(): AccountTable { return AccountTable( id = id, - name = name, - timestamp = System.currentTimeMillis() + timestamp = System.currentTimeMillis(), + name = "", + color = null ) } \ No newline at end of file diff --git a/persistence/src/main/java/com/anytypeio/anytype/persistence/model/AccountTable.kt b/persistence/src/main/java/com/anytypeio/anytype/persistence/model/AccountTable.kt index 6c1e8aff43..bc5b87539f 100644 --- a/persistence/src/main/java/com/anytypeio/anytype/persistence/model/AccountTable.kt +++ b/persistence/src/main/java/com/anytypeio/anytype/persistence/model/AccountTable.kt @@ -7,7 +7,9 @@ import com.anytypeio.anytype.persistence.common.Config @Entity(tableName = Config.ACCOUNT_TABLE_NAME) data class AccountTable( @PrimaryKey val id: String, - val name: String, val timestamp: Long, - val color: String? = null + @Deprecated("Should not be used") + val color: String? = null, + @Deprecated("Should not be used") + val name: String, ) \ No newline at end of file diff --git a/protocol/src/main/proto/changes.proto b/protocol/src/main/proto/changes.proto index bb7fa32283..784325be76 100644 --- a/protocol/src/main/proto/changes.proto +++ b/protocol/src/main/proto/changes.proto @@ -62,6 +62,9 @@ message Change { SetFileInfo setFileInfo = 111; NotificationCreate notificationCreate = 112; NotificationUpdate notificationUpdate = 113; + + DeviceAdd deviceAdd = 114; + DeviceUpdate deviceUpdate = 115; } reserved 102,103,104; // old unsupported relation changes } @@ -167,4 +170,13 @@ message Change { string id = 1; anytype.model.Notification.Status status = 2; } + + message DeviceAdd { + anytype.model.DeviceInfo device = 1; + } + + message DeviceUpdate { + string id = 1; + string name = 2; + } } diff --git a/protocol/src/main/proto/commands.proto b/protocol/src/main/proto/commands.proto index 5ca95faae0..52a286abb0 100644 --- a/protocol/src/main/proto/commands.proto +++ b/protocol/src/main/proto/commands.proto @@ -4118,6 +4118,7 @@ message Rpc { repeated string blockIds = 2; string objectTypeUniqueKey = 3; string templateId = 4; + anytype.model.Block block = 5; } message Response { @@ -7139,6 +7140,69 @@ message Rpc { } } } + + message Device { + message SetName { + message Request { + string deviceId = 1; + string name = 2; + } + message Response { + Error error = 1; + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message List { + message Request {} + message Response { + Error error = 1; + repeated anytype.model.DeviceInfo devices = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + message NetworkState { + message Set { + message Request { + anytype.model.DeviceNetworkType deviceNetworkType = 1; + } + message Response { + Error error = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + INTERNAL_ERROR = 3; + } + } + } + } + } + } } diff --git a/protocol/src/main/proto/events.proto b/protocol/src/main/proto/events.proto index 6114189115..e38efccce6 100644 --- a/protocol/src/main/proto/events.proto +++ b/protocol/src/main/proto/events.proto @@ -106,6 +106,8 @@ message Event { Membership.Update membershipUpdate = 117; Space.SyncStatus.Update spaceSyncStatusUpdate = 119; + + P2PStatus.Update p2pStatusUpdate = 120; } } @@ -1097,6 +1099,19 @@ message Event { NetworkError = 3; } } + message P2PStatus { + message Update { + string spaceId = 1; + Status status = 2; + int64 devicesCounter = 3; + } + + enum Status { + NotConnected = 0; + NotPossible = 1; + Connected = 2; + } + } } message ResponseEvent { diff --git a/protocol/src/main/proto/models.proto b/protocol/src/main/proto/models.proto index 83100e325d..272e2daf1e 100644 --- a/protocol/src/main/proto/models.proto +++ b/protocol/src/main/proto/models.proto @@ -50,6 +50,7 @@ enum SmartBlockType { FileObject = 0x215; NotificationObject = 0x217; + DevicesObject = 0x218; } message Search { @@ -595,21 +596,10 @@ message Range { */ message Account { string id = 1; // User's thread id - string name = 2; // User name, that associated with this account - Avatar avatar = 3; // Avatar of a user's account Config config = 4; Status status = 5; Info info = 6; - /** - * Avatar of a user's account. It could be an image or color - */ - message Avatar { - oneof avatar { - Block.Content.File image = 1; // Image of the avatar. Contains the hash to retrieve the image. - string color = 2; // Color of the avatar, used if image not set. - } - } message Config { bool enableDataview = 1; bool enableDebug = 2; @@ -1200,7 +1190,7 @@ enum NameserviceNameType { } -message Membership { +message Membership { enum Status { StatusUnknown = 0; // please wait a bit more, we are still processing your request @@ -1217,7 +1207,7 @@ message Membership { // in this case please call Finalize to finish the process StatusPendingRequiresFinalization = 3; } - + enum PaymentMethod { MethodNone = 0; MethodStripe = 1; @@ -1259,7 +1249,7 @@ message MembershipTierData { PeriodTypeDays = 2; PeriodTypeWeeks = 3; PeriodTypeMonths = 4; - PeriodTypeYears = 5; + PeriodTypeYears = 5; } // this is a unique Payment Node ID of the tier @@ -1270,14 +1260,14 @@ message MembershipTierData { // just a short technical description string description = 3; // is this tier for testing and debugging only? - bool isTest = 4; + bool isTest = 4; // how long is the period of the subscription PeriodType periodType = 5; // i.e. "5 days" or "3 years" uint32 periodValue = 6; // this one is a price we use ONLY on Stripe platform uint32 priceStripeUsdCents = 7; - // number of ANY NS names that this tier includes + // number of ANY NS names that this tier includes // also in the "features" list (see below) uint32 anyNamesCountIncluded = 8; // somename.any - is of len 8 @@ -1299,8 +1289,21 @@ message MembershipTierData { string androidProductId = 17; string androidManageUrl = 18; } +enum DeviceNetworkType { + WIFI = 0; + CELLULAR = 1; + NOT_CONNECTED = 2; +} message Detail { string key = 1; google.protobuf.Value value = 2; // NUll - removes key +} + +message DeviceInfo { + string id = 1; + string name = 2; + int64 addDate = 3; + bool archived = 4; + bool isConnected = 5; } \ No newline at end of file diff --git a/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Auth.kt b/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Auth.kt index 08a85f2e36..a4df69db4b 100644 --- a/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Auth.kt +++ b/test/core-models-stub/src/main/java/com/anytypeio/anytype/core_models/Auth.kt @@ -18,10 +18,7 @@ fun StubAccount( avatar: Url? = null, color: String? = null ) : Account = Account( - id = id, - name = name, - avatar = avatar, - color = color + id = id ) fun StubConfig(