Add user_updated event to webhooks.

This commit is contained in:
Guo Xiang Tan 2016-12-13 11:26:26 +08:00
parent 53086fdb98
commit 69330f8bc2
4 changed files with 9 additions and 4 deletions

View File

@ -71,7 +71,7 @@ class WebHook < ActiveRecord::Base
WebHook.enqueue_topic_hooks(:topic_edited, post.topic) if post.is_first_post? && topic_changed
end
%i(user_created user_approved).each do |event|
%i(user_created user_approved user_updated).each do |event|
DiscourseEvent.on(event) do |user|
WebHook.enqueue_hooks(:user, user_id: user.id, event_name: event.to_s)
end

View File

@ -98,7 +98,9 @@ class UserUpdater
update_muted_users(attributes[:muted_usernames])
end
(!save_options || user.user_option.save) && user_profile.save && user.save
saved = (!save_options || user.user_option.save) && user_profile.save && user.save
DiscourseEvent.trigger(:user_updated, user) if saved
saved
end
end

View File

@ -2573,7 +2573,7 @@ en:
details: "When there is a new reply, edit, deleted or recovered."
user_event:
name: "User Event"
details: "When a user is created or approved."
details: "When a user is created, approved or updated."
delivery_status:
title: "Delivery Status"
inactive: "Inactive"

View File

@ -131,7 +131,7 @@ describe WebHook do
PostDestroyer.new(user, post2).recover
end
it 'should enqueue the right hooks for user creation events' do
it 'should enqueue the right hooks for user events' do
WebHook.expects(:enqueue_hooks).once
user
@ -140,6 +140,9 @@ describe WebHook do
WebHook.expects(:enqueue_hooks).once
user.approve(admin)
WebHook.expects(:enqueue_hooks).once
UserUpdater.new(admin, user).update(username: 'testing123')
end
end
end