mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2649 Protocol | Enhancement | 0.35.0-rc5 (#1372)
This commit is contained in:
parent
b2dd0265b6
commit
26ae59d803
21 changed files with 143 additions and 146 deletions
|
@ -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?
|
||||
)
|
||||
@JvmInline
|
||||
value class Account(val id: Id)
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
|
@ -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)
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
|
@ -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
|
||||
)
|
|
@ -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?
|
||||
)
|
|
@ -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
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
|
@ -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,
|
||||
)
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue