Question: Auto-mentioning when a shared topic url is posted to another Discourse

On the other hand, wouldn’t this be relatively easy to do using incoming_links, incoming_referers and incoming_domains ?

What if one would be able to whitelist an incoming_domain and we could get oneboxes for links from those domains to that topic ?

Edit: the snippet below will list all links on Discourse sites* that point to a specific topic. Should be pretty easy to put this in a scheduled job that inserts a post in the topic whenever it finds a new link. Oneboxing will take care of the rest.

topic = Topic.find(xxx)
IncomingLink.where("post_id in (#{topic.posts.pluck(:id).join(',')})").where("incoming_referer_id is not null").each do |link|
  next unless link.incoming_referer.path.start_with?('/t/')
  puts "https://#{link.incoming_referer.incoming_domain.name}#{link.incoming_referer.path}"
end

*) I’m using a simple check now to determine if it’s a Discourse link but this could even request the home page of the site and inspect the meta data - although I think this could work very well for links from non-Discourse sites as well. Maybe whitelist the domains in plugin settings.