mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Process Reject
of interaction via fedi API, put rejected statuses in the "sin bin" 😈 (#3271)
* [feature] Process `Reject` of interaction via fedi API, put rejected statuses in the "sin bin" * update test * move nil check back to `rejectStatusIRI`
This commit is contained in:
2
internal/cache/cache.go
vendored
2
internal/cache/cache.go
vendored
@ -93,6 +93,7 @@ func (c *Caches) Init() {
|
||||
c.initPollVote()
|
||||
c.initPollVoteIDs()
|
||||
c.initReport()
|
||||
c.initSinBinStatus()
|
||||
c.initStatus()
|
||||
c.initStatusBookmark()
|
||||
c.initStatusBookmarkIDs()
|
||||
@ -170,6 +171,7 @@ func (c *Caches) Sweep(threshold float64) {
|
||||
c.DB.PollVote.Trim(threshold)
|
||||
c.DB.PollVoteIDs.Trim(threshold)
|
||||
c.DB.Report.Trim(threshold)
|
||||
c.DB.SinBinStatus.Trim(threshold)
|
||||
c.DB.Status.Trim(threshold)
|
||||
c.DB.StatusBookmark.Trim(threshold)
|
||||
c.DB.StatusBookmarkIDs.Trim(threshold)
|
||||
|
29
internal/cache/db.go
vendored
29
internal/cache/db.go
vendored
@ -145,6 +145,9 @@ type DBCaches struct {
|
||||
// Report provides access to the gtsmodel Report database cache.
|
||||
Report StructCache[*gtsmodel.Report]
|
||||
|
||||
// SinBinStatus provides access to the gtsmodel SinBinStatus database cache.
|
||||
SinBinStatus StructCache[*gtsmodel.SinBinStatus]
|
||||
|
||||
// Status provides access to the gtsmodel Status database cache.
|
||||
Status StructCache[*gtsmodel.Status]
|
||||
|
||||
@ -1170,6 +1173,32 @@ func (c *Caches) initReport() {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initSinBinStatus() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateResultCacheMax(
|
||||
sizeofSinBinStatus(), // model in-mem size.
|
||||
config.GetCacheSinBinStatusMemRatio(),
|
||||
)
|
||||
|
||||
log.Infof(nil, "cache size = %d", cap)
|
||||
|
||||
copyF := func(s1 *gtsmodel.SinBinStatus) *gtsmodel.SinBinStatus {
|
||||
s2 := new(gtsmodel.SinBinStatus)
|
||||
*s2 = *s1
|
||||
return s2
|
||||
}
|
||||
|
||||
c.DB.SinBinStatus.Init(structr.CacheConfig[*gtsmodel.SinBinStatus]{
|
||||
Indices: []structr.IndexConfig{
|
||||
{Fields: "ID"},
|
||||
{Fields: "URI"},
|
||||
},
|
||||
MaxSize: cap,
|
||||
IgnoreErr: ignoreErrors,
|
||||
Copy: copyF,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initStatus() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateResultCacheMax(
|
||||
|
23
internal/cache/size.go
vendored
23
internal/cache/size.go
vendored
@ -593,6 +593,29 @@ func sizeofReport() uintptr {
|
||||
}))
|
||||
}
|
||||
|
||||
func sizeofSinBinStatus() uintptr {
|
||||
return uintptr(size.Of(>smodel.SinBinStatus{
|
||||
ID: exampleID,
|
||||
CreatedAt: exampleTime,
|
||||
UpdatedAt: exampleTime,
|
||||
URI: exampleURI,
|
||||
URL: exampleURI,
|
||||
Domain: exampleURI,
|
||||
AccountURI: exampleURI,
|
||||
InReplyToURI: exampleURI,
|
||||
Content: exampleText,
|
||||
AttachmentLinks: []string{exampleURI, exampleURI},
|
||||
MentionTargetURIs: []string{exampleURI},
|
||||
EmojiLinks: []string{exampleURI},
|
||||
PollOptions: []string{exampleTextSmall, exampleTextSmall, exampleTextSmall, exampleTextSmall},
|
||||
ContentWarning: exampleTextSmall,
|
||||
Visibility: gtsmodel.VisibilityPublic,
|
||||
Sensitive: util.Ptr(false),
|
||||
Language: "en",
|
||||
ActivityStreamsType: ap.ObjectNote,
|
||||
}))
|
||||
}
|
||||
|
||||
func sizeofStatus() uintptr {
|
||||
return uintptr(size.Of(>smodel.Status{
|
||||
ID: exampleID,
|
||||
|
Reference in New Issue
Block a user