mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-01-29 04:06:41 +01:00
Merge branch 'main' into delivery_recipient_pre_sort
This commit is contained in:
commit
f88c398423
6 changed files with 29 additions and 23 deletions
28
internal/cache/cache.go
vendored
28
internal/cache/cache.go
vendored
|
@ -40,6 +40,11 @@ type Caches struct {
|
||||||
// the block []headerfilter.Filter cache.
|
// the block []headerfilter.Filter cache.
|
||||||
BlockHeaderFilters headerfilter.Cache
|
BlockHeaderFilters headerfilter.Cache
|
||||||
|
|
||||||
|
// TTL cache of statuses -> filterable text fields.
|
||||||
|
// To ensure up-to-date fields, cache is keyed as:
|
||||||
|
// `[status.ID][status.UpdatedAt.Unix()]`
|
||||||
|
StatusesFilterableFields *ttl.Cache[string, []string]
|
||||||
|
|
||||||
// Visibility provides access to the item visibility
|
// Visibility provides access to the item visibility
|
||||||
// cache. (used by the visibility filter).
|
// cache. (used by the visibility filter).
|
||||||
Visibility VisibilityCache
|
Visibility VisibilityCache
|
||||||
|
@ -47,11 +52,6 @@ type Caches struct {
|
||||||
// Webfinger provides access to the webfinger URL cache.
|
// Webfinger provides access to the webfinger URL cache.
|
||||||
Webfinger *ttl.Cache[string, string] // TTL=24hr, sweep=5min
|
Webfinger *ttl.Cache[string, string] // TTL=24hr, sweep=5min
|
||||||
|
|
||||||
// TTL cache of statuses -> filterable text fields.
|
|
||||||
// To ensure up-to-date fields, cache is keyed as:
|
|
||||||
// `[status.ID][status.UpdatedAt.Unix()]`
|
|
||||||
StatusesFilterableFields *ttl.Cache[string, []string]
|
|
||||||
|
|
||||||
// prevent pass-by-value.
|
// prevent pass-by-value.
|
||||||
_ nocopy
|
_ nocopy
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,15 @@ func (c *Caches) Sweep(threshold float64) {
|
||||||
c.Visibility.Trim(threshold)
|
c.Visibility.Trim(threshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Caches) initStatusesFilterableFields() {
|
||||||
|
c.StatusesFilterableFields = new(ttl.Cache[string, []string])
|
||||||
|
c.StatusesFilterableFields.Init(
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
1*time.Hour,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Caches) initWebfinger() {
|
func (c *Caches) initWebfinger() {
|
||||||
// Calculate maximum cache size.
|
// Calculate maximum cache size.
|
||||||
cap := calculateCacheMax(
|
cap := calculateCacheMax(
|
||||||
|
@ -219,12 +228,3 @@ func (c *Caches) initWebfinger() {
|
||||||
24*time.Hour,
|
24*time.Hour,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Caches) initStatusesFilterableFields() {
|
|
||||||
c.StatusesFilterableFields = new(ttl.Cache[string, []string])
|
|
||||||
c.StatusesFilterableFields.Init(
|
|
||||||
0,
|
|
||||||
512,
|
|
||||||
1*time.Hour,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
|
@ -63,6 +63,10 @@ func (f *federatingDB) Create(ctx context.Context, asType vocab.Type) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cache entry for this create activity ID for later
|
||||||
|
// checks in the Exist() function if we see it again.
|
||||||
|
f.activityIDs.Set(ap.GetJSONLDId(asType).String(), struct{}{})
|
||||||
|
|
||||||
switch name := asType.GetTypeName(); name {
|
switch name := asType.GetTypeName(); name {
|
||||||
case ap.ActivityBlock:
|
case ap.ActivityBlock:
|
||||||
// BLOCK SOMETHING
|
// BLOCK SOMETHING
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
"context"
|
"context"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"codeberg.org/gruf/go-cache/v3/simple"
|
||||||
"github.com/superseriousbusiness/activity/pub"
|
"github.com/superseriousbusiness/activity/pub"
|
||||||
"github.com/superseriousbusiness/activity/streams/vocab"
|
"github.com/superseriousbusiness/activity/streams/vocab"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/filter/interaction"
|
"github.com/superseriousbusiness/gotosocial/internal/filter/interaction"
|
||||||
|
@ -61,6 +62,10 @@ type federatingDB struct {
|
||||||
visFilter *visibility.Filter
|
visFilter *visibility.Filter
|
||||||
intFilter *interaction.Filter
|
intFilter *interaction.Filter
|
||||||
spamFilter *spam.Filter
|
spamFilter *spam.Filter
|
||||||
|
|
||||||
|
// tracks Activity IDs we have handled creates for,
|
||||||
|
// for use in the Exists() function during forwarding.
|
||||||
|
activityIDs simple.Cache[string, struct{}]
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a DB that satisfies the pub.Database
|
// New returns a DB that satisfies the pub.Database
|
||||||
|
@ -79,5 +84,6 @@ func New(
|
||||||
intFilter: intFilter,
|
intFilter: intFilter,
|
||||||
spamFilter: spamFilter,
|
spamFilter: spamFilter,
|
||||||
}
|
}
|
||||||
|
fdb.activityIDs.Init(0, 2048)
|
||||||
return &fdb
|
return &fdb
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,8 @@
|
||||||
"net/url"
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Exists returns true if the database has an entry for the specified
|
// Exists is an implementation of pub.Database{}.Exists(), optimized specifically for
|
||||||
// id. It may not be owned by this application instance.
|
// the only usecase in which go-fed/activity/pub actually calls it. Do not use otherwise!
|
||||||
//
|
|
||||||
// The library makes this call only after acquiring a lock first.
|
|
||||||
//
|
|
||||||
// Implementation note: this just straight up isn't implemented, and doesn't *really* need to be either.
|
|
||||||
func (f *federatingDB) Exists(ctx context.Context, id *url.URL) (exists bool, err error) {
|
func (f *federatingDB) Exists(ctx context.Context, id *url.URL) (exists bool, err error) {
|
||||||
return false, nil
|
return f.activityIDs.Has(id.String()), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
var _ interface {
|
var _ interface {
|
||||||
pub.CommonBehavior
|
pub.CommonBehavior
|
||||||
pub.FederatingProtocol
|
pub.FederatingProtocol
|
||||||
} = &Federator{}
|
} = (*Federator)(nil)
|
||||||
|
|
||||||
type Federator struct {
|
type Federator struct {
|
||||||
db db.DB
|
db db.DB
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
// Note that the library will not maintain a long-lived pointer to the
|
// Note that the library will not maintain a long-lived pointer to the
|
||||||
// returned Transport so that any private credentials are able to be
|
// returned Transport so that any private credentials are able to be
|
||||||
// garbage collected.
|
// garbage collected.
|
||||||
func (f *Federator) NewTransport(ctx context.Context, actorBoxIRI *url.URL, gofedAgent string) (pub.Transport, error) {
|
func (f *Federator) NewTransport(ctx context.Context, actorBoxIRI *url.URL, _ string) (pub.Transport, error) {
|
||||||
var username string
|
var username string
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue