diff options
author | 2021-05-09 20:34:27 +0200 | |
---|---|---|
committer | 2021-05-09 20:34:27 +0200 | |
commit | dc338dc881ead40723f0540aac7fe894f58b174d (patch) | |
tree | a000a065ffe219683f68520dd66b12aa1506a9fa /internal/message/fediprocess.go | |
parent | Fix token sweep (#19) (diff) | |
download | gotosocial-dc338dc881ead40723f0540aac7fe894f58b174d.tar.xz |
Webfinger + Small fixes (#20)
Diffstat (limited to 'internal/message/fediprocess.go')
-rw-r--r-- | internal/message/fediprocess.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/message/fediprocess.go b/internal/message/fediprocess.go index 6dc6330cf..dad1e848c 100644 --- a/internal/message/fediprocess.go +++ b/internal/message/fediprocess.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/go-fed/activity/streams" + apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" ) @@ -100,3 +101,32 @@ func (p *processor) GetFediUser(requestedUsername string, request *http.Request) return data, nil } + +func (p *processor) GetWebfingerAccount(requestedUsername string, request *http.Request) (*apimodel.WebfingerAccountResponse, ErrorWithCode) { + // get the account the request is referring to + requestedAccount := >smodel.Account{} + if err := p.db.GetLocalAccountByUsername(requestedUsername, requestedAccount); err != nil { + return nil, NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err)) + } + + // return the webfinger representation + return &apimodel.WebfingerAccountResponse{ + Subject: fmt.Sprintf("acct:%s@%s", requestedAccount.Username, p.config.Host), + Aliases: []string{ + requestedAccount.URI, + requestedAccount.URL, + }, + Links: []apimodel.WebfingerLink{ + { + Rel: "http://webfinger.net/rel/profile-page", + Type: "text/html", + Href: requestedAccount.URL, + }, + { + Rel: "self", + Type: "application/activity+json", + Href: requestedAccount.URI, + }, + }, + }, nil +} |