summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb/inbox.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-11-13 17:29:43 +0100
committerLibravatar GitHub <noreply@github.com>2021-11-13 17:29:43 +0100
commit09ef9e639efa1b01005dcb7fc044611f277ad618 (patch)
treebef200f444b7ddd90f2b9f0fcff644da7cd85a11 /internal/federation/federatingdb/inbox.go
parentupdate dependencies (#296) (diff)
downloadgotosocial-09ef9e639efa1b01005dcb7fc044611f277ad618.tar.xz
move to ssb gofed fork (#298)
Diffstat (limited to 'internal/federation/federatingdb/inbox.go')
-rw-r--r--internal/federation/federatingdb/inbox.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/internal/federation/federatingdb/inbox.go b/internal/federation/federatingdb/inbox.go
index 95886b571..90a10a499 100644
--- a/internal/federation/federatingdb/inbox.go
+++ b/internal/federation/federatingdb/inbox.go
@@ -22,8 +22,9 @@ import (
"context"
"net/url"
- "github.com/go-fed/activity/streams"
- "github.com/go-fed/activity/streams/vocab"
+ "github.com/superseriousbusiness/activity/streams"
+ "github.com/superseriousbusiness/activity/streams/vocab"
+ "github.com/superseriousbusiness/gotosocial/internal/db"
)
// InboxContains returns true if the OrderedCollection at 'inbox'
@@ -56,3 +57,25 @@ func (f *federatingDB) GetInbox(c context.Context, inboxIRI *url.URL) (inbox voc
func (f *federatingDB) SetInbox(c context.Context, inbox vocab.ActivityStreamsOrderedCollectionPage) error {
return nil
}
+
+// InboxForActor fetches the inbox corresponding to the given actorIRI.
+//
+// It is acceptable to just return nil for the inboxIRI. In this case, the library will
+// attempt to resolve the inbox of the actor by remote dereferencing instead.
+//
+// The library makes this call only after acquiring a lock first.
+func (f *federatingDB) InboxForActor(c context.Context, actorIRI *url.URL) (inboxIRI *url.URL, err error) {
+ account, err := f.db.GetAccountByURI(c, actorIRI.String())
+ if err != nil {
+ // if there are just no entries for this account yet it's fine, return nil
+ // and go-fed will try to dereference it instead
+ if err == db.ErrNoEntries {
+ return nil, nil
+ }
+ // there's been an actual error...
+ return nil, err
+ }
+
+ // we got it!
+ return url.Parse(account.InboxURI)
+}