FEATURE: Add user_confirmed_email to user event webhook (#12539)

This commit is contained in:
wilson29thid 2021-04-12 03:48:42 +01:00 committed by GitHub
parent 5b342ae505
commit d5b30b9b7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 3 deletions

View File

@ -72,6 +72,7 @@ class EmailToken < ActiveRecord::Base
user.save!
user.create_reviewable unless skip_reviewable
user.set_automatic_groups
DiscourseEvent.trigger(:user_confirmed_email, user)
end
if user

View File

@ -41,6 +41,7 @@ end
user_logged_in
user_approved
user_updated
user_confirmed_email
).each do |event|
DiscourseEvent.on(event) do |user|
WebHook.enqueue_object_hooks(:user, user, event)

View File

@ -3999,7 +3999,7 @@ en:
details: "When there is a new reply, edit, deleted or recovered."
user_event:
name: "User Event"
details: "When a user logs in, logs out, is created, approved or updated."
details: "When a user logs in, logs out, confirms their email, is created, approved or updated."
group_event:
name: "Group Event"
details: "When a group is created, updated or destroyed."

View File

@ -324,7 +324,6 @@ describe WebHook do
Fabricate(:user_web_hook, active: true)
user
user.activate
Jobs::CreateUserReviewable.new.execute(user_id: user.id)
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
@ -333,6 +332,14 @@ describe WebHook do
payload = JSON.parse(job_args["payload"])
expect(payload["id"]).to eq(user.id)
email_token = user.email_tokens.create(email: user.email)
EmailToken.confirm(email_token.token)
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
expect(job_args["event_name"]).to eq("user_confirmed_email")
payload = JSON.parse(job_args["payload"])
expect(payload["id"]).to eq(user.id)
admin
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first

View File

@ -230,7 +230,7 @@ describe UsersController do
end
expect(events.map { |event| event[:event_name] }).to contain_exactly(
:user_logged_in, :user_first_logged_in
:user_logged_in, :user_first_logged_in, :user_confirmed_email
)
expect(response.status).to eq(200)