|
|
|
@ -1755,17 +1755,19 @@ func (cache *Cache) GroupBy(g GroupFunc) (res map[string]types.Twts) { |
|
|
|
|
return GroupTwtsBy(cache.GetAll(false), g) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetMentions ...
|
|
|
|
|
// XXX: To be removed once FeatureFilterAndLists is promoted
|
|
|
|
|
// TODO: Remove my when FeatureFilterAndLists is the default
|
|
|
|
|
func (cache *Cache) GetMentions(u *User, refresh bool) types.Twts { |
|
|
|
|
func (cache *Cache) getMentions(u *User, refresh bool, fffs ...FilterFuncFactory) types.Twts { |
|
|
|
|
key := fmt.Sprintf("mentions:%s", u.Username) |
|
|
|
|
|
|
|
|
|
cache.mu.RLock() |
|
|
|
|
cached, ok := cache.Views[key] |
|
|
|
|
cache.mu.RUnlock() |
|
|
|
|
|
|
|
|
|
if ok && !refresh { |
|
|
|
|
if cache.conf.Features.IsEnabled(FeatureFilterAndLists) { |
|
|
|
|
var ffs []FilterFunc |
|
|
|
|
for _, fff := range fffs { |
|
|
|
|
ffs = append(ffs, fff(cache, u)) |
|
|
|
|
} |
|
|
|
|
return FilterTwtsBy(cached.GetTwts(), ffs...) |
|
|
|
|
} |
|
|
|
|
return cached.GetTwts() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1773,13 +1775,29 @@ func (cache *Cache) GetMentions(u *User, refresh bool) types.Twts { |
|
|
|
|
twts := cache.filterTwts(u, mentions) |
|
|
|
|
sort.Sort(twts) |
|
|
|
|
|
|
|
|
|
cache.mu.Lock() |
|
|
|
|
cache.Views[key] = NewCachedTwts(twts, "") |
|
|
|
|
cache.mu.Unlock() |
|
|
|
|
|
|
|
|
|
if cache.conf.Features.IsEnabled(FeatureFilterAndLists) { |
|
|
|
|
var ffs []FilterFunc |
|
|
|
|
for _, fff := range fffs { |
|
|
|
|
ffs = append(ffs, fff(cache, u)) |
|
|
|
|
} |
|
|
|
|
return FilterTwtsBy(cached.GetTwts(), ffs...) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return twts |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetMentions ...
|
|
|
|
|
// XXX: To be removed once FeatureFilterAndLists is promoted
|
|
|
|
|
// TODO: Remove my when FeatureFilterAndLists is the default
|
|
|
|
|
func (cache *Cache) GetMentions(u *User, refresh bool, fffs ...FilterFuncFactory) types.Twts { |
|
|
|
|
cache.mu.Lock() |
|
|
|
|
defer cache.mu.Unlock() |
|
|
|
|
|
|
|
|
|
return cache.getMentions(u, refresh, fffs...) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// IsCached ...
|
|
|
|
|
func (cache *Cache) IsCached(url string) bool { |
|
|
|
|
cache.mu.RLock() |
|
|
|
|