diff --git a/internal/activitypub/user.go b/internal/activitypub/user.go index f75fd73..1433e73 100644 --- a/internal/activitypub/user.go +++ b/internal/activitypub/user.go @@ -2,15 +2,10 @@ package activitypub import ( "fmt" - "os" "participating-online/sublinks-federation/internal/lemmy" "time" ) -var host, _ = os.LookupEnv("HOSTNAME") -var domain, _ = os.LookupEnv("CSB_BASE_PREVIEW_HOST") -var Hostname string = fmt.Sprintf("%s-8080.%s", host, domain) - type PublicKey struct { Keyid string `json:"id"` Owner string `json:"owner"` @@ -38,7 +33,7 @@ type User struct { Endpoints Endpoints `json:"endpoints"` } -func NewUser(name string, matrixUserId string, bio string, publickey 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) @@ -59,11 +54,12 @@ func NewUser(name string, matrixUserId string, bio string, publickey string) Use return user } -func ConvertUserToApub(u *lemmy.UserResponse) User { +func ConvertUserToApub(u *lemmy.UserResponse, host string) User { return NewUser( u.PersonView.Person.Name, u.PersonView.Person.MatrixUserId, u.PersonView.Person.Bio, "", //TODO: Public key goes here + host, ) } diff --git a/internal/http/routes/user.go b/internal/http/routes/user.go index e63bc79..4f1f881 100644 --- a/internal/http/routes/user.go +++ b/internal/http/routes/user.go @@ -27,7 +27,7 @@ func getUserInfoHandler(w http.ResponseWriter, r *http.Request) { return } - userLd := activitypub.ConvertUserToApub(user) + userLd := activitypub.ConvertUserToApub(user, r.Host) w.WriteHeader(http.StatusOK) w.Header().Add("content-type", "application/activity+json") content, _ := json.MarshalIndent(userLd, "", " ")