Class: NewsmastMastodon::Community

Inherits:
ApplicationRecord show all
Defined in:
app/models/newsmast_mastodon/community.rb

Constant Summary collapse

IMAGE_MIME_TYPES =
['image/svg+xml', 'image/png', 'image/jpeg', 'image/jpg', 'image/webp'].freeze
LIMIT =
2.megabytes

Class Method Summary collapse

Class Method Details

.default_privacy(user) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/newsmast_mastodon/community.rb', line 53

def self.default_privacy(user)
  return nil unless Object.const_defined?('NewsmastMastodon::CommunityAdmin')
  return nil unless defined?(NewsmastMastodon::CommunityAdmin) && NewsmastMastodon::CommunityAdmin.respond_to?(:find_by)

  admin = NewsmastMastodon::CommunityAdmin.find_by(
    account_id: user.,
    is_boost_bot: true,
    account_status: NewsmastMastodon::CommunityAdmin.['active']
  )
  return nil unless admin

  community = NewsmastMastodon::Community.find_by(id: admin.patchwork_community_id)
  return nil unless community&.content_type&.group_channel?

  case community.post_visibility
  when 'followers_only'
    'private'
  when 'public_visibility'
    'public'
  else
    community.post_visibility
  end
end