Class: Abqari::Syndication::Networks::Mastodon
- Inherits:
-
Base
- Object
- Base
- Abqari::Syndication::Networks::Mastodon
show all
- Defined in:
- lib/abqari/syndication.rb
Overview
Mastodon — uses the standard API. access_token is a per-user
OAuth token; in the Mastodon UI: Preferences → Development →
New Application (give it write:statuses scope).
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
325
326
327
|
# File 'lib/abqari/syndication.rb', line 325
def configured?
!instance_url.to_s.empty? && !token.to_s.empty?
end
|
#name ⇒ Object
321
322
323
|
# File 'lib/abqari/syndication.rb', line 321
def name
'mastodon'
end
|
#post(text:, url:) ⇒ Object
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
# File 'lib/abqari/syndication.rb', line 329
def post(text:, url:)
uri = URI("#{instance_url.sub(%r{/\z}, '')}/api/v1/statuses")
body = URI.encode_www_form(
status: text,
visibility: visibility
)
status, payload = http_json(uri,
method: :post,
headers: {
'Authorization' => "Bearer #{token}",
'Content-Type' => 'application/x-www-form-urlencoded'
},
body: body)
return nil unless status&.between?(200, 299) && payload
payload['url']
end
|