mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-22 14:50:40 +08:00
Extends the live PR status indicator (#36313) to inline oneboxes <img width="759" height="308" alt="image" src="https://github.com/user-attachments/assets/10a379d2-78a9-4987-8f56-1df854fe33fa" />
48 lines
1.3 KiB
Ruby
Vendored
48 lines
1.3 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class RebakeGithubPrPosts < ::Jobs::Base
|
|
sidekiq_options queue: "low"
|
|
|
|
def execute(args)
|
|
url = args[:pr_url]
|
|
return if url.blank?
|
|
|
|
Oneboxer.preview(url, invalidate_oneboxes: true)
|
|
InlineOneboxer.invalidate(url)
|
|
|
|
rebake_posts(url)
|
|
rebake_chat_messages(url) if SiteSetting.chat_enabled
|
|
end
|
|
|
|
private
|
|
|
|
def rebake_posts(url)
|
|
post_ids = TopicLink.where(url:).or(TopicLink.where("url LIKE ?", "#{url}%")).select(:post_id)
|
|
|
|
Post
|
|
.where(id: post_ids)
|
|
.where(
|
|
"cooked LIKE :pattern AND (cooked LIKE '%githubpullrequest%' OR cooked LIKE '%inline-onebox%')",
|
|
pattern: "%#{url}%",
|
|
)
|
|
.find_each { |post| post.rebake!(priority: :low, skip_publish_rebaked_changes: true) }
|
|
end
|
|
|
|
def rebake_chat_messages(url)
|
|
message_ids =
|
|
::Chat::MessageLink
|
|
.where(url:)
|
|
.or(::Chat::MessageLink.where("url LIKE ?", "#{url}%"))
|
|
.select(:chat_message_id)
|
|
|
|
::Chat::Message
|
|
.where(id: message_ids)
|
|
.where(
|
|
"cooked LIKE :pattern AND (cooked LIKE '%githubpullrequest%' OR cooked LIKE '%inline-onebox%')",
|
|
pattern: "%#{url}%",
|
|
)
|
|
.find_each { |message| message.rebake!(priority: :low, skip_notifications: true) }
|
|
end
|
|
end
|
|
end
|