Revert "FIX: always trigger the ':user_updated' event"

This reverts commit 519b70ea46.

https://meta.discourse.org/t/creating-a-topic-or-a-post-sends-the-user-updated-webhook/71643
This commit is contained in:
Guo Xiang Tan 2017-10-23 11:31:04 +08:00
parent e91a631978
commit 19f3b81161
3 changed files with 5 additions and 13 deletions

View File

@ -108,7 +108,6 @@ class User < ActiveRecord::Base
after_save :expire_old_email_tokens
after_save :index_search
after_commit :trigger_user_created_event, on: :create
after_commit :trigger_user_updated_event, on: :update
before_destroy do
# These tables don't have primary keys, so destroying them with activerecord is tricky:
@ -1098,11 +1097,6 @@ class User < ActiveRecord::Base
true
end
def trigger_user_updated_event
DiscourseEvent.trigger(:user_updated, self)
true
end
def set_should_validate_email
if self.primary_email
self.primary_email.should_validate_email = should_validate_email_address?

View File

@ -122,6 +122,7 @@ class UserUpdater
end
end
DiscourseEvent.trigger(:user_updated, user) if saved
saved
end

View File

@ -91,15 +91,12 @@ describe User do
user.approve(admin)
end
it 'triggers extensibility events' do
it 'triggers a extensibility event' do
user && admin # bypass the user_created event
user_updated_event, user_approved_event = DiscourseEvent.track_events { user.approve(admin) }
event = DiscourseEvent.track_events { user.approve(admin) }.first
expect(user_updated_event[:event_name]).to eq(:user_updated)
expect(user_updated_event[:params].first).to eq(user)
expect(user_approved_event[:event_name]).to eq(:user_approved)
expect(user_approved_event[:params].first).to eq(user)
expect(event[:event_name]).to eq(:user_approved)
expect(event[:params].first).to eq(user)
end
context 'after approval' do