Class: Noticed::BulkDeliveryMethods::Bluesky
Instance Attribute Summary
#config, #event
Instance Method Summary
collapse
#evaluate_option, #fetch_constant, #perform
Methods included from ApiClient
#post_request
Instance Method Details
#deliver ⇒ Object
bulk_deliver_by :bluesky do |config|
config.identifier = ENV["BLUESKY_ID"]
config.password = ENV["BLUESKY_PASSWORD"]
config.json = {text: "...", createdAt: "..."}
end
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/noticed/bulk_delivery_methods/bluesky.rb', line 12
def deliver
Rails.logger.debug(evaluate_option(:json))
post_request(
"https://#{host}/xrpc/com.atproto.repo.createRecord",
headers: {"Authorization" => "Bearer #{token}"},
json: {
repo: identifier,
collection: "app.bsky.feed.post",
record: evaluate_option(:json)
}
)
end
|
#host ⇒ Object
40
41
42
|
# File 'lib/noticed/bulk_delivery_methods/bluesky.rb', line 40
def host
@host ||= evaluate_option(:host) || "bsky.social"
end
|
#identifier ⇒ Object
44
45
46
|
# File 'lib/noticed/bulk_delivery_methods/bluesky.rb', line 44
def identifier
@identifier ||= evaluate_option(:identifier)
end
|
#start_session ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/noticed/bulk_delivery_methods/bluesky.rb', line 29
def start_session
response = post_request(
"https://#{host}/xrpc/com.atproto.server.createSession",
json: {
identifier: identifier,
password: evaluate_option(:password)
}
)
JSON.parse(response.body)
end
|
#token ⇒ Object
25
26
27
|
# File 'lib/noticed/bulk_delivery_methods/bluesky.rb', line 25
def token
start_session.dig("accessJwt")
end
|