mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 01:33:45 +08:00
b3238bfc34
Now forums can enroll their sites to be showcased in the Discourse [Discover](https://discourse.org/discover) directory. Once they enable the site setting `include_in_discourse_discover` to enroll their forum the `CallDiscourseHub` job will ping the `api.discourse.org/api/discover/enroll` endpoint. Then the Discourse Hub will fetch the basic details from the forum and add it to the review queue. If the site is approved then the forum details will be displayed in the `/discover` page.
71 lines
1.5 KiB
Ruby
71 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class AboutSerializer < ApplicationSerializer
|
|
class UserAboutSerializer < BasicUserSerializer
|
|
attributes :title, :last_seen_at
|
|
end
|
|
|
|
class AboutCategoryModsSerializer < ApplicationSerializer
|
|
attributes :category_id
|
|
|
|
has_many :moderators, serializer: UserAboutSerializer, embed: :objects
|
|
end
|
|
|
|
has_many :moderators, serializer: UserAboutSerializer, embed: :objects
|
|
has_many :admins, serializer: UserAboutSerializer, embed: :objects
|
|
has_many :category_moderators, serializer: AboutCategoryModsSerializer, embed: :objects
|
|
|
|
attributes :stats,
|
|
:description,
|
|
:title,
|
|
:locale,
|
|
:version,
|
|
:https,
|
|
:can_see_about_stats,
|
|
:contact_url,
|
|
:contact_email,
|
|
:discourse_discover_enrolled
|
|
|
|
def include_stats?
|
|
can_see_about_stats
|
|
end
|
|
|
|
def stats
|
|
object.class.fetch_cached_stats
|
|
end
|
|
|
|
def include_contact_url?
|
|
can_see_site_contact_details
|
|
end
|
|
|
|
def contact_url
|
|
SiteSetting.contact_url
|
|
end
|
|
|
|
def include_contact_email?
|
|
can_see_site_contact_details
|
|
end
|
|
|
|
def contact_email
|
|
SiteSetting.contact_email
|
|
end
|
|
|
|
def discourse_discover_enrolled
|
|
SiteSetting.include_in_discourse_discover?
|
|
end
|
|
|
|
def include_discourse_discover_enrolled?
|
|
SiteSetting.include_in_discourse_discover?
|
|
end
|
|
|
|
private
|
|
|
|
def can_see_about_stats
|
|
scope.can_see_about_stats?
|
|
end
|
|
|
|
def can_see_site_contact_details
|
|
scope.can_see_site_contact_details?
|
|
end
|
|
end
|