Skip to content

Commit

Permalink
Merge pull request #10 from participating-online/9-update-user-endpoi…
Browse files Browse the repository at this point in the history
…nts-to-u-instead-of-users

Update user URLs
  • Loading branch information
lazyguru authored Dec 6, 2023
2 parents a477dbd + 193fdf9 commit 7e4f2a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions internal/activitypub/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ type User struct {
Endpoints Endpoints `json:"endpoints"`
}

func NewUser(name string, matrixUserId string, bio string, publickey string, Hostname string) User {
func NewUser(
name string,
matrixUserId string,
bio string,
publickey string,
Hostname string,
) User {
user := User{}
user.Context = GetContext()
user.Id = fmt.Sprintf("https://%s/users/%s", Hostname, name)
user.Id = fmt.Sprintf("https://%s/u/%s", Hostname, name)
user.PreferredUsername = name
user.Inbox = fmt.Sprintf("https://%s/users/%s/inbox", Hostname, name)
user.Outbox = fmt.Sprintf("https://%s/users/%s/outbox", Hostname, name)
user.Inbox = fmt.Sprintf("https://%s/u/%s/inbox", Hostname, name)
user.Outbox = fmt.Sprintf("https://%s/u/%s/outbox", Hostname, name)
user.Type = "Person"
user.Summary = bio
user.MatrixUserId = matrixUserId
owner := fmt.Sprintf("https://%s/users/%s", Hostname, name)
owner := fmt.Sprintf("https://%s/u/%s", Hostname, name)
user.Publickey = PublicKey{
Keyid: fmt.Sprintf("https://%s/users/%s#main-key", Hostname, name),
Keyid: fmt.Sprintf("https://%s/u/%s#main-key", Hostname, name),
Owner: owner,
PublicKeyPem: publickey,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/http/routes/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func SetupUserRoutes(r *mux.Router) {
r.HandleFunc("/users/{user}", getUserInfoHandler).Methods("GET")
r.HandleFunc("/u/{user}", getUserInfoHandler).Methods("GET")
}

func getUserInfoHandler(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 7e4f2a2

Please sign in to comment.