Skip to content

Commit

Permalink
Merge pull request #37 from appwrite/dev
Browse files Browse the repository at this point in the history
fix: for appwrite 1.4.x
  • Loading branch information
abnegate committed Sep 1, 2023
2 parents 618eb55 + a0ded72 commit a8bf4d5
Show file tree
Hide file tree
Showing 11 changed files with 340 additions and 297 deletions.
4 changes: 2 additions & 2 deletions README.md
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
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
@@ -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"
}
}

0 comments on commit a8bf4d5

Please sign in to comment.