skyfall 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d272120c19a97451a6df364e1a7dbbb8191dc0247fd929129ecab0cf05902599
4
- data.tar.gz: 242ebbbbf44aee36a883c2fc78be327d29c14fa27168fc1eac66ef38ad16cc16
3
+ metadata.gz: 8fb36995d08abb6e93e1ce9f29ca74a88cea54bf21b3a1ae0d66a1cb9feb9240
4
+ data.tar.gz: b9c21937b269d0cae220563bd912ce13d0d381bec920a139d40c33b6ace06253
5
5
  SHA512:
6
- metadata.gz: cebb5837133466638a7009d52be516af961644c55f91fe3f3e9a6fe120bc8875f614bbf849cea02fe23b81f3f1f4652226214d375adff12198faf3dd81c1bedd
7
- data.tar.gz: f1c8c48d58c344a67f4df27afc792b6d38272ecb0aefdf7cf4336269290e36c788d356547c2af0520a9d11664e62fb872157da88951cb669f7081bb0414cc029
6
+ metadata.gz: f71bc939578c8fd50278562c28c19e00e558297e93440f1627b567df8f0c5fa3dc88b22efa2cd5a284fc58c241d1f66a21f9c482b7dda3fc799263ebfd777ee0
7
+ data.tar.gz: 579db31d36c8fcee844f3d26193eea2fcdc9721e037ac5c6d1e1ee20362059f9051afd1fb56fab4ba15e566add9571751e85d8b0663fda190f80756959882468
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.5.1] - 2025-05-18
2
+
3
+ - added support for the new `#sync` message type
4
+ - added `#unknown?` helper in `Skyfall::Firehose::Message` and `Skyfall::Jetstream::Message`, which returns true if the message type is `UnknownMessage`
5
+ - added `:bsky_verification` and `:bsky_actor_status` lexicon type and shortcode
6
+ - added one missing require
7
+
1
8
  ## [0.5.0] - 2024-11-15
2
9
 
3
10
  Jetstream support! You can now connect to [Jetstream](https://github.com/bluesky-social/jetstream) sources using `Skyfall::Jetstream` (see readme).
data/README.md CHANGED
@@ -80,7 +80,7 @@ Alternatively, you can connect to a [Jetstream](https://github.com/bluesky-socia
80
80
  Jetstream connections are made using a `Skyfall::Jetstream` instance, which has more or less the same API as `Skyfall::Firehose`, so it should be possible to switch between those by just changing the line that creates the client instance:
81
81
 
82
82
  ```rb
83
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network')
83
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network')
84
84
 
85
85
  sky.on_message { |msg| ... }
86
86
  sky.on_error { |e| ... }
@@ -113,7 +113,7 @@ Jetstream has a similar mechanism, except the cursor is the event's timestamp in
113
113
  ```rb
114
114
  cursor = load_cursor
115
115
 
116
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', { cursor: cursor })
116
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network', { cursor: cursor })
117
117
  sky.on_message do |msg|
118
118
  save_cursor(msg.seq)
119
119
  process_message(msg)
@@ -283,7 +283,7 @@ Jetstream allows you to specify [filters](https://github.com/bluesky-social/jets
283
283
  To use these filters, pass the "wantedCollections" and/or "wantedDids" parameters in the options hash when initializing `Skyfall::Jetstream`. You can use the original JavaScript param names, or a more Ruby-like snake_case form:
284
284
 
285
285
  ```rb
286
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', {
286
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network', {
287
287
  wanted_collections: 'app.bsky.feed.post',
288
288
  wanted_dids: @dids
289
289
  })
@@ -292,7 +292,7 @@ sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', {
292
292
  For collections, you can also use the symbol codes used in `Operation#type`, e.g. `:bsky_post`:
293
293
 
294
294
  ```rb
295
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', {
295
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network', {
296
296
  wanted_collections: [:bsky_post]
297
297
  })
298
298
  ```
@@ -18,7 +18,7 @@ if terms.empty?
18
18
  end
19
19
 
20
20
  # tell Jetstream to send us only post records
21
- sky = Skyfall::Jetstream.new('jetstream1.us-east.bsky.network', { wanted_collections: [:bsky_post] })
21
+ sky = Skyfall::Jetstream.new('jetstream2.us-east.bsky.network', { wanted_collections: [:bsky_post] })
22
22
 
23
23
  sky.on_message do |msg|
24
24
  # we're only interested in repo commit messages
@@ -1,37 +1,41 @@
1
1
  module Skyfall
2
2
  module Collection
3
- BSKY_PROFILE = "app.bsky.actor.profile"
4
- BSKY_FEED = "app.bsky.feed.generator"
5
- BSKY_LIKE = "app.bsky.feed.like"
6
- BSKY_POST = "app.bsky.feed.post"
7
- BSKY_POSTGATE = "app.bsky.feed.postgate"
8
- BSKY_REPOST = "app.bsky.feed.repost"
9
- BSKY_THREADGATE = "app.bsky.feed.threadgate"
10
- BSKY_BLOCK = "app.bsky.graph.block"
11
- BSKY_FOLLOW = "app.bsky.graph.follow"
12
- BSKY_LIST = "app.bsky.graph.list"
13
- BSKY_LISTBLOCK = "app.bsky.graph.listblock"
14
- BSKY_LISTITEM = "app.bsky.graph.listitem"
15
- BSKY_STARTERPACK = "app.bsky.graph.starterpack"
16
- BSKY_LABELER = "app.bsky.labeler.service"
3
+ BSKY_PROFILE = "app.bsky.actor.profile"
4
+ BSKY_ACTOR_STATUS = "app.bsky.actor.status"
5
+ BSKY_FEED = "app.bsky.feed.generator"
6
+ BSKY_LIKE = "app.bsky.feed.like"
7
+ BSKY_POST = "app.bsky.feed.post"
8
+ BSKY_POSTGATE = "app.bsky.feed.postgate"
9
+ BSKY_REPOST = "app.bsky.feed.repost"
10
+ BSKY_THREADGATE = "app.bsky.feed.threadgate"
11
+ BSKY_BLOCK = "app.bsky.graph.block"
12
+ BSKY_FOLLOW = "app.bsky.graph.follow"
13
+ BSKY_LIST = "app.bsky.graph.list"
14
+ BSKY_LISTBLOCK = "app.bsky.graph.listblock"
15
+ BSKY_LISTITEM = "app.bsky.graph.listitem"
16
+ BSKY_STARTERPACK = "app.bsky.graph.starterpack"
17
+ BSKY_VERIFICATION = "app.bsky.graph.verification"
18
+ BSKY_LABELER = "app.bsky.labeler.service"
17
19
 
18
20
  BSKY_CHAT_DECLARATION = "chat.bsky.actor.declaration"
19
21
 
20
22
  SHORT_CODES = {
21
- BSKY_BLOCK => :bsky_block,
22
- BSKY_FEED => :bsky_feed,
23
- BSKY_FOLLOW => :bsky_follow,
24
- BSKY_LABELER => :bsky_labeler,
25
- BSKY_LIKE => :bsky_like,
26
- BSKY_LIST => :bsky_list,
27
- BSKY_LISTBLOCK => :bsky_listblock,
28
- BSKY_LISTITEM => :bsky_listitem,
29
- BSKY_POST => :bsky_post,
30
- BSKY_POSTGATE => :bsky_postgate,
31
- BSKY_PROFILE => :bsky_profile,
32
- BSKY_REPOST => :bsky_repost,
33
- BSKY_STARTERPACK => :bsky_starterpack,
34
- BSKY_THREADGATE => :bsky_threadgate,
23
+ BSKY_ACTOR_STATUS => :bsky_actor_status,
24
+ BSKY_BLOCK => :bsky_block,
25
+ BSKY_FEED => :bsky_feed,
26
+ BSKY_FOLLOW => :bsky_follow,
27
+ BSKY_LABELER => :bsky_labeler,
28
+ BSKY_LIKE => :bsky_like,
29
+ BSKY_LIST => :bsky_list,
30
+ BSKY_LISTBLOCK => :bsky_listblock,
31
+ BSKY_LISTITEM => :bsky_listitem,
32
+ BSKY_POST => :bsky_post,
33
+ BSKY_POSTGATE => :bsky_postgate,
34
+ BSKY_PROFILE => :bsky_profile,
35
+ BSKY_REPOST => :bsky_repost,
36
+ BSKY_STARTERPACK => :bsky_starterpack,
37
+ BSKY_THREADGATE => :bsky_threadgate,
38
+ BSKY_VERIFICATION => :bsky_verification,
35
39
  BSKY_CHAT_DECLARATION => :bsky_chat_declaration,
36
40
  }
37
41
 
@@ -0,0 +1,48 @@
1
+ require 'websocket/driver'
2
+ require_relative 'firehose'
3
+
4
+ module WebSocket
5
+ class Driver
6
+ class Hybi
7
+ def emit_message
8
+ message = @extensions.process_incoming_message(@message)
9
+ @message = nil
10
+
11
+ payload = message.data
12
+
13
+ case message.opcode
14
+ when OPCODES[:text] then
15
+ payload = Driver.encode(payload, Encoding::UTF_8)
16
+ payload = nil unless payload.valid_encoding?
17
+ # when OPCODES[:binary]
18
+ # payload = payload.bytes.to_a
19
+ end
20
+
21
+ if payload
22
+ emit(:message, MessageEvent.new(payload))
23
+ else
24
+ fail(:encoding_error, 'Could not decode a text frame as UTF-8')
25
+ end
26
+ rescue ::WebSocket::Extensions::ExtensionError => error
27
+ fail(:extension_error, error.message)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ module Skyfall
34
+ class Firehose
35
+ def handle_message(msg)
36
+ data = msg.data #.pack('C*')
37
+ @handlers[:raw_message]&.call(data)
38
+
39
+ if @handlers[:message]
40
+ atp_message = Message.new(data)
41
+ @cursor = atp_message.seq
42
+ @handlers[:message].call(atp_message)
43
+ else
44
+ @cursor = nil
45
+ end
46
+ end
47
+ end
48
+ end
@@ -15,6 +15,7 @@ module Skyfall
15
15
  require_relative 'identity_message'
16
16
  require_relative 'info_message'
17
17
  require_relative 'labels_message'
18
+ require_relative 'sync_message'
18
19
  require_relative 'tombstone_message'
19
20
  require_relative 'unknown_message'
20
21
 
@@ -34,6 +35,7 @@ module Skyfall
34
35
  when '#identity' then Firehose::IdentityMessage
35
36
  when '#info' then Firehose::InfoMessage
36
37
  when '#labels' then Firehose::LabelsMessage
38
+ when '#sync' then Firehose::SyncMessage
37
39
  when '#tombstone' then Firehose::TombstoneMessage
38
40
  else Firehose::UnknownMessage
39
41
  end
@@ -56,6 +58,10 @@ module Skyfall
56
58
  []
57
59
  end
58
60
 
61
+ def unknown?
62
+ self.is_a?(Firehose::UnknownMessage)
63
+ end
64
+
59
65
  def time
60
66
  @time ||= @data_object['time'] && Time.parse(@data_object['time'])
61
67
  end
@@ -0,0 +1,9 @@
1
+ require_relative '../firehose'
2
+
3
+ module Skyfall
4
+ class Firehose::SyncMessage < Firehose::Message
5
+ def rev
6
+ @rev ||= @data_object['rev']
7
+ end
8
+ end
9
+ end
@@ -39,6 +39,10 @@ module Skyfall
39
39
  @time_us = @json['time_us']
40
40
  end
41
41
 
42
+ def unknown?
43
+ self.is_a?(Jetstream::UnknownMessage)
44
+ end
45
+
42
46
  def operations
43
47
  []
44
48
  end
@@ -2,6 +2,8 @@ require 'eventmachine'
2
2
  require 'faye/websocket'
3
3
  require 'uri'
4
4
 
5
+ require_relative 'version'
6
+
5
7
  module Skyfall
6
8
  class Stream
7
9
  EVENTS = %w(message raw_message connecting connect disconnect reconnect error timeout)
@@ -53,7 +55,7 @@ module Skyfall
53
55
  @handlers[:error]&.call(e)
54
56
  end
55
57
 
56
- @ws = Faye::WebSocket::Client.new(url, nil, { headers: { 'User-Agent' => user_agent }})
58
+ @ws = build_websocket_client(url)
57
59
 
58
60
  @ws.on(:open) do |e|
59
61
  @handlers[:connect]&.call
@@ -183,6 +185,10 @@ module Skyfall
183
185
  end
184
186
  end
185
187
 
188
+ def build_websocket_client(url)
189
+ Faye::WebSocket::Client.new(url, nil, { headers: { 'User-Agent' => user_agent }})
190
+ end
191
+
186
192
  def build_websocket_url
187
193
  @root_url
188
194
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Skyfall
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skyfall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Suder
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-15 00:00:00.000000000 Z
10
+ date: 2025-05-19 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base32
@@ -123,6 +122,7 @@ files:
123
122
  - lib/skyfall/collection.rb
124
123
  - lib/skyfall/errors.rb
125
124
  - lib/skyfall/extensions.rb
125
+ - lib/skyfall/faye_ext.rb
126
126
  - lib/skyfall/firehose.rb
127
127
  - lib/skyfall/firehose/account_message.rb
128
128
  - lib/skyfall/firehose/commit_message.rb
@@ -132,6 +132,7 @@ files:
132
132
  - lib/skyfall/firehose/labels_message.rb
133
133
  - lib/skyfall/firehose/message.rb
134
134
  - lib/skyfall/firehose/operation.rb
135
+ - lib/skyfall/firehose/sync_message.rb
135
136
  - lib/skyfall/firehose/tombstone_message.rb
136
137
  - lib/skyfall/firehose/unknown_message.rb
137
138
  - lib/skyfall/jetstream.rb
@@ -152,7 +153,6 @@ metadata:
152
153
  bug_tracker_uri: https://github.com/mackuba/skyfall/issues
153
154
  changelog_uri: https://github.com/mackuba/skyfall/blob/master/CHANGELOG.md
154
155
  source_code_uri: https://github.com/mackuba/skyfall
155
- post_install_message:
156
156
  rdoc_options: []
157
157
  require_paths:
158
158
  - lib
@@ -167,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.4.10
171
- signing_key:
170
+ rubygems_version: 3.6.2
172
171
  specification_version: 4
173
172
  summary: A Ruby gem for streaming data from the Bluesky/AtProto firehose
174
173
  test_files: []