Comments (10)
Using symbols as hash keys is preferred in ruby, as they are immutable and not trigger GC.
But on parsing request keys are currently strings, and it's not easy to fix it as it's breaking change for the SDK users.
from stream-chat-ruby.
@peterdeme can you please also check this issue out when you will have time? Should be a quick one. Thank you.
from stream-chat-ruby.
thanks for reporting this, in the meantime can you try client.update_user([user])
?
from stream-chat-ruby.
You mean like
client.update_user([{
'id' => 'bob-1',
'role' => 'admin',
'name' => 'Robert Tables'
}])
?
Gives me
irb(main):004:0> client.update_user([{
irb(main):005:3* 'id' => 'bob-1',
irb(main):006:3* 'role' => 'admin',
irb(main):007:3* 'name' => 'Robert Tables'
irb(main):008:3> }])
Traceback (most recent call last):
6: from /usr/local/bin/irb:11:in `<main>'
5: from (irb):4
4: from /usr/local/bundle/gems/stream-chat-ruby-1.1.0/lib/stream-chat/client.rb:101:in `update_user'
3: from /usr/local/bundle/gems/stream-chat-ruby-1.1.0/lib/stream-chat/client.rb:94:in `update_users'
2: from /usr/local/bundle/gems/stream-chat-ruby-1.1.0/lib/stream-chat/client.rb:94:in `each'
1: from /usr/local/bundle/gems/stream-chat-ruby-1.1.0/lib/stream-chat/client.rb:95:in `block in update_users'
TypeError (no implicit conversion of Symbol into Integer)
from stream-chat-ruby.
Just recreated this and the following works:
# update a single user
client.update_user({
:id => 'bob-1',
:role => 'admin',
:name => 'Robert Tables'
})
# update multiple users
client.update_users([{
:id => 'bob-1',
:role => 'admin',
:name => 'Robert Tables'
}])
Turns out the keys need to be symbols not strings. I'll update the specific example right away. I'm not sure which other examples have similar problems.
from stream-chat-ruby.
@bogdan-d any advice here?
from stream-chat-ruby.
Copying what I put in #12
I've fixed this specific issue, but there seems to be a lot of inconsistencies here.
Like this one which uses strings.
def create_channel_type(data)
if !data.key? "commands" || data["commands"].nil? || data["commands"].empty?
data["commands"] = ["all"]
end
post("channeltypes", data: data)
end
Easiest fix is to switch to using rails' HashWithIndifferentAccess
see here. Although that requires a big import. If we want to avoid that path and just fix the code itself I can't say I'm experienced enough in ruby to know the best way (adding support for both, switching all to one way, or what).
from stream-chat-ruby.
@tbarbugli can you please unassign me :D it seems I don't have permissions.
from stream-chat-ruby.
@keyneston 👋🏻 replaced with me 😃
from stream-chat-ruby.
from stream-chat-ruby.
Related Issues (20)
- Add skip_push option for sending messages
- Gem completely breaks with latest version of Faraday. HOT 2
- Improve release workflow HOT 2
- Relax dependency versions HOT 5
- Gem is misnamed causing additional work during implementation HOT 3
- File upload not working HOT 1
- Missing method 'restore_users' on ruby client
- Querying members with a filter doesn't work HOT 1
- bug: client.create_token returning a token but silently failing to create a user
- Error handling format does not match actual api format HOT 1
- Response headers are not available on successful requests HOT 2
- Sorting messages using channel query method HOT 1
- `StreamChannelException not defined` HOT 2
- Support for multi-tenant mode HOT 1
- Creating channel without ID for Team HOT 1
- Get unread messages from an user in a channel HOT 1
- Use development dependencies HOT 2
- JWT format error on create_token method HOT 4
- Sorbet issue with setting T::Configuration.default_checked_level HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stream-chat-ruby.