summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb/get.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-01-27 14:48:11 +0100
committerLibravatar GitHub <noreply@github.com>2023-01-27 14:48:11 +0100
commit3283900b0d0b98e5ca956f61ce09ab373cf0cbe8 (patch)
treef7dc654ea2d510e0c02d63d8a174908f1e25c680 /internal/federation/federatingdb/get.go
parent[docs] Add Flag documentation to federation docs (#1393) (diff)
downloadgotosocial-3283900b0d0b98e5ca956f61ce09ab373cf0cbe8.tar.xz
[feature] Federate reports to remote instance as Flag (if desired) (#1386)
* reports federate out, we did it lxds * fix optional line start (should be optional slash)
Diffstat (limited to 'internal/federation/federatingdb/get.go')
-rw-r--r--internal/federation/federatingdb/get.go25
1 files changed, 9 insertions, 16 deletions
diff --git a/internal/federation/federatingdb/get.go b/internal/federation/federatingdb/get.go
index 24f3ddb51..a55cb0280 100644
--- a/internal/federation/federatingdb/get.go
+++ b/internal/federation/federatingdb/get.go
@@ -20,7 +20,7 @@ package federatingdb
import (
"context"
- "errors"
+ "fmt"
"net/url"
"codeberg.org/gruf/go-kv"
@@ -33,34 +33,27 @@ import (
//
// The library makes this call only after acquiring a lock first.
func (f *federatingDB) Get(ctx context.Context, id *url.URL) (value vocab.Type, err error) {
- l := log.WithFields(kv.Fields{
- {"id", id},
- }...)
+ l := log.WithFields(kv.Fields{{"id", id}}...)
l.Debug("entering Get")
- if uris.IsUserPath(id) {
+ switch {
+ case uris.IsUserPath(id):
acct, err := f.db.GetAccountByURI(ctx, id.String())
if err != nil {
return nil, err
}
return f.typeConverter.AccountToAS(ctx, acct)
- }
-
- if uris.IsStatusesPath(id) {
+ case uris.IsStatusesPath(id):
status, err := f.db.GetStatusByURI(ctx, id.String())
if err != nil {
return nil, err
}
return f.typeConverter.StatusToAS(ctx, status)
- }
-
- if uris.IsFollowersPath(id) {
+ case uris.IsFollowersPath(id):
return f.Followers(ctx, id)
- }
-
- if uris.IsFollowingPath(id) {
+ case uris.IsFollowingPath(id):
return f.Following(ctx, id)
+ default:
+ return nil, fmt.Errorf("federatingDB: could not Get %s", id.String())
}
-
- return nil, errors.New("could not get")
}