Skip to content

Commit

Permalink
feat: add check sns point (#134)
Browse files Browse the repository at this point in the history
* feat: add check sns point

* feat: check sns

* fix: linting
  • Loading branch information
totalimmersion authored Oct 30, 2023
1 parent 2bcb985 commit 532ae7e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/stream-chat/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def self.from_env(**options)
Client.new(ENV.fetch('STREAM_KEY'),
ENV.fetch('STREAM_SECRET'),
ENV.fetch('STREAM_CHAT_TIMEOUT', DEFAULT_TIMEOUT),
**{ base_url: ENV.fetch('STREAM_CHAT_URL', DEFAULT_BASE_URL) }.merge(options))
base_url: ENV.fetch('STREAM_CHAT_URL', DEFAULT_BASE_URL),
**options)
end

# Sets the underlying Faraday http client.
Expand Down Expand Up @@ -741,6 +742,14 @@ def check_sqs(sqs_key = nil, sqs_secret = nil, sqs_url = nil)
post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
end

# Check SNS Push settings
#
# When no parameters are given, the current SNS app settings are used.
sig { params(sns_key: T.nilable(String), sns_secret: T.nilable(String), sns_topic_arn: T.nilable(String)).returns(StreamChat::StreamResponse) }
def check_sns(sns_key = nil, sns_secret = nil, sns_topic_arn = nil)
post('check_sns', data: { sns_key: sns_key, sns_secret: sns_secret, sns_topic_arn: sns_topic_arn })
end

# Creates a new command.
sig { params(command: StringKeyHash).returns(StreamChat::StreamResponse) }
def create_command(command)
Expand Down
6 changes: 6 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,12 @@ def loop_times(times)
expect(resp['error']).to include 'invalid SQS url'
end

it 'check_sns with an invalid topic arn should fail' do
resp = @client.check_sns('key', 'secret', 'arn:aws:sns:us-east-1:123456789012:sns-topic')
expect(resp['status']).to eq 'error'
expect(resp['error']).to include 'publishing the message failed.'
end

it 'can create a guest if it"s allowed' do
guest_user = @client.create_guest({ user: { id: SecureRandom.uuid } })
expect(guest_user['access_token']).not_to be_empty
Expand Down

0 comments on commit 532ae7e

Please sign in to comment.