mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 17:02:25 -05:00
[feature] Create/update/remove domain permission subscriptions (#3623)
* [feature] Create/update/remove domain permission subscriptions * lint * envparsing * remove errant fmt.Println * create drafts, subs, exclude, from snapshot models * name etag column correctly * remove count column * lint
This commit is contained in:
parent
77f1e79532
commit
e9bb7ddd3a
50 changed files with 4630 additions and 172 deletions
34
internal/cache/db.go
vendored
34
internal/cache/db.go
vendored
|
|
@ -70,6 +70,9 @@ type DBCaches struct {
|
|||
// DomainPermissionDraft provides access to the domain permission draft database cache.
|
||||
DomainPermissionDraft StructCache[*gtsmodel.DomainPermissionDraft]
|
||||
|
||||
// DomainPermissionSubscription provides access to the domain permission subscription database cache.
|
||||
DomainPermissionSubscription StructCache[*gtsmodel.DomainPermissionSubscription]
|
||||
|
||||
// DomainPermissionExclude provides access to the domain permission exclude database cache.
|
||||
DomainPermissionExclude *domain.Cache
|
||||
|
||||
|
|
@ -589,6 +592,37 @@ func (c *Caches) initDomainPermissionDraft() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initDomainPermissionSubscription() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateResultCacheMax(
|
||||
sizeofDomainPermissionSubscription(), // model in-mem size.
|
||||
config.GetCacheDomainPermissionSubscriptionMemRation(),
|
||||
)
|
||||
|
||||
log.Infof(nil, "cache size = %d", cap)
|
||||
|
||||
copyF := func(d1 *gtsmodel.DomainPermissionSubscription) *gtsmodel.DomainPermissionSubscription {
|
||||
d2 := new(gtsmodel.DomainPermissionSubscription)
|
||||
*d2 = *d1
|
||||
|
||||
// Don't include ptr fields that
|
||||
// will be populated separately.
|
||||
d2.CreatedByAccount = nil
|
||||
|
||||
return d2
|
||||
}
|
||||
|
||||
c.DB.DomainPermissionSubscription.Init(structr.CacheConfig[*gtsmodel.DomainPermissionSubscription]{
|
||||
Indices: []structr.IndexConfig{
|
||||
{Fields: "ID"},
|
||||
{Fields: "URI"},
|
||||
},
|
||||
MaxSize: cap,
|
||||
IgnoreErr: ignoreErrors,
|
||||
Copy: copyF,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initDomainPermissionExclude() {
|
||||
c.DB.DomainPermissionExclude = new(domain.Cache)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue