diff --git a/internal/node/component/federated/transformer_social_type.go b/internal/node/component/federated/transformer_social_type.go index 68ae0b0e..a73ec469 100644 --- a/internal/node/component/federated/transformer_social_type.go +++ b/internal/node/component/federated/transformer_social_type.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "github.com/rss3-network/node/schema/worker/federated" "github.com/rss3-network/protocol-go/schema/activity" "github.com/rss3-network/protocol-go/schema/metadata" "github.com/rss3-network/protocol-go/schema/network" @@ -15,7 +16,7 @@ import ( // TransformSocialType adds author url and note url to social actions based on type, network and platform func (c *Component) TransformSocialType(ctx context.Context, network network.Network, platform string, action activity.Action) (activity.Action, error) { switch action.Type { - case typex.SocialPost, typex.SocialComment, typex.SocialShare: + case typex.SocialPost, typex.SocialComment, typex.SocialShare, typex.SocialLike: return c.TransformSocialPost(ctx, network, platform, action) } @@ -55,14 +56,21 @@ func (c *Component) buildSocialAuthorURL(_ context.Context, platform, handle str return "" } - parts := strings.SplitN(handle, "@", 3) - if len(parts) != 3 { - return "" - } + switch platform { + case federated.PlatformMastodon.String(): + parts := strings.SplitN(handle, "@", 3) + if len(parts) != 3 { + return "" + } - username, domain := parts[1], parts[2] + username, domain := parts[1], parts[2] - return fmt.Sprintf("https://%s/users/%s", domain, username) + return fmt.Sprintf("https://%s/users/%s", domain, username) + case federated.PlatformBluesky.String(): + return fmt.Sprintf("https://bsky.app/profile/%s", handle) + default: + return "" + } } // buildSocialNoteURL returns note url based on domain, handle, profileID and pubID @@ -71,12 +79,19 @@ func (c *Component) buildSocialNoteURL(_ context.Context, _ network.Network, pla return "" } - parts := strings.SplitN(handle, "@", 3) - if len(parts) != 3 { - return "" - } + switch platform { + case federated.PlatformMastodon.String(): + parts := strings.SplitN(handle, "@", 3) + if len(parts) != 3 { + return "" + } - username, domain := parts[1], parts[2] + username, domain := parts[1], parts[2] - return fmt.Sprintf("https://%s/users/%s/statuses/%s", domain, username, pubID) + return fmt.Sprintf("https://%s/users/%s/statuses/%s", domain, username, pubID) + case federated.PlatformBluesky.String(): + return fmt.Sprintf("https://bsky.app/profile/%s/post/%s", handle, pubID) + default: + return "" + } }