Class: NewsmastMastodon::FeedService

Inherits:
Object
  • Object
show all
Includes:
Redisable
Defined in:
app/services/newsmast_mastodon/feed_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(account = nil) ⇒ FeedService

Returns a new instance of FeedService.



9
10
11
# File 'app/services/newsmast_mastodon/feed_service.rb', line 9

def initialize( = nil)
  @account = 
end

Instance Method Details

#excluded_status_idsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/services/newsmast_mastodon/feed_service.rb', line 19

def excluded_status_ids
  content_filter = NewsmastMastodon::ServerSetting.where(name: "Content filters").last
  spam_filter = NewsmastMastodon::ServerSetting.where(name: "Spam filters").last

  return [] unless content_filter && spam_filter

  if content_filter.value && spam_filter.value
    redis.zrange('excluded_status_ids', 0, -1)
  elsif content_filter.value
    redis.zrange('content_filters_banned_status_ids', 0, -1)
  elsif spam_filter.value
    redis.zrange('spam_filters_banned_status_ids', 0, -1)
  else
    []
  end
end

#federation_filter_by_server_settingObject



40
41
42
# File 'app/services/newsmast_mastodon/feed_service.rb', line 40

def federation_filter_by_server_setting
  Status.domain_filter_by_server_setting_scope(@account) if @account
end

#server_setting?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'app/services/newsmast_mastodon/feed_service.rb', line 13

def server_setting?
  content_filters = NewsmastMastodon::ServerSetting.where(name: "Content filters").last
  return false unless content_filters
  content_filters.value
end

#server_setting_federation?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/services/newsmast_mastodon/feed_service.rb', line 36

def server_setting_federation?
  NewsmastMastodon::ServerSetting.where(name: 'Threads', value: true).exists? || NewsmastMastodon::ServerSetting.where(name: 'Bluesky', value: true).exists? if @account
end