Publish noai, noindex or other_settings on activitypub
This commit is contained in:
parent
a4de9fcfdb
commit
062da7f31d
5 changed files with 34 additions and 11 deletions
|
@ -293,6 +293,14 @@ class Account < ApplicationRecord
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def noindex?
|
||||||
|
user_prefers_noindex? || (settings.present? && settings['noindex']) || false
|
||||||
|
end
|
||||||
|
|
||||||
|
def noai?
|
||||||
|
user&.setting_noai || (settings.present? && settings['noai']) || false
|
||||||
|
end
|
||||||
|
|
||||||
def previous_strikes_count
|
def previous_strikes_count
|
||||||
strikes.where(overruled_at: nil).count
|
strikes.where(overruled_at: nil).count
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,14 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||||
context :security
|
context :security
|
||||||
|
|
||||||
context_extensions :manually_approves_followers, :featured, :also_known_as,
|
context_extensions :manually_approves_followers, :featured, :also_known_as,
|
||||||
:moved_to, :property_value, :discoverable, :olm, :suspended, :searchable_by, :subscribable_by
|
:moved_to, :property_value, :discoverable, :olm, :suspended, :searchable_by, :subscribable_by,
|
||||||
|
:other_setting
|
||||||
|
|
||||||
attributes :id, :type, :following, :followers,
|
attributes :id, :type, :following, :followers,
|
||||||
:inbox, :outbox, :featured, :featured_tags,
|
:inbox, :outbox, :featured, :featured_tags,
|
||||||
:preferred_username, :name, :summary,
|
:preferred_username, :name, :summary,
|
||||||
:url, :manually_approves_followers,
|
:url, :manually_approves_followers,
|
||||||
:discoverable, :published, :searchable_by, :subscribable_by, :obher_setting
|
:discoverable, :published, :searchable_by, :subscribable_by, :other_setting
|
||||||
|
|
||||||
has_one :public_key, serializer: ActivityPub::PublicKeySerializer
|
has_one :public_key, serializer: ActivityPub::PublicKeySerializer
|
||||||
|
|
||||||
|
@ -170,6 +171,21 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||||
ActivityPub::TagManager.instance.subscribable_by(object)
|
ActivityPub::TagManager.instance.subscribable_by(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def other_setting
|
||||||
|
hash = []
|
||||||
|
if object.settings.present?
|
||||||
|
hash = object.settings.map do |k, v|
|
||||||
|
{
|
||||||
|
type: 'PropertyValue',
|
||||||
|
name: k,
|
||||||
|
value: v,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
hash << { type: 'PropertyValue', name: 'noindex', value: object.noindex? }
|
||||||
|
hash << { type: 'PropertyValue', name: 'noai', value: object.noai? }
|
||||||
|
end
|
||||||
|
|
||||||
class CustomEmojiSerializer < ActivityPub::EmojiSerializer
|
class CustomEmojiSerializer < ActivityPub::EmojiSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :group, :created_at,
|
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :group, :created_at,
|
||||||
:note, :url, :avatar, :avatar_static, :header, :header_static, :searchability, :subscribable,
|
:note, :url, :avatar, :avatar_static, :header, :header_static, :searchability, :subscribable,
|
||||||
:followers_count, :following_count, :statuses_count, :last_status_at, :other_settings
|
:followers_count, :following_count, :statuses_count, :last_status_at, :other_settings,
|
||||||
|
:noindex, :noai
|
||||||
|
|
||||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||||
|
|
||||||
|
@ -14,8 +15,6 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attribute :suspended, if: :suspended?
|
attribute :suspended, if: :suspended?
|
||||||
attribute :silenced, key: :limited, if: :silenced?
|
attribute :silenced, key: :limited, if: :silenced?
|
||||||
attribute :noindex, if: :local?
|
|
||||||
attribute :noai, if: :local?
|
|
||||||
|
|
||||||
attribute :memorial, if: :memorial?
|
attribute :memorial, if: :memorial?
|
||||||
|
|
||||||
|
@ -144,11 +143,11 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def noindex
|
def noindex
|
||||||
object.user_prefers_noindex?
|
object.noindex?
|
||||||
end
|
end
|
||||||
|
|
||||||
def noai
|
def noai
|
||||||
object.user&.setting_noai
|
object.noai?
|
||||||
end
|
end
|
||||||
|
|
||||||
delegate :suspended?, :silenced?, :local?, :memorial?, to: :object
|
delegate :suspended?, :silenced?, :local?, :memorial?, to: :object
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
= "#{display_name(@account)} (#{acct(@account)})"
|
= "#{display_name(@account)} (#{acct(@account)})"
|
||||||
|
|
||||||
- content_for :header_tags do
|
- content_for :header_tags do
|
||||||
- if @account.user_prefers_noindex?
|
- if @account.noindex?
|
||||||
%meta{ name: 'robots', content: 'noindex, noarchive, noai, noimageai' }/
|
%meta{ name: 'robots', content: 'noindex, noarchive, noai, noimageai' }/
|
||||||
%meta{ name: 'CCBot', content: 'nofollow' }/
|
%meta{ name: 'CCBot', content: 'nofollow' }/
|
||||||
- elsif @account.user&.setting_noai
|
- elsif @account.noai?
|
||||||
%meta{ name: 'robots', content: 'noai, noimageai' }/
|
%meta{ name: 'robots', content: 'noai, noimageai' }/
|
||||||
%meta{ name: 'CCBot', content: 'nofollow' }/
|
%meta{ name: 'CCBot', content: 'nofollow' }/
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
= t('statuses.title', name: display_name(@account), quote: truncate(@status.spoiler_text.presence || @status.text, length: 50, omission: '…', escape: false))
|
= t('statuses.title', name: display_name(@account), quote: truncate(@status.spoiler_text.presence || @status.text, length: 50, omission: '…', escape: false))
|
||||||
|
|
||||||
- content_for :header_tags do
|
- content_for :header_tags do
|
||||||
- if @account.user_prefers_noindex?
|
- if @account.noindex?
|
||||||
%meta{ name: 'robots', content: 'noindex, noarchive, noai, noimageai' }/
|
%meta{ name: 'robots', content: 'noindex, noarchive, noai, noimageai' }/
|
||||||
%meta{ name: 'CCBot', content: 'nofollow' }/
|
%meta{ name: 'CCBot', content: 'nofollow' }/
|
||||||
- elsif @account.user&.setting_noai
|
- elsif @account.noai?
|
||||||
%meta{ name: 'robots', content: 'noai, noimageai' }/
|
%meta{ name: 'robots', content: 'noai, noimageai' }/
|
||||||
%meta{ name: 'CCBot', content: 'nofollow' }/
|
%meta{ name: 'CCBot', content: 'nofollow' }/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue