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:
parent
b0d17a508b
commit
4c1e690e32
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue