+1
-1
Gemfile
+1
-1
Gemfile
+2
-2
Gemfile.lock
+2
-2
Gemfile.lock
···
25
25
bcrypt_pbkdf (1.1.1)
26
26
benchmark (0.4.1)
27
27
bigdecimal (3.2.2)
28
-
blue_factory (0.1.5)
28
+
blue_factory (0.1.6)
29
29
sinatra (~> 3.0)
30
30
capistrano (2.15.11)
31
31
highline
···
128
128
DEPENDENCIES
129
129
activerecord (~> 8.0)
130
130
bcrypt_pbkdf (>= 1.0, < 2.0)
131
-
blue_factory (~> 0.1.5)
131
+
blue_factory (~> 0.1.6)
132
132
capistrano (~> 2.0)
133
133
debug
134
134
didkit (~> 0.2)
+1
-3
README.md
+1
-3
README.md
···
1
-
<h1>Bluesky feeds in Ruby <img src="https://raw.githubusercontent.com/mackuba/bluesky-feeds-rb/ebbfc3056129a2c31bf030cb21e4b14a71dea3c9/images/ruby.png" width="26"></h1>
1
+
<h1>Bluesky feeds in Ruby <img src="https://raw.githubusercontent.com/mackuba/bluesky-feeds-rb/refs/heads/master/images/ruby.png" width="26"></h1>
2
2
3
3
This repo is an example or template that you can use to create a "feed generator" service for the Bluesky social network which hosts custom feeds. It's a reimplementation of the official TypeScript [feed-generator](https://github.com/bluesky-social/feed-generator) example in Ruby.
4
4
···
199
199
```
200
200
bundle exec rake bluesky:publish KEY=starwars
201
201
```
202
-
203
-
If you're on a self-hosted PDS, pass the hostname in a parameter like this: `SERVER_URL=https://pds.example.com`.
204
202
205
203
206
204
### App maintenance
+4
Rakefile
+4
Rakefile
+16
-6
app/firehose_stream.rb
+16
-6
app/firehose_stream.rb
···
57
57
@sky.on_connecting { |u| log "Connecting to #{u}..." }
58
58
59
59
@sky.on_connect {
60
+
@message_counter = 0
60
61
@replaying = !!(cursor)
61
62
log "Connected โ"
62
63
}
···
122
123
if @replaying
123
124
log "Replaying events since #{msg.time.getlocal} -->"
124
125
@replaying = false
126
+
end
127
+
128
+
@message_counter += 1
129
+
130
+
if @message_counter % 100 == 0
131
+
# save current cursor every 100 events
132
+
save_cursor(msg.seq)
125
133
end
126
134
127
135
msg.operations.each do |op|
···
224
232
puts text
225
233
end
226
234
227
-
if @save_posts == :all || @save_posts && matched
235
+
if @save_posts == :all
236
+
# wait until we have 100 posts and then save them all in one insert, if possible
228
237
@post_queue << post
229
-
end
230
238
231
-
# wait until we have 100 posts and then save them all in one insert, if possible
232
-
if @post_queue.length >= POSTS_BATCH_SIZE
233
-
save_queued_posts
234
-
save_cursor(@sky.cursor)
239
+
if @post_queue.length >= POSTS_BATCH_SIZE
240
+
save_queued_posts
241
+
end
242
+
elsif @save_posts == :matching && matched
243
+
# save immediately because matched posts might be rare; we've already checked validations
244
+
post.save!(validate: false)
235
245
end
236
246
237
247
print '.' if @show_progress && @log_posts != :all
+1
-2
app/post_console_printer.rb
+1
-2
app/post_console_printer.rb
···
14
14
if langs.nil?
15
15
print '[nil] * '
16
16
elsif langs != ['en']
17
-
label = langs.map { |ln| ln.upcase.tr('A-Z', "\u{1F1E6}-\u{1F1FF}") }.join
18
-
print "#{label} * "
17
+
print "[#{langs.join(', ')}] * "
19
18
end
20
19
21
20
puts Rainbow("https://bsky.app/profile/#{post.repo}/post/#{post.rkey}").darkgray