1
0
Fork 0
forked from gitea/nas

Merge commit '3a1a6ba39e' into kb_migration_development

This commit is contained in:
KMY 2023-05-01 15:08:16 +09:00
commit 81a7272ce7
288 changed files with 1345 additions and 1343 deletions

View file

@ -458,14 +458,14 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
end
SCAN_SEARCHABILITY_RE = /\[searchability:(public|followers|reactors|private)\]/.freeze
SCAN_SEARCHABILITY_RE = /\[searchability:(public|followers|reactors|private)\]/
def searchability
searchability = searchability_from_audience
if searchability.nil?
note = @account&.note
return nil unless note.present?
return nil if note.blank?
searchability_bio = note.scan(SCAN_SEARCHABILITY_RE).first
return nil unless searchability_bio
@ -479,9 +479,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
searchability = :private if searchability == 'reactors'
end
visibility = visibility_from_audience_with_silence
visibility = visibility_from_audience_with_silence
if searchability === visibility
if searchability == visibility
searchability
elsif [:public, :unlisted].include?(searchability) && [:public, :unlisted].include?(visibility) # unlisted is Followers only in kmyblue (generics: private)
:unlisted

View file

@ -36,9 +36,9 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
uri = emoji_tag['id']
domain = URI.split(uri)[2]
emoji = CustomEmoji.find_or_create_by!(shortcode: shortcode, domain: domain) do |emoji|
emoji.uri = uri
emoji.image_remote_url = image_url
emoji = CustomEmoji.find_or_create_by!(shortcode: shortcode, domain: domain) do |emoji_data|
emoji_data.uri = uri
emoji_data.image_remote_url = image_url
end
Trends.statuses.register(@original_status)
@ -59,7 +59,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
end
def forward_for_emoji_reaction
return unless @json['signature'].present?
return if @json['signature'].blank?
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(@json), @original_status.account.id, [@account.preferred_inbox_url])
end
@ -87,7 +87,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
def misskey_favourite?
misskey_shortcode = @json['_misskey_reaction']&.delete(':')
return misskey_shortcode == shortcode && misskey_shortcode == '⭐'
misskey_shortcode == shortcode && misskey_shortcode == '⭐'
end
def emoji_tag

View file

@ -121,9 +121,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
if shortcode.present?
emoji_tag = @object['tag'].is_a?(Array) ? @object['tag']&.first : @object['tag']
if emoji_tag.present? && emoji_tag['id'].present?
emoji = CustomEmoji.find_by(shortcode: shortcode, domain: @account.domain)
end
emoji = CustomEmoji.find_by(shortcode: shortcode, domain: @account.domain) if emoji_tag.present? && emoji_tag['id'].present?
emoji_reaction = @original_status.emoji_reactions.where(account: @account, name: shortcode, custom_emoji: emoji).first
@ -159,7 +157,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
end
def forward_for_undo_emoji_reaction
return unless @json['signature'].present?
return if @json['signature'].blank?
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(@json), @original_status.account.id, [@account.preferred_inbox_url])
end

View file

@ -124,9 +124,7 @@ class ActivityPub::TagManager
cc << COLLECTIONS[:public]
end
cc = cc + cc_private_visibility(status)
cc
cc + cc_private_visibility(status)
end
def cc_for_misskey(status)
@ -205,7 +203,7 @@ class ActivityPub::TagManager
end
def subscribable_by(account)
account.dissubscribable ? [] : [COLLECTIONS[:public]]
account.dissubscribable ? [] : [COLLECTIONS[:public]]
end
def searchable_by(status)
@ -213,10 +211,10 @@ class ActivityPub::TagManager
case status.compute_searchability_activitypub
when 'public'
[COLLECTIONS[:public]]
when 'unlisted' # Followers only in kmyblue (generics: private)
when 'unlisted' # Followers only in kmyblue (generics: private)
[account_followers_url(status.account)]
when 'private' # Reaction only in kmyblue (generics: direct)
[]
# when 'private' # Reaction only in kmyblue (generics: direct)
# []
when 'limited'
status.conversation_id.present? ? [uri_for(status.conversation)] : []
else

View file

@ -37,7 +37,17 @@ class ConnectionPool::SharedConnectionPool < ConnectionPool
end
def checkin(preferred_tag)
if ::Thread.current[key(preferred_tag)]
if preferred_tag.is_a?(Hash) && preferred_tag[:force]
# ConnectionPool 2.4+ calls `checkin(force: true)` after fork.
# When this happens, we should remove all connections from Thread.current
::Thread.current.keys.each do |name| # rubocop:disable Style/HashEachMethods
next unless name.to_s.start_with?("#{@key}-")
@available.push(::Thread.current[name])
::Thread.current[name] = nil
end
elsif ::Thread.current[key(preferred_tag)]
if ::Thread.current[key_count(preferred_tag)] == 1
@available.push(::Thread.current[key(preferred_tag)])
::Thread.current[key(preferred_tag)] = nil

View file

@ -63,11 +63,9 @@ class EmojiFormatter
def emoji_map
# from emoji_reactions_grouped_by_name (status_stat)
if !custom_emojis.first&.image.present?
return @emoji_map ||= custom_emojis.each_with_object({}) { |e, h| h[e.name] = [e.url, e.static_url] }
end
return @emoji_map ||= custom_emojis.each_with_object({}) { |e, h| h[e.name] = [e.url, e.static_url] } if custom_emojis.first&.image.blank?
return @emoji_map ||= custom_emojis.each_with_object({}) { |e, h| h[e.shortcode] = [full_asset_url(e.image.url), full_asset_url(e.image.url(:static))] }
@emoji_map ||= custom_emojis.each_with_object({}) { |e, h| h[e.shortcode] = [full_asset_url(e.image.url), full_asset_url(e.image.url(:static))] }
end
def count_tag_nesting(tag)
@ -102,7 +100,7 @@ class EmojiFormatter
end
def image_style
'min-width:16px;' + (@options[:style] || '')
"min-width:16px;#{@options[:style] || ''}"
end
def animate?

View file

@ -120,8 +120,8 @@ class StatusReachFinder
return @banned_domains if @banned_domains
domains = banned_domains_of_status(@status)
domains = domains + banned_domains_of_status(@status.reblog) if @status.reblog? && @status.reblog.local?
return @banned_domains = domains.uniq
domains += banned_domains_of_status(@status.reblog) if @status.reblog? && @status.reblog.local?
@banned_domains = domains.uniq
end
def banned_domains_of_status(status)
@ -142,8 +142,8 @@ class StatusReachFinder
return @banned_domains_for_misskey if @banned_domains_for_misskey
domains = banned_domains_for_misskey_of_status(@status)
domains = domains + banned_domains_for_misskey_of_status(@status.reblog) if @status.reblog? && @status.reblog.local?
return @banned_domains_for_misskey = domains.uniq
domains += banned_domains_for_misskey_of_status(@status.reblog) if @status.reblog? && @status.reblog.local?
@banned_domains_for_misskey = domains.uniq
end
def banned_domains_for_misskey_of_status(status)

View file

@ -168,28 +168,27 @@ class TextFormatter
def markdownify(html)
# not need filter_html because escape is already done
@htmlobj ||= MyMarkdownHTML.new(
filter_html: false,
hard_wrap: true
)
filter_html: false,
hard_wrap: true
)
@markdown ||= Redcarpet::Markdown.new(@htmlobj,
autolink: false,
tables: false,
disable_indented_code_blocks: false,
fenced_code_blocks: true,
strikethrough: true,
superscript: true,
underline: true,
highlight: false
)
autolink: false,
tables: false,
disable_indented_code_blocks: false,
fenced_code_blocks: true,
strikethrough: true,
superscript: true,
underline: true,
highlight: false)
@markdown.render(html)
end
class MyMarkdownHTML < Redcarpet::Render::HTML
def link(link, title, content)
def link(_link, _title, _content)
nil
end
def block_code(code, language)
def block_code(code, _language)
"<pre>#{process_program_code(code)}</pre>"
end
@ -197,15 +196,15 @@ class TextFormatter
"<code>#{process_program_code(code)}</code>"
end
def header(text, header_level)
def header(text, _header_level)
"<p>#{text}</p>"
end
def underline(text)
text.include?(':') ? nil : '<u>' + text + '</u>'
text.include?(':') ? nil : "<u>#{text}</u>"
end
def image(link, title, alt_text)
def image(_link, _title, _alt_text)
nil
end