mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-18 11:27:35 -06:00
[feature] Add domain permission drafts and excludes (#3547)
* [feature] Add domain permission drafts and excludes * fix typescript complaining * lint * make filenames more consistent * test own domain excluded
This commit is contained in:
parent
c2029df9bc
commit
301543616b
69 changed files with 5664 additions and 264 deletions
42
internal/cache/db.go
vendored
42
internal/cache/db.go
vendored
|
|
@ -67,6 +67,12 @@ type DBCaches struct {
|
|||
// DomainBlock provides access to the domain block database cache.
|
||||
DomainBlock *domain.Cache
|
||||
|
||||
// DomainPermissionDraft provides access to the domain permission draft database cache.
|
||||
DomainPermissionDraft StructCache[*gtsmodel.DomainPermissionDraft]
|
||||
|
||||
// DomainPermissionExclude provides access to the domain permission exclude database cache.
|
||||
DomainPermissionExclude *domain.Cache
|
||||
|
||||
// Emoji provides access to the gtsmodel Emoji database cache.
|
||||
Emoji StructCache[*gtsmodel.Emoji]
|
||||
|
||||
|
|
@ -548,6 +554,42 @@ func (c *Caches) initDomainBlock() {
|
|||
c.DB.DomainBlock = new(domain.Cache)
|
||||
}
|
||||
|
||||
func (c *Caches) initDomainPermissionDraft() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateResultCacheMax(
|
||||
sizeofDomainPermissionDraft(), // model in-mem size.
|
||||
config.GetCacheDomainPermissionDraftMemRation(),
|
||||
)
|
||||
|
||||
log.Infof(nil, "cache size = %d", cap)
|
||||
|
||||
copyF := func(d1 *gtsmodel.DomainPermissionDraft) *gtsmodel.DomainPermissionDraft {
|
||||
d2 := new(gtsmodel.DomainPermissionDraft)
|
||||
*d2 = *d1
|
||||
|
||||
// Don't include ptr fields that
|
||||
// will be populated separately.
|
||||
d2.CreatedByAccount = nil
|
||||
|
||||
return d2
|
||||
}
|
||||
|
||||
c.DB.DomainPermissionDraft.Init(structr.CacheConfig[*gtsmodel.DomainPermissionDraft]{
|
||||
Indices: []structr.IndexConfig{
|
||||
{Fields: "ID"},
|
||||
{Fields: "Domain", Multiple: true},
|
||||
{Fields: "SubscriptionID", Multiple: true},
|
||||
},
|
||||
MaxSize: cap,
|
||||
IgnoreErr: ignoreErrors,
|
||||
Copy: copyF,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initDomainPermissionExclude() {
|
||||
c.DB.DomainPermissionExclude = new(domain.Cache)
|
||||
}
|
||||
|
||||
func (c *Caches) initEmoji() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateResultCacheMax(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue