lib/submodules/ably-ruby/lib/ably/rest/channel.rb in ably-rest-0.8.5 vs lib/submodules/ably-ruby/lib/ably/rest/channel.rb in ably-rest-0.8.6

- old
+ new

@@ -65,10 +65,18 @@ end payload = messages.map do |message| Ably::Models::Message(message.dup).tap do |message| message.encode self + + next if message.client_id.nil? + if message.client_id == '*' + raise Ably::Exceptions::IncompatibleClientId.new('Wildcard client_id is reserved and cannot be used when publishing messages', 400, 40012) + end + unless client.auth.can_assume_client_id?(message.client_id) + raise Ably::Exceptions::IncompatibleClientId.new("Cannot publish with client_id '#{message.client_id}' as it is incompatible with the current configured client_id '#{client.client_id}'", 400, 40012) + end end.as_json end response = client.post("#{base_path}/publish", payload.length == 1 ? payload.first : payload) @@ -121,10 +129,10 @@ @options = channel_options.clone.freeze end private def base_path - "/channels/#{CGI.escape(name)}" + "/channels/#{Addressable::URI.encode(name)}" end def decode_message(message) message.decode self rescue Ably::Exceptions::CipherError, Ably::Exceptions::EncoderError => e