From 2796a2e82f16ade9872008878cf88299bd66b4e7 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 31 Jul 2023 15:47:35 +0200 Subject: [feature] Hashtag federation (in/out), hashtag client API endpoints (#2032) * update go-fed * do the things * remove unused columns from tags * update to latest lingo from main * further tag shenanigans * serve stub page at tag endpoint * we did it lads * tests, oh tests, ohhh tests, oh tests (doo doo doo doo) * swagger docs * document hashtag usage + federation * instanceGet * don't bother parsing tag href * rename whereStartsWith -> whereStartsLike * remove GetOrCreateTag * dont cache status tag timelineability --- internal/cache/gts.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'internal/cache/gts.go') diff --git a/internal/cache/gts.go b/internal/cache/gts.go index fefd02fff..6014d13d4 100644 --- a/internal/cache/gts.go +++ b/internal/cache/gts.go @@ -47,6 +47,7 @@ type GTSCaches struct { report *result.Cache[*gtsmodel.Report] status *result.Cache[*gtsmodel.Status] statusFave *result.Cache[*gtsmodel.StatusFave] + tag *result.Cache[*gtsmodel.Tag] tombstone *result.Cache[*gtsmodel.Tombstone] user *result.Cache[*gtsmodel.User] @@ -78,6 +79,7 @@ func (c *GTSCaches) Init() { c.initReport() c.initStatus() c.initStatusFave() + c.initTag() c.initTombstone() c.initUser() c.initWebfinger() @@ -120,6 +122,7 @@ func (c *GTSCaches) Start() { tryStart(c.report, config.GetCacheGTSReportSweepFreq()) tryStart(c.status, config.GetCacheGTSStatusSweepFreq()) tryStart(c.statusFave, config.GetCacheGTSStatusFaveSweepFreq()) + tryStart(c.tag, config.GetCacheGTSTagSweepFreq()) tryStart(c.tombstone, config.GetCacheGTSTombstoneSweepFreq()) tryStart(c.user, config.GetCacheGTSUserSweepFreq()) tryUntil("starting *gtsmodel.Webfinger cache", 5, func() bool { @@ -167,6 +170,7 @@ func (c *GTSCaches) Stop() { tryStop(c.report, config.GetCacheGTSReportSweepFreq()) tryStop(c.status, config.GetCacheGTSStatusSweepFreq()) tryStop(c.statusFave, config.GetCacheGTSStatusFaveSweepFreq()) + tryStop(c.tag, config.GetCacheGTSTagSweepFreq()) tryStop(c.tombstone, config.GetCacheGTSTombstoneSweepFreq()) tryStop(c.user, config.GetCacheGTSUserSweepFreq()) tryUntil("stopping *gtsmodel.Webfinger cache", 5, func() bool { @@ -290,6 +294,11 @@ func (c *GTSCaches) StatusFave() *result.Cache[*gtsmodel.StatusFave] { return c.statusFave } +// Tag provides access to the gtsmodel Tag database cache. +func (c *GTSCaches) Tag() *result.Cache[*gtsmodel.Tag] { + return c.tag +} + // Tombstone provides access to the gtsmodel Tombstone database cache. func (c *GTSCaches) Tombstone() *result.Cache[*gtsmodel.Tombstone] { return c.tombstone @@ -568,6 +577,19 @@ func (c *GTSCaches) initStatusFave() { c.status.IgnoreErrors(ignoreErrors) } +func (c *GTSCaches) initTag() { + c.tag = result.New([]result.Lookup{ + {Name: "ID"}, + {Name: "Name"}, + }, func(m1 *gtsmodel.Tag) *gtsmodel.Tag { + m2 := new(gtsmodel.Tag) + *m2 = *m1 + return m2 + }, config.GetCacheGTSTagMaxSize()) + c.tag.SetTTL(config.GetCacheGTSTagTTL(), true) + c.tag.IgnoreErrors(ignoreErrors) +} + func (c *GTSCaches) initTombstone() { c.tombstone = result.New([]result.Lookup{ {Name: "ID"}, -- cgit v1.2.3