From f038eb73d7b357baa8b1e635c5eeb739cd484fbd Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 29 Nov 2024 23:13:53 +0200 Subject: [PATCH] Add support for Bluesky --- README.md | 2 ++ api/gitlab/build.go | 4 ++-- bridgeconfig/bluesky.tpl.yaml | 14 ++++++++++++++ cmd/bbctl/bridgeutil.go | 2 ++ cmd/bbctl/config.go | 3 ++- cmd/bbctl/run.go | 2 +- cmd/bbctl/whoami.go | 1 + 7 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 bridgeconfig/bluesky.tpl.yaml diff --git a/README.md b/README.md index cd4d49e..cd21a44 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ used with the `--type` flag. | [mautrix-meta] | meta, instagram, facebook | | [mautrix-googlechat] | googlechat, gchat | | [mautrix-twitter] | twitter | +| [mautrix-bluesky] | bluesky | | [mautrix-imessage] | imessage | | [beeper-imessage] | imessagego | | [linkedin-matrix] | linkedin | @@ -107,6 +108,7 @@ used with the `--type` flag. [mautrix-instagram]: https://github.com/mautrix/instagram [mautrix-googlechat]: https://github.com/mautrix/googlechat [mautrix-twitter]: https://github.com/mautrix/twitter +[mautrix-bluesky]: https://github.com/mautrix/bluesky [mautrix-imessage]: https://github.com/mautrix/imessage [beeper-imessage]: https://github.com/beeper/imessage [linkedin-matrix]: https://github.com/beeper/linkedin diff --git a/api/gitlab/build.go b/api/gitlab/build.go index 5e9c8f2..1616fb1 100644 --- a/api/gitlab/build.go +++ b/api/gitlab/build.go @@ -70,7 +70,7 @@ func getRefFromBridge(bridge string) (string, error) { switch bridge { case "imessage": return "master", nil - case "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta", "twitter": + case "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta", "twitter", "bluesky": return "main", nil default: return "", fmt.Errorf("unknown bridge %s", bridge) @@ -165,7 +165,7 @@ func downloadFile(ctx context.Context, artifactURL, path string) error { func needsLibolmDylib(bridge string) bool { switch bridge { - case "imessage", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta", "twitter": + case "imessage", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta", "twitter", "bluesky": return runtime.GOOS == "darwin" default: return false diff --git a/bridgeconfig/bluesky.tpl.yaml b/bridgeconfig/bluesky.tpl.yaml new file mode 100644 index 0000000..e20bd6a --- /dev/null +++ b/bridgeconfig/bluesky.tpl.yaml @@ -0,0 +1,14 @@ +# Network-specific config options +network: + # Displayname template for Bluesky users. Available variables: + # .DisplayName - displayname set by the user. Not required, may be empty. + # .Handle - username (domain) of the user. Always present. + # .DID - internal user ID starting with `did:`. Always present. + displayname_template: {{ `"{{or .DisplayName .Handle}}"` }} + +{{ setfield . "CommandPrefix" "!bsky" -}} +{{ setfield . "DatabaseFileName" "mautrix-bluesky" -}} +{{ setfield . "BridgeTypeName" "Bluesky" -}} +{{ setfield . "BridgeTypeIcon" "mxc://maunium.net/ezAjjDxhiJWGEohmhkpfeHYf" -}} +{{ setfield . "DefaultPickleKey" "go.mau.fi/mautrix-bluesky" -}} +{{ template "bridgev2.tpl.yaml" . }} diff --git a/cmd/bbctl/bridgeutil.go b/cmd/bbctl/bridgeutil.go index 3606775..d19c4fd 100644 --- a/cmd/bbctl/bridgeutil.go +++ b/cmd/bbctl/bridgeutil.go @@ -35,6 +35,7 @@ var officialBridges = []bridgeTypeToNames{ {"heisenbridge", []string{"irc", "heisenbridge"}}, {"gmessages", []string{"gmessages", "googlemessages", "rcs", "sms"}}, {"gvoice", []string{"gvoice", "googlevoice"}}, + {"bluesky", []string{"bluesky", "bsky"}}, } var websocketBridges = map[string]bool{ @@ -50,6 +51,7 @@ var websocketBridges = map[string]bool{ "bridgev2": true, "meta": true, "twitter": true, + "bluesky": true, } func doOutputFile(ctx *cli.Context, name, data string) error { diff --git a/cmd/bbctl/config.go b/cmd/bbctl/config.go index dbf4a94..fdd755c 100644 --- a/cmd/bbctl/config.go +++ b/cmd/bbctl/config.go @@ -218,6 +218,7 @@ var bridgeIPSuffix = map[string]string{ "gmessages": "36", "imessagego": "37", "gvoice": "38", + "bluesky": "40", } func doGenerateBridgeConfig(ctx *cli.Context, bridge string) (*generatedBridgeConfig, error) { @@ -344,7 +345,7 @@ func generateBridgeConfig(ctx *cli.Context) error { } var startupCommand, installInstructions string switch cfg.BridgeType { - case "imessage", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "meta", "twitter": + case "imessage", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "meta", "twitter", "bluesky": startupCommand = fmt.Sprintf("mautrix-%s", cfg.BridgeType) if outputPath != "config.yaml" && outputPath != "" { startupCommand += " -c " + outputPath diff --git a/cmd/bbctl/run.go b/cmd/bbctl/run.go index b50b8f5..8a93114 100644 --- a/cmd/bbctl/run.go +++ b/cmd/bbctl/run.go @@ -316,7 +316,7 @@ func runBridge(ctx *cli.Context) error { var bridgeArgs []string var needsWebsocketProxy bool switch cfg.BridgeType { - case "imessage", "imessagego", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "meta", "twitter": + case "imessage", "imessagego", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "meta", "twitter", "bluesky": binaryName := fmt.Sprintf("mautrix-%s", cfg.BridgeType) ciV2 := false switch cfg.BridgeType { diff --git a/cmd/bbctl/whoami.go b/cmd/bbctl/whoami.go index 7ab8360..1b05a32 100644 --- a/cmd/bbctl/whoami.go +++ b/cmd/bbctl/whoami.go @@ -92,6 +92,7 @@ var dockerToGitRepo = map[string]string{ "telegram": "https://github.com/mautrix/telegram/commit/%s", "telegramgo": "https://github.com/mautrix/telegramgo/commit/%s", "twitter": "https://github.com/mautrix/twitter/commit/%s", + "bluesky": "https://github.com/mautrix/bluesky/commit/%s", "whatsapp": "https://github.com/mautrix/whatsapp/commit/%s", }