summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2023-03-09 18:55:45 +0100
committerLibravatar GitHub <noreply@github.com>2023-03-09 17:55:45 +0000
commita312238e7909c6451e608a91c326ad250dda875c (patch)
tree1395a27178a7ffd78486e3ddb00cd29dfce27cd8 /internal/processing
parent[bug] Handle 410 on webfinger properly (#1601) (diff)
downloadgotosocial-a312238e7909c6451e608a91c326ad250dda875c.tar.xz
[feature] Provide .well-known/host-meta endpoint (#1604)
* [feature] Provide .well-known/host-meta endpoint This adds the host-meta endpoint as Mastodon clients use this to discover the API domain to use when the host and account domains aren't the same. * Address review comments
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/fedi/wellknown.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/processing/fedi/wellknown.go b/internal/processing/fedi/wellknown.go
index 6f113ac5d..7be75649b 100644
--- a/internal/processing/fedi/wellknown.go
+++ b/internal/processing/fedi/wellknown.go
@@ -28,6 +28,10 @@ import (
)
const (
+ hostMetaXMLNS = "http://docs.oasis-open.org/ns/xri/xrd-1.0"
+ hostMetaRel = "lrdd"
+ hostMetaType = "application/xrd+xml"
+ hostMetaTemplate = ".well-known/webfinger?resource={uri}"
nodeInfoVersion = "2.0"
nodeInfoSoftwareName = "gotosocial"
nodeInfoRel = "http://nodeinfo.diaspora.software/ns/schema/" + nodeInfoVersion
@@ -96,6 +100,22 @@ func (p *Processor) NodeInfoGet(ctx context.Context) (*apimodel.Nodeinfo, gtserr
}, nil
}
+// HostMetaGet returns a host-meta struct in response to a host-meta request.
+func (p *Processor) HostMetaGet() *apimodel.HostMeta {
+ protocol := config.GetProtocol()
+ host := config.GetHost()
+ return &apimodel.HostMeta{
+ XMLNS: hostMetaXMLNS,
+ Link: []apimodel.Link{
+ {
+ Rel: hostMetaRel,
+ Type: hostMetaType,
+ Template: fmt.Sprintf("%s://%s/%s", protocol, host, hostMetaTemplate),
+ },
+ },
+ }
+}
+
// WebfingerGet handles the GET for a webfinger resource. Most commonly, it will be used for returning account lookups.
func (p *Processor) WebfingerGet(ctx context.Context, requestedUsername string) (*apimodel.WellKnownResponse, gtserror.WithCode) {
// Get the local account the request is referring to.