DEV: after_extract_linked_users hook for plugins to modify user list

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

diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb
index 24d8b48..23025a5 100644
--- a/app/services/post_alerter.rb
+++ b/app/services/post_alerter.rb
@@ -508,13 +508,17 @@ class PostAlerter
   end
 
   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
       if !linked_post && topic = link.link_topic
         linked_post = topic.posts.find_by(post_number: 1)
       end
       (linked_post && post.user_id != linked_post.user_id && linked_post.user) || nil
     end.compact
+
+    DiscourseEvent.trigger(:after_extract_linked_users, users, post)
+
+    users
   end
 
   # Notify a bunch of users

GitHub sha: 4c1e690e

1 Like