DEV: after_extract_linked_users hook for plugins to modify user list

This allows plugins to change the list of users which will be sent 'linked' notifications
This commit is contained in:
David Taylor 2020-07-03 14:52:49 +01:00
parent b0d17a508b
commit 4c1e690e32
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
1 changed files with 5 additions and 1 deletions

View File

@ -508,13 +508,17 @@ class PostAlerter
end end
def extract_linked_users(post) def extract_linked_users(post)
post.topic_links.where(reflection: false).map do |link| users = post.topic_links.where(reflection: false).map do |link|
linked_post = link.link_post linked_post = link.link_post
if !linked_post && topic = link.link_topic if !linked_post && topic = link.link_topic
linked_post = topic.posts.find_by(post_number: 1) linked_post = topic.posts.find_by(post_number: 1)
end end
(linked_post && post.user_id != linked_post.user_id && linked_post.user) || nil (linked_post && post.user_id != linked_post.user_id && linked_post.user) || nil
end.compact end.compact
DiscourseEvent.trigger(:after_extract_linked_users, users, post)
users
end end
# Notify a bunch of users # Notify a bunch of users