DEV: use 'user_created' discourse event instead of 'after_commit' model callback.

DEV: use ‘user_created’ discourse event instead of ‘after_commit’ model callback.

diff --git a/plugins/discourse-narrative-bot/plugin.rb b/plugins/discourse-narrative-bot/plugin.rb
index 02d78d0..7368b37 100644
--- a/plugins/discourse-narrative-bot/plugin.rb
+++ b/plugins/discourse-narrative-bot/plugin.rb
@@ -120,9 +120,9 @@ after_initialize do
     DiscourseNarrativeBot::Store.remove(self.id)
   end
 
-  self.add_model_callback(User, :after_commit, on: :create) do
-    if SiteSetting.discourse_narrative_bot_welcome_post_delay == 0 && !self.staged
-      self.enqueue_bot_welcome_post
+  self.on(:user_created) do |user|
+    if SiteSetting.discourse_narrative_bot_welcome_post_delay == 0 && !user.staged
+      user.enqueue_bot_welcome_post
     end
   end

GitHub sha: 5a919c22

1 Like