Skip to content

Commit 1888b7e

Browse files
authored
feat(bluesky): allow https:// URI also in getThread (#61)
* feat(bluesky): allow https:// URI also in getThread --------- Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
1 parent 62b98b9 commit 1888b7e

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

servlets/bluesky/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ func Call(input CallToolRequest) (CallToolResult, error) {
2525
return reply(input.Params.Arguments.(map[string]any))
2626
case "latest_mentions":
2727
return latestMentions(input.Params.Arguments.(map[string]any))
28+
case "search":
29+
return search(input.Params.Arguments.(map[string]any))
2830
case "get_thread":
2931
return getThread(input.Params.Arguments.(map[string]any))
3032
default:

servlets/bluesky/post.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ func getThread(args map[string]any) (CallToolResult, error) {
7474
if !ok {
7575
return callToolError("missing uri"), nil
7676
}
77+
// allow web URIs and conver them to AT URIs
78+
uri = webUriToAT(uri)
79+
pdk.Log(pdk.LogInfo, fmt.Sprintf("uri: %s", uri))
7780
depth, ok := args["depth"].(int)
7881
if !ok {
7982
depth = 6

servlets/bluesky/reply.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ func reply(args map[string]any) (CallToolResult, error) {
3737
// - https://bsky.app/profile/<DID>/post/<RKEY>
3838
// - at://<DID>/app.bsky.feed.post/<RKEY>
3939
func webUriToAT(uri string) string {
40-
if strings.HasPrefix(uri, "https://bsky.app/profile/") {
41-
parts := strings.Split(uri, "/")
42-
return fmt.Sprintf("at://%s/app.bsky.feed.post/%s", parts[3], parts[5])
40+
uriParts, err := parseURI(uri)
41+
if err != nil {
42+
return uri
4343
}
44-
return uri
44+
return fmt.Sprintf("at://%s/app.bsky.feed.post/%s", uriParts.Repo, uriParts.Rkey)
4545
}
4646

4747
type UriParts struct {

0 commit comments

Comments
 (0)