summaryrefslogtreecommitdiff
path: root/internal/transport/dereference.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/transport/dereference.go')
-rw-r--r--internal/transport/dereference.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/transport/dereference.go b/internal/transport/dereference.go
index 5ef6db9a7..61d99c5c5 100644
--- a/internal/transport/dereference.go
+++ b/internal/transport/dereference.go
@@ -23,10 +23,29 @@ import (
"net/url"
"github.com/sirupsen/logrus"
+ "github.com/spf13/viper"
+ "github.com/superseriousbusiness/gotosocial/internal/config"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
func (t *transport) Dereference(ctx context.Context, iri *url.URL) ([]byte, error) {
l := logrus.WithField("func", "Dereference")
+
+ // if the request is to us, we can shortcut for certain URIs rather than going through
+ // the normal request flow, thereby saving time and energy
+ if iri.Host == viper.GetString(config.Keys.Host) {
+ if uris.IsFollowersPath(iri) {
+ // the request is for followers of one of our accounts, which we can shortcut
+ return t.dereferenceFollowersShortcut(ctx, iri)
+ }
+
+ if uris.IsUserPath(iri) {
+ // the request is for one of our accounts, which we can shortcut
+ return t.dereferenceUserShortcut(ctx, iri)
+ }
+ }
+
+ // the request is either for a remote host or for us but we don't have a shortcut, so continue as normal
l.Debugf("performing GET to %s", iri.String())
return t.sigTransport.Dereference(ctx, iri)
}