tangled
alpha
login
or
join now
mackuba.eu
/
skyfall
6
fork
atom
A Ruby gem for streaming data from the Bluesky/ATProto firehose
6
fork
atom
overview
issues
pulls
pipelines
use Hash#dig to get nested optional fields
mackuba.eu
3 months ago
ba9bbfd4
00190f52
+10
-10
1 changed file
expand all
collapse all
unified
split
example
push_notifications.rb
+10
-10
example/push_notifications.rb
···
98
98
99
99
if reply = data['reply']
100
100
# check for replies (direct only)
101
101
-
if reply['parent'] && reply['parent']['uri']
102
102
-
parent_uri = AtURI.new(reply['parent']['uri'])
101
101
+
if uri = reply.dig('parent', 'uri')
102
102
+
parent_uri = AtURI.new(uri)
103
103
104
104
if parent_uri.did == @user_did
105
105
send_reply_notification(msg, op)
···
109
109
110
110
if embed = data['embed']
111
111
# check for quotes
112
112
-
if embed['record'] && embed['record']['uri']
113
113
-
quoted_uri = AtURI.new(embed['record']['uri'])
112
112
+
if uri = embed.dig('record', 'uri')
113
113
+
quoted_uri = AtURI.new(uri)
114
114
115
115
if quoted_uri.did == @user_did
116
116
send_quote_notification(msg, op)
···
118
118
end
119
119
120
120
# second type of quote (recordWithMedia)
121
121
-
if embed['record'] && embed['record']['record'] && embed['record']['record']['uri']
122
122
-
quoted_uri = AtURI.new(embed['record']['record']['uri'])
121
121
+
if uri = embed.dig('record', 'record', 'uri')
122
122
+
quoted_uri = AtURI.new(uri)
123
123
124
124
if quoted_uri.did == @user_did
125
125
send_quote_notification(msg, op)
···
159
159
def process_like(msg, op)
160
160
data = op.raw_record
161
161
162
162
-
if data['subject'] && data['subject']['uri']
163
163
-
liked_uri = AtURI.new(data['subject']['uri'])
162
162
+
if uri = data.dig('subject', 'uri')
163
163
+
liked_uri = AtURI.new(uri)
164
164
165
165
if liked_uri.did == @user_did
166
166
case liked_uri.collection
···
193
193
def process_repost(msg, op)
194
194
data = op.raw_record
195
195
196
196
-
if data['subject'] && data['subject']['uri']
197
197
-
reposted_uri = AtURI.new(data['subject']['uri'])
196
196
+
if uri = data.dig('subject', 'uri')
197
197
+
reposted_uri = AtURI.new(uri)
198
198
199
199
if reposted_uri.did == @user_did && reposted_uri.collection == 'app.bsky.feed.post'
200
200
send_repost_notification(msg, reposted_uri)