File tree 4 files changed +75
-2
lines changed
docs/bulk_delivery_methods
noticed/bulk_delivery_methods
4 files changed +75
-2
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ Delivery methods we officially support:
41
41
42
42
Bulk delivery methods we support:
43
43
44
+ * [ Bluesky] ( docs/bulk_delivery_methods/bluesky.md )
44
45
* [ Discord] ( docs/bulk_delivery_methods/discord.md )
45
46
* [ Slack] ( docs/bulk_delivery_methods/slack.md )
46
47
* [ Webhook] ( docs/bulk_delivery_methods/webhook.md )
@@ -427,8 +428,8 @@ Recipients can also be computed inside a notifier:
427
428
class NewCommentNotifier < ApplicationNotifier
428
429
recipients ->{ params[:record].thread.all_authors }
429
430
430
- # or
431
- recipients do
431
+ # or
432
+ recipients do
432
433
params[:record].thread.all_authors
433
434
end
434
435
@@ -526,6 +527,7 @@ Individual delivery methods:
526
527
527
528
Bulk delivery methods :
528
529
530
+ * [Bluesky](docs/bulk_delivery_methods/bluesky.md)
529
531
* [Discord](docs/bulk_delivery_methods/discord.md)
530
532
* [Slack](docs/bulk_delivery_methods/slack.md)
531
533
* [Webhook](docs/bulk_delivery_methods/webhook.md)
Original file line number Diff line number Diff line change
1
+ # Bluesky Bulk Delivery Method
2
+
3
+ Create a Bluesky post.
4
+
5
+ ## Usage
6
+
7
+ ``` ruby
8
+ class CommentNotification
9
+ bulk_deliver_by :bluesky do |config |
10
+ config.identifier = " username"
11
+ config.password = " password"
12
+ config.json = -> {
13
+ {
14
+ text: " Hello world!" ,
15
+ createdAt: Time .current.iso8601
16
+ # ...
17
+ }
18
+ }
19
+ end
20
+ end
21
+ ```
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ def self.deprecator # :nodoc:
20
20
autoload :Translation , "noticed/translation"
21
21
22
22
module BulkDeliveryMethods
23
+ autoload :Bluesky , "noticed/bulk_delivery_methods/bluesky"
23
24
autoload :Discord , "noticed/bulk_delivery_methods/discord"
24
25
autoload :Slack , "noticed/bulk_delivery_methods/slack"
25
26
autoload :Test , "noticed/bulk_delivery_methods/test"
Original file line number Diff line number Diff line change
1
+ module Noticed
2
+ module BulkDeliveryMethods
3
+ class Bluesky < BulkDeliveryMethod
4
+ required_options :identifier , :password , :json
5
+
6
+ # bulk_deliver_by :bluesky do |config|
7
+ # config.identifier = ENV["BLUESKY_ID"]
8
+ # config.password = ENV["BLUESKY_PASSWORD"]
9
+ # config.json = {text: "...", createdAt: "..."}
10
+ # end
11
+
12
+ def deliver
13
+ Rails . logger . debug ( evaluate_option ( :json ) )
14
+ post_request (
15
+ "https://#{ host } /xrpc/com.atproto.repo.createRecord" ,
16
+ headers : { "Authorization" => "Bearer #{ token } " } ,
17
+ json : {
18
+ repo : identifier ,
19
+ collection : "app.bsky.feed.post" ,
20
+ record : evaluate_option ( :json )
21
+ } ,
22
+ )
23
+ end
24
+
25
+ def token
26
+ start_session . dig ( "accessJwt" )
27
+ end
28
+
29
+ def start_session
30
+ response = post_request (
31
+ "https://#{ host } /xrpc/com.atproto.server.createSession" ,
32
+ json : {
33
+ identifier : identifier ,
34
+ password : evaluate_option ( :password )
35
+ }
36
+ )
37
+ JSON . parse ( response . body )
38
+ end
39
+
40
+ def host
41
+ @host ||= evaluate_option ( :host ) || "bsky.social"
42
+ end
43
+
44
+ def identifier
45
+ @identifier ||= evaluate_option ( :identifier )
46
+ end
47
+ end
48
+ end
49
+ end
You can’t perform that action at this time.
0 commit comments