mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-28 10:00:31 +00:00
2dc9fc1626
* start moving to bun * changing more stuff * more * and yet more * tests passing * seems stable now * more big changes * small fix * little fixes
89 lines
3 KiB
Go
89 lines
3 KiB
Go
/*
|
|
GoToSocial
|
|
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package federatingdb
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"github.com/go-fed/activity/streams"
|
|
"github.com/go-fed/activity/streams/vocab"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/superseriousbusiness/gotosocial/internal/db"
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
|
"github.com/superseriousbusiness/gotosocial/internal/util"
|
|
)
|
|
|
|
// GetOutbox returns the first ordered collection page of the outbox
|
|
// at the specified IRI, for prepending new items.
|
|
//
|
|
// The library makes this call only after acquiring a lock first.
|
|
func (f *federatingDB) GetOutbox(ctx context.Context, outboxIRI *url.URL) (inbox vocab.ActivityStreamsOrderedCollectionPage, err error) {
|
|
l := f.log.WithFields(
|
|
logrus.Fields{
|
|
"func": "GetOutbox",
|
|
},
|
|
)
|
|
l.Debug("entering GETOUTBOX function")
|
|
|
|
return streams.NewActivityStreamsOrderedCollectionPage(), nil
|
|
}
|
|
|
|
// SetOutbox saves the outbox value given from GetOutbox, with new items
|
|
// prepended. Note that the new items must not be added as independent
|
|
// database entries. Separate calls to Create will do that.
|
|
//
|
|
// The library makes this call only after acquiring a lock first.
|
|
func (f *federatingDB) SetOutbox(ctx context.Context, outbox vocab.ActivityStreamsOrderedCollectionPage) error {
|
|
l := f.log.WithFields(
|
|
logrus.Fields{
|
|
"func": "SetOutbox",
|
|
},
|
|
)
|
|
l.Debug("entering SETOUTBOX function")
|
|
|
|
return nil
|
|
}
|
|
|
|
// OutboxForInbox fetches the corresponding actor's outbox IRI for the
|
|
// actor's inbox IRI.
|
|
//
|
|
// The library makes this call only after acquiring a lock first.
|
|
func (f *federatingDB) OutboxForInbox(ctx context.Context, inboxIRI *url.URL) (outboxIRI *url.URL, err error) {
|
|
l := f.log.WithFields(
|
|
logrus.Fields{
|
|
"func": "OutboxForInbox",
|
|
"inboxIRI": inboxIRI.String(),
|
|
},
|
|
)
|
|
l.Debugf("entering OUTBOXFORINBOX function with inboxIRI %s", inboxIRI.String())
|
|
|
|
if !util.IsInboxPath(inboxIRI) {
|
|
return nil, fmt.Errorf("%s is not an inbox URI", inboxIRI.String())
|
|
}
|
|
acct := >smodel.Account{}
|
|
if err := f.db.GetWhere(ctx, []db.Where{{Key: "inbox_uri", Value: inboxIRI.String()}}, acct); err != nil {
|
|
if err == db.ErrNoEntries {
|
|
return nil, fmt.Errorf("no actor found that corresponds to inbox %s", inboxIRI.String())
|
|
}
|
|
return nil, fmt.Errorf("db error searching for actor with inbox %s", inboxIRI.String())
|
|
}
|
|
return url.Parse(acct.OutboxURI)
|
|
}
|