summaryrefslogtreecommitdiff
path: root/internal/util
diff options
context:
space:
mode:
Diffstat (limited to 'internal/util')
-rw-r--r--internal/util/uri.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/util/uri.go b/internal/util/uri.go
index edcfc5c02..cee9dcbaa 100644
--- a/internal/util/uri.go
+++ b/internal/util/uri.go
@@ -22,6 +22,8 @@ import (
"fmt"
"net/url"
"strings"
+
+ "github.com/google/uuid"
)
const (
@@ -47,6 +49,8 @@ const (
FeaturedPath = "featured"
// PublicKeyPath is for serving an account's public key
PublicKeyPath = "main-key"
+ // FollowPath used to generate the URI for an individual follow or follow request
+ FollowPath = "follow"
)
// APContextKey is a type used specifically for settings values on contexts within go-fed AP request chains
@@ -103,6 +107,12 @@ type UserURIs struct {
PublicKeyURI string
}
+// GenerateURIForFollow returns the AP URI for a new follow -- something like:
+// https://example.org/users/whatever_user/follow/41c7f33f-1060-48d9-84df-38dcb13cf0d8
+func GenerateURIForFollow(username string, protocol string, host string) string {
+ return fmt.Sprintf("%s://%s/%s/%s/%s", protocol, host, UsersPath, FollowPath, uuid.NewString())
+}
+
// GenerateURIsForAccount throws together a bunch of URIs for the given username, with the given protocol and host.
func GenerateURIsForAccount(username string, protocol string, host string) *UserURIs {
// The below URLs are used for serving web requests