Class: NewsmastMastodon::ReblogPostService
- Inherits:
-
BaseService
- Object
- BaseService
- NewsmastMastodon::ReblogPostService
- Defined in:
- app/services/newsmast_mastodon/reblog_post_service.rb
Constant Summary collapse
- CACHE_KEY =
'reblog_access_token'
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(status_url) ⇒ ReblogPostService
constructor
A new instance of ReblogPostService.
Constructor Details
#initialize(status_url) ⇒ ReblogPostService
Returns a new instance of ReblogPostService.
9 10 11 12 13 14 |
# File 'app/services/newsmast_mastodon/reblog_post_service.rb', line 9 def initialize(status_url) @status_url = status_url @base_url = ENV['REBLOG_INSTANCE_URL'] @email = ENV['REBLOG_EMAIL'] @password = ENV['REBLOG_PASSWORD'] end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/newsmast_mastodon/reblog_post_service.rb', line 16 def call token = fetch_token unless token.present? Rails.cache.delete(CACHE_KEY) Rails.logger.error "[ReblogPostService] Authentication failed: Token not found" end status_id = NewsmastMastodon::SearchPostService.new(@base_url, token, @status_url).call rescue StandardError => e Rails.logger.error "[ReblogPostService] Error: #{e.class} - #{e.}" raise e end |