Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: for appwrite 1.4.x #37

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:

```groovy
implementation("io.appwrite:sdk-for-android:3.0.0")
implementation("io.appwrite:sdk-for-android:3.0.1")
```

### Maven
Expand All @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-android</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
</dependency>
</dependencies>
```
Expand Down
8 changes: 4 additions & 4 deletions library/src/main/java/io/appwrite/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Client @JvmOverloads constructor(
"x-sdk-name" to "Android",
"x-sdk-platform" to "client",
"x-sdk-language" to "android",
"x-sdk-version" to "3.0.0",
"x-sdk-version" to "3.0.1",
"x-appwrite-response-format" to "1.4.0"
)
config = mutableMapOf()
Expand Down Expand Up @@ -394,7 +394,7 @@ class Client @JvmOverloads constructor(
responseType = Map::class.java,
)
val chunksUploaded = current["chunksUploaded"] as Long
offset = (chunksUploaded * CHUNK_SIZE).coerceAtMost(size)
offset = chunksUploaded * CHUNK_SIZE
}

while (offset < size) {
Expand All @@ -405,7 +405,7 @@ class Client @JvmOverloads constructor(
}
"bytes" -> {
val end = if (offset + CHUNK_SIZE < size) {
offset + CHUNK_SIZE
offset + CHUNK_SIZE - 1
} else {
size - 1
}
Expand All @@ -425,7 +425,7 @@ class Client @JvmOverloads constructor(
)

headers["Content-Range"] =
"bytes $offset-${((offset + CHUNK_SIZE) - 1).coerceAtMost(size)}/$size"
"bytes $offset-${((offset + CHUNK_SIZE) - 1).coerceAtMost(size - 1)}/$size"

result = call(
method = "POST",
Expand Down
43 changes: 43 additions & 0 deletions library/src/main/java/io/appwrite/Role.kt
Original file line number Diff line number Diff line change
@@ -1,29 +1,72 @@
package io.appwrite

/**
* Helper class to generate role strings for [Permission].
*/
class Role {
companion object {

/**
* Grants access to anyone.
*
* This includes authenticated and unauthenticated users.
*/
fun any(): String = "any"

/**
* Grants access to a specific user by user ID.
*
* You can optionally pass verified or unverified for
* [status] to target specific types of users.
*/
fun user(id: String, status: String = ""): String = if(status.isEmpty()) {
"user:$id"
} else {
"user:$id/$status"
}

/**
* Grants access to any authenticated or anonymous user.
*
* You can optionally pass verified or unverified for
* [status] to target specific types of users.
*/
fun users(status: String = ""): String = if(status.isEmpty()) {
"users"
} else {
"users/$status"
}

/**
* Grants access to any guest user without a session.
*
* Authenticated users don't have access to this role.
*/
fun guests(): String = "guests"

/**
* Grants access to a team by team ID.
*
* You can optionally pass a role for [role] to target
* team members with the specified role.
*/
fun team(id: String, role: String = ""): String = if(role.isEmpty()) {
"team:$id"
} else {
"team:$id/$role"
}

/**
* Grants access to a specific member of a team.
*
* When the member is removed from the team, they will
* no longer have access.
*/
fun member(id: String): String = "member:$id"

/**
* Grants access to a user with the specified label.
*/
fun label(name: String): String = "label:$name"
}
}
Loading