discourse_subscription_client 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f069fe8f7e5ca4e06fca3133df12ad2a67599b3d175ad644b9ab346437adc93f
4
- data.tar.gz: c1a8b49c041741767cd37016d3bde41fc23138b23837b74ff2a3c00b80f24fc0
3
+ metadata.gz: 03fe5f25d9d530751ddc8530ff74fb3bca6eef434172769f621beb0ddaebf8bb
4
+ data.tar.gz: 39a728c0ffecdbbfb5d4b6b69983b49fa533dd410ccecd72dfb52aa19657d3ed
5
5
  SHA512:
6
- metadata.gz: f5efe845b7c65951a24bae6a4697db67f48ac528e089aa1182c1594fc1698a4eb1ae7e1fc44f1be82b55603f369d07dd8ad5f665049f2ab96a6ad835710032f5
7
- data.tar.gz: b510d995e599fb23af27447a3e84e6cdbf9c16957fd8b59dfc4d416e8074ddcdbb6fa729d447774e54a6559f4de27fda987ae71f7beb64f1da4dfbd2d40961b9
6
+ metadata.gz: ce4bf56aecb3056ecdda3888508088511417f5739334203dc16d0504324bb4acdb8314de6fdc9818cf14942367e26594c4c91d911eec060cc0d2deb2dac0d72b
7
+ data.tar.gz: c26396551c3dea1b80770918dbc64d4b7ff423e6b0e674ce856c87a46114b11a8ac074cad7631ac47e4cc61350749a34470e925757fea992dba22cfc9623e300
data/README.md CHANGED
@@ -53,7 +53,7 @@ RAILS_ENV=test rake db:drop db:create db:migrate
53
53
  If you're not adding new migrations you only need to load the schema. If you are running migrations you need to also load the schema (in addition to running the migrations)
54
54
 
55
55
  ```
56
- RAILS_ENV=test rake db:schema:load
56
+ RAILS_ENV=test bundle exec rake db:schema:load
57
57
  ```
58
58
 
59
59
  ## License
@@ -7,7 +7,13 @@ module DiscourseSubscriptionClient
7
7
  before_action :find_supplier, only: %i[authorize destroy]
8
8
 
9
9
  def index
10
- render_serialized(SubscriptionClientSupplier.all, SupplierSerializer, root: "suppliers")
10
+ suppliers = SubscriptionClientSupplier.all
11
+ if params[:resource]
12
+ suppliers = suppliers
13
+ .joins(:resources)
14
+ .where(resources: { name: params[:resource] })
15
+ end
16
+ render_serialized(suppliers, SupplierSerializer, root: "suppliers")
11
17
  end
12
18
 
13
19
  def authorize
@@ -8,21 +8,19 @@ class SubscriptionClientResource < ActiveRecord::Base
8
8
  has_many :subscriptions, foreign_key: "resource_id", class_name: "SubscriptionClientSubscription", dependent: :destroy
9
9
 
10
10
  def get_source_url(bucket)
11
- return nil unless access_key_id && secret_access_key
11
+ return nil unless access_key_id && secret_access_key && s3_client
12
12
  return nil unless can_access_bucket?(bucket)
13
13
 
14
14
  "s3://#{access_key_id}:#{secret_access_key}@#{bucket}"
15
15
  end
16
16
 
17
17
  def can_access_bucket?(bucket)
18
- begin
19
- s3_client.head_bucket(bucket: bucket)
20
- rescue Aws::S3::Errors::BadRequest,
21
- Aws::S3::Errors::Forbidden,
22
- Aws::S3::Errors::NotFound => e
23
- return false
24
- end
18
+ s3_client.head_bucket(bucket: bucket)
25
19
  true
20
+ rescue Aws::S3::Errors::BadRequest,
21
+ Aws::S3::Errors::Forbidden,
22
+ Aws::S3::Errors::NotFound
23
+ false
26
24
  end
27
25
 
28
26
  def s3_client
@@ -4,6 +4,7 @@ module DiscourseSubscriptionClient
4
4
  class SupplierSerializer < ApplicationSerializer
5
5
  attributes :id,
6
6
  :name,
7
+ :url,
7
8
  :authorized,
8
9
  :authorized_at
9
10
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DiscourseSubscriptionClient
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discourse_subscription_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angus McLeod
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-17 00:00:00.000000000 Z
11
+ date: 2024-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aws-sdk-s3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: byebug
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -220,20 +234,6 @@ dependencies:
220
234
  - - ">="
221
235
  - !ruby/object:Gem::Version
222
236
  version: '0'
223
- - !ruby/object:Gem::Dependency
224
- name: aws-sdk-s3
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- version: '0'
237
237
  description: Adds a backend subscription client to a Discourse plugin.
238
238
  email:
239
239
  - angus@mcleod.org.au