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: patch updates for appwrite 1.4.1 #16

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
2 changes: 1 addition & 1 deletion appwrite.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |spec|

spec.name = 'appwrite'
spec.version = '9.0.0'
spec.version = '9.0.1'
spec.license = 'BSD-3-Clause'
spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API'
spec.author = 'Appwrite Team'
Expand Down
6 changes: 3 additions & 3 deletions lib/appwrite/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize
'x-sdk-name'=> 'Ruby',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'ruby',
'x-sdk-version'=> '9.0.0',
'x-sdk-version'=> '9.0.1',
'X-Appwrite-Response-Format' => '1.4.0'
}
@endpoint = 'https://HOSTNAME/v1'
Expand Down Expand Up @@ -170,7 +170,7 @@ def chunked_upload(
params: {}
)
chunks_uploaded = current['chunksUploaded'].to_i
offset = [size, (chunks_uploaded * @chunk_size)].min
offset = chunks_uploaded * @chunk_size
end

while offset < size
Expand All @@ -187,7 +187,7 @@ def chunked_upload(
mime_type: input_file.mime_type
)

headers['content-range'] = "bytes #{offset}-#{[offset + @chunk_size - 1, size].min}/#{size}"
headers['content-range'] = "bytes #{offset}-#{[offset + @chunk_size - 1, size - 1].min}/#{size}"

result = call(
method: 'POST',
Expand Down
56 changes: 56 additions & 0 deletions lib/appwrite/role.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
module Appwrite

# Helper class to generate role strings for `Permission`.
class Role

# Grants access to anyone.
#
# This includes authenticated and unauthenticated users.
#
# @return [String]
def self.any
'any'
end

# Grants access to a specific user by user ID.
#
# You can optionally pass verified or unverified for
# `status` to target specific types of users.
#
# @param [String] id
# @param [String] status
#
# @return [String]
def self.user(id, status = "")
if(status.empty?)
"user:#{id}"
Expand All @@ -12,6 +29,14 @@ def self.user(id, status = "")
end
end

# Grants access to any authenticated or anonymous user.
#
# You can optionally pass verified or unverified for
# `status` to target specific types of users.
#
# @param [String] status
#
# @return [String]
def self.users(status = "")
if(status.empty?)
'users'
Expand All @@ -20,10 +45,24 @@ def self.users(status = "")
end
end

# Grants access to any guest user without a session.
#
# Authenticated users don't have access to this role.
#
# @return [String]
def self.guests
'guests'
end

# Grants access to a team by team ID.
#
# You can optionally pass a role for `role` to target
# team members with the specified role.
#
# @param [String] id
# @param [String] role
#
# @return [String]
def self.team(id, role = "")
if(role.empty?)
"team:#{id}"
Expand All @@ -32,8 +71,25 @@ def self.team(id, role = "")
end
end

# Grants access to a specific member of a team.
#
# When the member is removed from the team, they will
# no longer have access.
#
# @param [String] id
#
# @return [String]
def self.member(id)
"member:#{id}"
end

# Grants access to a user with the specified label.
#
# @param [String] name
#
# @return [String]
def self.label(name)
"label:#{name}"
end
end
end
Loading