M config.example.ini => config.example.ini +1 -0
@@ 4,3 4,4 @@ path = posts.db
[atproto]
jetstream_host = jetstream2.us-east.bsky.network
; publisher_did = <your atproto did>
+; self_host = <domain this runs on>
M main.tcl => main.tcl +7 -1
@@ 63,7 63,13 @@ jetstream::listen [::ini::value $config atproto jetstream_host] $::algos::list
### HTTPD ###
httpd::router main [list \
- /xrpc/app.bsky.feed.getFeedSkeleton [list ::feed::serve_skeleton $::algos::list [::ini::value $config atproto publisher_did]] \
+ /xrpc/app.bsky.feed.getFeedSkeleton [list ::feed::serve_skeleton \
+ $::algos::list \
+ [::ini::value $config atproto publisher_did]] \
+ /xrpc/app.bsky.feed.describeFeedGenerator [list ::feed::serve_generator_description \
+ $::algos::list \
+ [::ini::value $config atproto publisher_did] \
+ [::ini::value $config atproto self_host]]
]
httpd::listen main [::ini::value $config httpd port]
M src/config.tcl => src/config.tcl +1 -0
@@ 35,6 35,7 @@ namespace eval ::config {
require $config atproto jetstream_host
require $config atproto publisher_did
+ require $config atproto self_host
optional $config httpd port 3000
${log}::info "Config loaded!..."
M src/feed.tcl => src/feed.tcl +24 -4
@@ 58,10 58,13 @@ namespace eval feed {
set feed_data {}
foreach uri [db eval "SELECT uri FROM $feed ORDER BY ord DESC LIMIT $limit OFFSET $cursor;"] {
- lappend feed_data [::json::write object post [::json::write string $uri]]
+ lappend feed_data [::json::write object \
+ post [::json::write string $uri]]
}
set feed_data_arr [::json::write array {*}$feed_data]
- set feed_contents [::json::write object cursor [expr {$cursor + min([llength $feed_data], $limit)}] feed $feed_data_arr]
+ set feed_contents [::json::write object \
+ cursor [expr {$cursor + min([llength $feed_data], $limit)}] \
+ feed $feed_data_arr]
puts $sock "HTTP/1.0 200 OK"
puts $sock "Content-Type: application/json"
@@ 73,7 76,24 @@ namespace eval feed {
return
}
- proc ::feed::serve_generator_description {feeds publisher _ sock path query headers} {
-
+ proc ::feed::serve_generator_description {feeds publisher self_host _ sock path query headers} {
+ set feed_uris {}
+ foreach feed $feeds {
+ lappend feed_uris [::json::write object \
+ uri [::json::write string "at://$publisher/app.bsky.feed.generator/$feed"]]
+ }
+ set feed_uris [::json::write array {*}$feed_uris]
+ set description [::json::write object \
+ did [::json::write string "did:web:$self_host"] \
+ feeds $feed_uris]
+
+ puts $sock "HTTP/1.0 200 OK"
+ puts $sock "Content-Type: application/json"
+ puts $sock "Content-Length: [string length $description]"
+ puts $sock ""
+ fconfigure $sock -translation binary
+ puts -nonewline $sock $description
+ close $sock
+ return
}
}