blue_factory 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +0 -2
- data/lib/blue_factory/tasks/publish.rake +17 -7
- data/lib/blue_factory/tasks/support.rb +17 -0
- data/lib/blue_factory/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae5c10a8dcd8bfd61682ce21cf4aa509ec9c0c651a6cdf0aa57da637d9822184
|
4
|
+
data.tar.gz: '028f4409f9d9a06d6b675b73a3d5fb0460df394524b9e95efd3f9b37f8c5bfea'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 905c86c1d8b504f0fd5d2a21b68170e26c946b59d3fa5104878cdc947f789429a056a5783e1f9231a8f7a5c022c9603cf430f6e9a10ff4390d26153a83ab575d
|
7
|
+
data.tar.gz: 8aa9307562065b331e1d2daf03c4e197b47e7c2dfc27a3db3fd0693e5b36ed0e2c2c31cf66fe0b8f0b23df814794d563b48725fb52030eb02b8c6fb3d0f6b84b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -232,8 +232,6 @@ When you're ready, run the rake task passing the feed key (you will be asked for
|
|
232
232
|
bundle exec rake bluesky:publish KEY=wwdc
|
233
233
|
```
|
234
234
|
|
235
|
-
For non-Bluesky PDSes, you need to also add an env var `SERVER_URL=https://your.pds.host`.
|
236
|
-
|
237
235
|
|
238
236
|
## Credits
|
239
237
|
|
@@ -22,6 +22,8 @@ namespace :bluesky do
|
|
22
22
|
exit 1
|
23
23
|
end
|
24
24
|
|
25
|
+
publisher_did = BlueFactory.publisher_did
|
26
|
+
|
25
27
|
feed = BlueFactory.get_feed(feed_key)
|
26
28
|
|
27
29
|
if feed.nil?
|
@@ -71,21 +73,29 @@ namespace :bluesky do
|
|
71
73
|
avatar_data = File.read(avatar_file)
|
72
74
|
end
|
73
75
|
|
74
|
-
|
76
|
+
did_url = if publisher_did.start_with?('did:plc:')
|
77
|
+
"https://plc.directory/#{publisher_did}"
|
78
|
+
else
|
79
|
+
web_domain = did.gsub(/^did\:web\:/, '')
|
80
|
+
"https://#{web_domain}/.well-known/did.json"
|
81
|
+
end
|
82
|
+
|
83
|
+
did_json = BlueFactory::Net.get_request(did_url)
|
84
|
+
pds_host = did_json['service'].detect { |x| x['id'] == '#atproto_pds' }['serviceEndpoint']
|
75
85
|
|
76
|
-
print "Enter password for your publisher account (#{
|
86
|
+
print "Enter password for your publisher account (#{publisher_did}): "
|
77
87
|
password = STDIN.noecho(&:gets).chomp
|
78
88
|
puts
|
79
89
|
|
80
|
-
json = BlueFactory::Net.post_request(
|
81
|
-
identifier:
|
90
|
+
json = BlueFactory::Net.post_request(pds_host, 'com.atproto.server.createSession', {
|
91
|
+
identifier: publisher_did,
|
82
92
|
password: password
|
83
93
|
})
|
84
94
|
|
85
95
|
access_token = json['accessJwt']
|
86
96
|
|
87
97
|
if avatar_data
|
88
|
-
json = BlueFactory::Net.post_request(
|
98
|
+
json = BlueFactory::Net.post_request(pds_host, 'com.atproto.repo.uploadBlob', avatar_data,
|
89
99
|
content_type: encoding, auth: access_token)
|
90
100
|
|
91
101
|
avatar_ref = json['blob']
|
@@ -101,8 +111,8 @@ namespace :bluesky do
|
|
101
111
|
record[:avatar] = avatar_ref if avatar_ref
|
102
112
|
record[:contentMode] = feed_content_mode if feed_content_mode
|
103
113
|
|
104
|
-
json = BlueFactory::Net.post_request(
|
105
|
-
repo:
|
114
|
+
json = BlueFactory::Net.post_request(pds_host, 'com.atproto.repo.putRecord', {
|
115
|
+
repo: publisher_did,
|
106
116
|
collection: BlueFactory::FEED_GENERATOR_TYPE,
|
107
117
|
rkey: feed_key,
|
108
118
|
record: record
|
@@ -1,10 +1,27 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'net/http'
|
3
|
+
require 'uri'
|
3
4
|
|
4
5
|
module BlueFactory
|
5
6
|
module Net
|
6
7
|
class ResponseError < StandardError; end
|
7
8
|
|
9
|
+
def self.get_request(server, method = nil, params = nil, auth: nil)
|
10
|
+
headers = {}
|
11
|
+
headers['Authorization'] = "Bearer #{auth}" if auth
|
12
|
+
|
13
|
+
url = method ? URI("#{server}/xrpc/#{method}") : URI(server)
|
14
|
+
|
15
|
+
if params && !params.empty?
|
16
|
+
url.query = URI.encode_www_form(params)
|
17
|
+
end
|
18
|
+
|
19
|
+
response = ::Net::HTTP.get_response(url, headers)
|
20
|
+
raise ResponseError, "Invalid response: #{response.code} #{response.body}" if response.code.to_i / 100 != 2
|
21
|
+
|
22
|
+
JSON.parse(response.body)
|
23
|
+
end
|
24
|
+
|
8
25
|
def self.post_request(server, method, data, auth: nil, content_type: "application/json")
|
9
26
|
headers = {}
|
10
27
|
headers['Content-Type'] = content_type
|
data/lib/blue_factory/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blue_factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kuba Suder
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: sinatra
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
rubygems_version: 3.6.
|
72
|
+
rubygems_version: 3.6.9
|
73
73
|
specification_version: 4
|
74
74
|
summary: A Ruby gem for hosting custom feeds for Bluesky
|
75
75
|
test_files: []
|