A platform for community discussion. Free, open, simple.
DEV: Pass the acting user to workflow-relevant events (#44555)
Régis Hanol22630754ba93
diff --git a/.skills/discourse-workflow-nodes/SKILL.md b/.skills/discourse-workflow-nodes/SKILL.mdindex 63b586f8f2c..0fce8d371c8 100644--- a/.skills/discourse-workflow-nodes/SKILL.md+++ b/.skills/discourse-workflow-nodes/SKILL.md@@ -27,6 +27,23 @@ Shape entities only with `DiscourseWorkflows::EntitySerializers` (`lib/discourse- Never use `BasicUserSerializer` or `TopicListItemSerializer` in node files; `node_entity_builders_spec` fails if you do.- Groups: `BasicGroupSerializer` (`BASIC_GROUP_PROPERTIES`) or `WebHookGroupSerializer` (`GROUP_SCHEMA`).+## `user` vs `actor`++- `user` is the subject: the post/topic author, or the affected account.+- `actor` is whoever performed the action, built with `serialize_user` and declared with `Schema::ACTOR_SCHEMA` (nullable).+- Emit both, even when they are the same person (liker, voter, participant).+- Output never uses `acting_user`; events never use `actor:`.++## Events pass the acting user++Fire events with the actor as a trailing `acting_user:` kwarg:++```ruby+DiscourseEvent.trigger(:topic_status_updated, topic, status, enabled, acting_user: user)+```++Trigger nodes receive it as a trailing hash: `def initialize(topic, status, enabled, payload = {})` and read `payload[:acting_user]`. Specs that assert exact event params must include `{ acting_user: ... }`.+## Output conventions- URLs are absolute (`Discourse.base_url + ...`, `full_url`). Keep existing relative keys such as `post_url`.diff --git a/app/models/reviewable.rb b/app/models/reviewable.rbindex 24454a938ba..cb1a9ef3d60 100644--- a/app/models/reviewable.rb+++ b/app/models/reviewable.rb@@ -512,7 +512,12 @@ class Reviewable < ActiveRecord::Basesave!log_history(:transitioned, performed_by)- DiscourseEvent.trigger(:reviewable_transitioned_to, status_symbol, self)+ DiscourseEvent.trigger(+ :reviewable_transitioned_to,+ status_symbol,+ self,+ acting_user: performed_by,+ )if score_status = ReviewableScore.score_transitions[status_symbol]scores.update_all(diff --git a/app/services/topic_status_updater.rb b/app/services/topic_status_updater.rbindex 086ae6f632b..f62cff4d54b 100644--- a/app/services/topic_status_updater.rb+++ b/app/services/topic_status_updater.rb@@ -20,7 +20,13 @@ TopicStatusUpdater =endif changed- DiscourseEvent.trigger(:topic_status_updated, topic, event_status, status.enabled?)+ DiscourseEvent.trigger(+ :topic_status_updated,+ topic,+ event_status,+ status.enabled?,+ acting_user: user,+ )endupdateddiff --git a/plugins/chat/lib/discourse_workflows/nodes/chat_approval/v2.rb b/plugins/chat/lib/discourse_workflows/nodes/chat_approval/v2.rbindex fe771fd9ce1..ac3d0240a9c 100644--- a/plugins/chat/lib/discourse_workflows/nodes/chat_approval/v2.rb+++ b/plugins/chat/lib/discourse_workflows/nodes/chat_approval/v2.rb@@ -30,6 +30,7 @@ if defined?(DiscourseWorkflows)"type" => "object","properties" => DiscourseWorkflows::Schema::USER_PROPERTIES,},+ "actor" => DiscourseWorkflows::Schema.nullable_user("User who clicked the button"),},}.freeze@@ -238,7 +239,12 @@ if defined?(DiscourseWorkflows)[DiscourseWorkflows::Item.wrap(- { value: interaction.action["value"].to_s, channel: channel_data, user: user_data },+ {+ value: interaction.action["value"].to_s,+ channel: channel_data,+ user: user_data,+ actor: user_data,+ },paired_item: 0,),]diff --git a/plugins/chat/lib/discourse_workflows/nodes/chat_message_created/v1.rb b/plugins/chat/lib/discourse_workflows/nodes/chat_message_created/v1.rbindex bf39b7c9893..0846eb4bbf8 100644--- a/plugins/chat/lib/discourse_workflows/nodes/chat_message_created/v1.rb+++ b/plugins/chat/lib/discourse_workflows/nodes/chat_message_created/v1.rb@@ -59,6 +59,8 @@ if defined?(DiscourseWorkflows)"properties" => Chat::WorkflowChannelSerializer::PROPERTIES,},"user" => DiscourseWorkflows::Schema.nullable_user("Message author"),+ "actor" =>+ DiscourseWorkflows::Schema.nullable_user("User who sent the message"),},},},@@ -118,6 +120,8 @@ if defined?(DiscourseWorkflows)enddef output+ user = serialize_user(@user)+{message: {id: @message.id,@@ -130,7 +134,8 @@ if defined?(DiscourseWorkflows)url: @message.full_url,},channel: serialize_channel,- user: serialize_user(@user),+ user:,+ actor: user,}enddiff --git a/plugins/chat/spec/integration/workflows_chat_approval_spec.rb b/plugins/chat/spec/integration/workflows_chat_approval_spec.rbindex c0fb5117315..7d612c6c611 100644--- a/plugins/chat/spec/integration/workflows_chat_approval_spec.rb+++ b/plugins/chat/spec/integration/workflows_chat_approval_spec.rb@@ -162,7 +162,7 @@ RSpec.describe "Chat approval workflows end-to-end" dofinal_output = execution.reload.execution_data.context_data.dig("Final", 0, "json")expect(execution.status).to eq("success")expect(final_output).to include("request_id" => 42, "completed" => true)- expect(final_output.keys).not_to include("value", "channel", "user")+ expect(final_output.keys).not_to include("value", "channel", "user", "actor")endit "fails a timed-out V2 workflow with the approval timeout error" dodiff --git a/plugins/chat/spec/lib/discourse_workflows/nodes/chat_message_created_spec.rb b/plugins/chat/spec/lib/discourse_workflows/nodes/chat_message_created_spec.rbindex 6107ecb9348..1cbfd32087d 100644--- a/plugins/chat/spec/lib/discourse_workflows/nodes/chat_message_created_spec.rb+++ b/plugins/chat/spec/lib/discourse_workflows/nodes/chat_message_created_spec.rb@@ -61,13 +61,15 @@ RSpec.describe DiscourseWorkflows::Nodes::ChatMessageCreated::V1 dousername: user.username,avatar_template: user.avatar_template,)+ expect(output[:actor]).to include(id: user.id, username: user.username)expect(output).to match_node_output_schema(described_class)end- it "returns a nil user when there is no user", :aggregate_failures do+ it "returns nil user and actor when there is no user", :aggregate_failures dooutput = described_class.new(message, channel, nil).outputexpect(output[:user]).to be_nil+ expect(output[:actor]).to be_nilexpect(output).to match_node_output_schema(described_class)enddiff --git a/plugins/chat/spec/services/chat/workflows/approval/resume_interaction_spec.rb b/plugins/chat/spec/services/chat/workflows/approval/resume_interaction_spec.rbindex 8fb5a74d937..b06096e50e0 100644--- a/plugins/chat/spec/services/chat/workflows/approval/resume_interaction_spec.rb+++ b/plugins/chat/spec/services/chat/workflows/approval/resume_interaction_spec.rb@@ -250,6 +250,7 @@ RSpec.describe Chat::Workflows::Approval::ResumeInteraction do"value" => "needs:changes","channel" => expected_channel,"user" => expected_user,+ "actor" => expected_user,},"pairedItem" => {"item" => 0,diff --git a/plugins/discourse-assign/lib/assigner.rb b/plugins/discourse-assign/lib/assigner.rbindex a3c7d97cfeb..481ae682784 100644--- a/plugins/discourse-assign/lib/assigner.rb+++ b/plugins/discourse-assign/lib/assigner.rb@@ -407,7 +407,7 @@ class ::AssignerWebHook.enqueue_assign_hooks(assigned_to_type, payload.to_json)end- DiscourseEvent.trigger(:assigned, assignment)+ DiscourseEvent.trigger(:assigned, assignment, acting_user: @assigned_by){ success: true }end@@ -472,7 +472,7 @@ class ::AssignerWebHook.enqueue_assign_hooks(type, payload.to_json)end- DiscourseEvent.trigger(:unassigned, assignment)+ DiscourseEvent.trigger(:unassigned, assignment, acting_user: @assigned_by)if allowed_user_ids.present?MessageBus.publish(diff --git a/plugins/discourse-assign/lib/discourse_assign/workflows/assignment_trigger.rb b/plugins/discourse-assign/lib/discourse_assign/workflows/assignment_trigger.rbindex 7c41d791c42..727157625df 100644--- a/plugins/discourse-assign/lib/discourse_assign/workflows/assignment_trigger.rb+++ b/plugins/discourse-assign/lib/discourse_assign/workflows/assignment_trigger.rb@@ -3,9 +3,10 @@module DiscourseAssignmodule Workflowsmodule AssignmentTrigger- def initialize(assignment, *)+ def initialize(assignment, payload = {})super(parameters: {})@assignment = assignment+ @actor = payload[:acting_user]enddef valid?@@ -22,6 +23,7 @@ module DiscourseAssignassignment: serialize_assignment,post: serialize_post(post),topic: serialize_topic_list_item(@assignment.topic),+ actor: serialize_user(@actor),}enddiff --git a/plugins/discourse-assign/lib/discourse_assign/workflows/schema.rb b/plugins/discourse-assign/lib/discourse_assign/workflows/schema.rbindex 61fdde16f03..5fe4bf10b67 100644--- a/plugins/discourse-assign/lib/discourse_assign/workflows/schema.rb+++ b/plugins/discourse-assign/lib/discourse_assign/workflows/schema.rb@@ -69,6 +69,7 @@ module DiscourseAssignDiscourseWorkflows::Schema::POST_SCHEMA,DiscourseWorkflows::Schema::TOPIC_LIST_ITEM_SCHEMA,ASSIGNMENT_SCHEMA,+ DiscourseWorkflows::Schema::ACTOR_SCHEMA,).freezeendenddiff --git a/plugins/discourse-assign/spec/lib/discourse_workflows/nodes/unassigned/v1_spec.rb b/plugins/discourse-assign/spec/lib/discourse_workflows/nodes/unassigned/v1_spec.rbindex 9aa359c72a2..77244fb204d 100644--- a/plugins/discourse-assign/spec/lib/discourse_workflows/nodes/unassigned/v1_spec.rb+++ b/plugins/discourse-assign/spec/lib/discourse_workflows/nodes/unassigned/v1_spec.rb@@ -4,6 +4,7 @@ RSpec.describe DiscourseWorkflows::Nodes::Unassigned::V1 dofab!(:post)fab!(:topic) { post.topic }fab!(:assigned_by_user, :admin)+ fab!(:unassigned_by_user, :admin)fab!(:assignee, :moderator)fab!(:group)@@ -83,15 +84,14 @@ RSpec.describe DiscourseWorkflows::Nodes::Unassigned::V1 doendit "returns valid output for an assignment destroyed by unassign", :aggregate_failures do- assigner = Assigner.new(topic, assigned_by_user)- assigner.assign(assignee)- assignment = topic.reload.assignment+ Assigner.new(topic, assigned_by_user).assign(assignee)- DiscourseEvent.track(:unassigned) { assigner.unassign }+ event = DiscourseEvent.track(:unassigned) { Assigner.new(topic, unassigned_by_user).unassign }- output = described_class.new(assignment).output+ output = described_class.from_event(:unassigned, *event[:params]).outputexpect(output[:assignment]).to include(target_type: "Topic", target_id: topic.id)+ expect(output[:actor][:username]).to eq(unassigned_by_user.username)expect(output[:topic][:id]).to eq(topic.id)expect(output).to match_node_output_schema(described_class)enddiff --git a/plugins/discourse-events/app/jobs/regular/discourse_post_event_bulk_invite.rb b/plugins/discourse-events/app/jobs/regular/discourse_post_event_bulk_invite.rbindex 1e0b4714c0f..4f24afa0abf 100644--- a/plugins/discourse-events/app/jobs/regular/discourse_post_event_bulk_invite.rb+++ b/plugins/discourse-events/app/jobs/regular/discourse_post_event_bulk_invite.rb@@ -108,6 +108,7 @@ module Jobsinvitee.status = statusinvitee.recurring = @recurring && invitee.going?invitee.save!+ invitee.publish_status_changed!(acting_user: @current_user) if invitee.saved_change_to_status?enddef save_log(message)diff --git a/plugins/discourse-events/app/models/discourse_events/events/invitee.rb b/plugins/discourse-events/app/models/discourse_events/events/invitee.rbindex 653b816ea9f..4998d44391f 100644--- a/plugins/discourse-events/app/models/discourse_events/events/invitee.rb+++ b/plugins/discourse-events/app/models/discourse_events/events/invitee.rb@@ -33,7 +33,7 @@ module DiscourseEvents@statuses ||= Enum.new(going: 0, interested: 1, not_going: 2)end- def self.create_attendance!(user_id, post_id, status, recurring: false)+ def self.create_attendance!(user_id, post_id, status, recurring: false, acting_user: nil)status = status.to_symevent = Event.find(post_id)@@ -42,14 +42,14 @@ module DiscourseEventsendinvitee = create!(post_id:, user_id:, status: statuses[status], recurring:)- invitee.publish_attendance_change!+ invitee.publish_attendance_change!(acting_user:)inviteerescue ActiveRecord::RecordNotUnique# multiple attendances may be created concurrently — return the winning rowfind_by(post_id:, user_id:)end- def update_attendance!(status, recurring: false)+ def update_attendance!(status, recurring: false, acting_user: nil)status = status&.to_symif status == :going && event.at_capacity? && !going?@@ -57,7 +57,7 @@ module DiscourseEventsendupdate!(status: self.class.statuses[status], recurring:)- publish_attendance_change!+ publish_attendance_change!(acting_user:)selfend@@ -65,14 +65,18 @@ module DiscourseEventsstatus == Invitee.statuses[:going]end- def publish_attendance_change!+ def publish_attendance_change!(acting_user:)event.publish_update!update_topic_tracking!- DiscourseEvent.trigger(:discourse_calendar_post_event_invitee_status_changed, self)+ publish_status_changed!(acting_user:)end- def publish_attendance_removed!- DiscourseEvent.trigger(:discourse_calendar_post_event_invitee_status_changed, self)+ def publish_status_changed!(acting_user:)+ DiscourseEvent.trigger(+ :discourse_calendar_post_event_invitee_status_changed,+ self,+ acting_user:,+ )enddef self.extract_uniq_usernames(groups)diff --git a/plugins/discourse-events/app/services/discourse_events/events/create_invitee.rb b/plugins/discourse-events/app/services/discourse_events/events/create_invitee.rbindex a6ee1d465c8..2338793140f 100644--- a/plugins/discourse-events/app/services/discourse_events/events/create_invitee.rb+++ b/plugins/discourse-events/app/services/discourse_events/events/create_invitee.rb@@ -51,8 +51,14 @@ module DiscourseEventsparams.status != :going || !event.at_capacity?end- def create_invitee(user:, event:, params:)- Invitee.create_attendance!(user.id, event.id, params.status, recurring: params.recurring)+ def create_invitee(user:, event:, params:, guardian:)+ Invitee.create_attendance!(+ user.id,+ event.id,+ params.status,+ recurring: params.recurring,+ acting_user: guardian.user,+ )endendenddiff --git a/plugins/discourse-events/app/services/discourse_events/events/destroy_invitee.rb b/plugins/discourse-events/app/services/discourse_events/events/destroy_invitee.rbindex 3395668866c..df05232db14 100644--- a/plugins/discourse-events/app/services/discourse_events/events/destroy_invitee.rb+++ b/plugins/discourse-events/app/services/discourse_events/events/destroy_invitee.rb@@ -44,9 +44,9 @@ module DiscourseEventsevent.can_user_update_attendance?(guardian.user)end- def destroy(invitee:)+ def destroy(invitee:, guardian:)invitee.destroy!- invitee.publish_attendance_removed!+ invitee.publish_status_changed!(acting_user: guardian.user)enddef publish(event:)diff --git a/plugins/discourse-events/app/services/discourse_events/events/update_invitee.rb b/plugins/discourse-events/app/services/discourse_events/events/update_invitee.rbindex 05438b841a7..d7f951c7ccf 100644--- a/plugins/discourse-events/app/services/discourse_events/events/update_invitee.rb+++ b/plugins/discourse-events/app/services/discourse_events/events/update_invitee.rb@@ -51,8 +51,12 @@ module DiscourseEventsparams.status != :going || !event.at_capacity? || invitee.status == Invitee.statuses[:going]end- def update(invitee:, params:)- invitee.update_attendance!(params.status, recurring: params.recurring)+ def update(invitee:, params:, guardian:)+ invitee.update_attendance!(+ params.status,+ recurring: params.recurring,+ acting_user: guardian.user,+ )endendenddiff --git a/plugins/discourse-events/lib/discourse_workflows/nodes/event_participation_changed/v1.rb b/plugins/discourse-events/lib/discourse_workflows/nodes/event_participation_changed/v1.rbindex c8c67605411..9b6c2029dca 100644--- a/plugins/discourse-events/lib/discourse_workflows/nodes/event_participation_changed/v1.rb+++ b/plugins/discourse-events/lib/discourse_workflows/nodes/event_participation_changed/v1.rb@@ -25,9 +25,10 @@ if defined?(DiscourseWorkflows)i18n_scope: PostEventScoping::I18N_SCOPE,)- def initialize(invitee, *)+ def initialize(invitee, payload = {})super(parameters: {})@invitee = invitee+ @actor = payload[:acting_user]end# Re-submitting an unchanged RSVP still publishes, so without the@@ -52,6 +53,7 @@ if defined?(DiscourseWorkflows)recurring: !removed? && [email protected],},stats: serialize_event_stats,+ actor: serialize_user(@actor),}enddiff --git a/plugins/discourse-events/lib/discourse_workflows/nodes/post_event_schema.rb b/plugins/discourse-events/lib/discourse_workflows/nodes/post_event_schema.rbindex 88e78b0a6f8..1ca0ae1bc27 100644--- a/plugins/discourse-events/lib/discourse_workflows/nodes/post_event_schema.rb+++ b/plugins/discourse-events/lib/discourse_workflows/nodes/post_event_schema.rb@@ -108,6 +108,7 @@ if defined?(DiscourseWorkflows)DiscourseWorkflows::Schema::USER_SCHEMA,PARTICIPATION_SCHEMA,STATS_SCHEMA,+ DiscourseWorkflows::Schema::ACTOR_SCHEMA,).freezeendenddiff --git a/plugins/discourse-events/spec/integration/workflows_event_triggers_spec.rb b/plugins/discourse-events/spec/integration/workflows_event_triggers_spec.rbindex b90a2ca1b10..5c1770f7257 100644--- a/plugins/discourse-events/spec/integration/workflows_event_triggers_spec.rb+++ b/plugins/discourse-events/spec/integration/workflows_event_triggers_spec.rb@@ -80,6 +80,60 @@ RSpec.describe "Post event workflow triggers" doJobs::DiscourseWorkflows::ExecuteWorkflow.jobs.first["args"].first["trigger_data"]expect(trigger_data["participation"]).to include("removed" => true, "status" => nil)end++ it "enqueues for each invitee whose status a bulk invite sets" do+ event.update!(status: DiscourseEvents::Events::Event.statuses[:public])+ newcomer = Fabricate(:user)+ DiscourseEvents::Events::Invitee.create_attendance!(attendee.id, event.id, :interested)+ workflow = publish_workflow("trigger-all", "trigger:event_participation_changed")+ Jobs::DiscourseWorkflows::ExecuteWorkflow.jobs.clear++ Jobs::DiscoursePostEventBulkInvite.new.execute(+ event_id: event.id,+ current_user_id: admin.id,+ invitees: [+ { "identifier" => attendee.username, "attendance" => "going" },+ { "identifier" => newcomer.username, "attendance" => "not_going" },+ ],+ )++ expect(enqueued_workflow_ids("trigger-all")).to eq([workflow.id, workflow.id])++ participations =+ Jobs::DiscourseWorkflows::ExecuteWorkflow.jobs.map do |job|+ job["args"].first["trigger_data"].slice("user", "participation", "actor")+ end+ expect(participations).to contain_exactly(+ a_hash_including(+ "user" => a_hash_including("id" => attendee.id),+ "participation" =>+ a_hash_including("status" => "going", "previous_status" => "interested"),+ "actor" => a_hash_including("id" => admin.id),+ ),+ a_hash_including(+ "user" => a_hash_including("id" => newcomer.id),+ "participation" => a_hash_including("status" => "not_going", "previous_status" => nil),+ "actor" => a_hash_including("id" => admin.id),+ ),+ )+ end++ it "does not enqueue when a bulk invite leaves the status unchanged" do+ event.update!(status: DiscourseEvents::Events::Event.statuses[:public])+ DiscourseEvents::Events::Invitee.create_attendance!(attendee.id, event.id, :going).update!(+ notified: true,+ )+ publish_workflow("trigger-all", "trigger:event_participation_changed")+ Jobs::DiscourseWorkflows::ExecuteWorkflow.jobs.clear++ Jobs::DiscoursePostEventBulkInvite.new.execute(+ event_id: event.id,+ current_user_id: admin.id,+ invitees: [{ "identifier" => attendee.username, "attendance" => "going" }],+ )++ expect(enqueued_workflow_ids("trigger-all")).to be_empty+ endenddescribe "trigger:event_ended" dodiff --git a/plugins/discourse-events/spec/lib/discourse_workflows/nodes/event_participation_changed/v1_spec.rb b/plugins/discourse-events/spec/lib/discourse_workflows/nodes/event_participation_changed/v1_spec.rbindex eaffcd8462c..5149ad4411f 100644--- a/plugins/discourse-events/spec/lib/discourse_workflows/nodes/event_participation_changed/v1_spec.rb+++ b/plugins/discourse-events/spec/lib/discourse_workflows/nodes/event_participation_changed/v1_spec.rb@@ -67,6 +67,26 @@ RSpec.describe DiscourseWorkflows::Nodes::EventParticipationChanged::V1 doprevious_status: nil,removed: false,)+ expect(output[:actor]).to be_nil+ expect(output).to match_node_output_schema(described_class)+ end++ it "reports the user who changed the RSVP as actor", :aggregate_failures do+ organizer = Fabricate(:admin)+ tracked =+ DiscourseEvent.track(:discourse_calendar_post_event_invitee_status_changed) do+ DiscourseEvents::Events::Invitee.create_attendance!(+ user.id,+ event.id,+ :going,+ acting_user: organizer,+ )+ end++ output = described_class.from_event(:any, *tracked[:params]).output++ expect(output[:user][:username]).to eq(user.username)+ expect(output[:actor][:username]).to eq(organizer.username)expect(output).to match_node_output_schema(described_class)enddiff --git a/plugins/discourse-events/spec/services/discourse_events/events/create_invitee_spec.rb b/plugins/discourse-events/spec/services/discourse_events/events/create_invitee_spec.rbindex cc66396e283..68124a51d8d 100644--- a/plugins/discourse-events/spec/services/discourse_events/events/create_invitee_spec.rb+++ b/plugins/discourse-events/spec/services/discourse_events/events/create_invitee_spec.rb@@ -118,6 +118,15 @@ RSpec.describe(DiscourseEvents::Events::CreateInvitee) doit { is_expected.to run_successfully }+ it "publishes the staff member as the acting user" do+ event =+ DiscourseEvent+ .track_events(:discourse_calendar_post_event_invitee_status_changed) { result }+ .first++ expect(event[:params].last).to eq(acting_user: admin)+ end+it "creates the invitee for the other user" doexpect { result }.to change { DiscourseEvents::Events::Invitee.count }.by(1)expect(result[:invitee]).to have_attributes(diff --git a/plugins/discourse-events/spec/services/discourse_events/events/destroy_invitee_spec.rb b/plugins/discourse-events/spec/services/discourse_events/events/destroy_invitee_spec.rbindex 25e8f4e756a..cc29423da50 100644--- a/plugins/discourse-events/spec/services/discourse_events/events/destroy_invitee_spec.rb+++ b/plugins/discourse-events/spec/services/discourse_events/events/destroy_invitee_spec.rb@@ -139,6 +139,15 @@ RSpec.describe(DiscourseEvents::Events::DestroyInvitee) doit { is_expected.to run_successfully }+ it "publishes the staff member as the acting user" do+ event =+ DiscourseEvent+ .track_events(:discourse_calendar_post_event_invitee_status_changed) { result }+ .first++ expect(event[:params].last).to eq(acting_user: admin)+ end+it "destroys the invitee" doexpect { result }.to change { DiscourseEvents::Events::Invitee.count }.by(-1)enddiff --git a/plugins/discourse-events/spec/services/discourse_events/events/update_invitee_spec.rb b/plugins/discourse-events/spec/services/discourse_events/events/update_invitee_spec.rbindex b4b591fe139..a4d1c17a0b3 100644--- a/plugins/discourse-events/spec/services/discourse_events/events/update_invitee_spec.rb+++ b/plugins/discourse-events/spec/services/discourse_events/events/update_invitee_spec.rb@@ -164,6 +164,15 @@ RSpec.describe(DiscourseEvents::Events::UpdateInvitee) doit { is_expected.to run_successfully }+ it "publishes the event creator as the acting user" do+ event =+ DiscourseEvent+ .track_events(:discourse_calendar_post_event_invitee_status_changed) { result }+ .first++ expect(event[:params].last).to eq(acting_user: event_creator)+ end+it "updates the invitee status" doexpect { result }.to change { creator_event_invitee.reload.status }.from(DiscourseEvents::Events::Invitee.statuses[:going],diff --git a/plugins/discourse-solved/app/services/discourse_solved/accept_answer.rb b/plugins/discourse-solved/app/services/discourse_solved/accept_answer.rbindex 798db893b78..fa3982b95ab 100644--- a/plugins/discourse-solved/app/services/discourse_solved/accept_answer.rb+++ b/plugins/discourse-solved/app/services/discourse_solved/accept_answer.rb@@ -186,7 +186,7 @@ class DiscourseSolved::AcceptAnswerenddef publish_solution(post:, topic:, guardian:)- DiscourseEvent.trigger(:accepted_solution, post)+ DiscourseEvent.trigger(:accepted_solution, post, acting_user: guardian.user)MessageBus.publish("/topic/#{topic.id}",{diff --git a/plugins/discourse-solved/app/services/discourse_solved/unaccept_answer.rb b/plugins/discourse-solved/app/services/discourse_solved/unaccept_answer.rbindex 276c05a9938..57ff5d7b156 100644--- a/plugins/discourse-solved/app/services/discourse_solved/unaccept_answer.rb+++ b/plugins/discourse-solved/app/services/discourse_solved/unaccept_answer.rb@@ -87,7 +87,7 @@ class DiscourseSolved::UnacceptAnswerenddef publish_unaccepted(post:, topic:, guardian:)- DiscourseEvent.trigger(:unaccepted_solution, post)+ DiscourseEvent.trigger(:unaccepted_solution, post, acting_user: guardian.user)MessageBus.publish("/topic/#{topic.id}",{diff --git a/plugins/discourse-solved/lib/discourse_workflows/nodes/solution_changed/v1.rb b/plugins/discourse-solved/lib/discourse_workflows/nodes/solution_changed/v1.rbindex 28fb047ac23..8db0ffe65d0 100644--- a/plugins/discourse-solved/lib/discourse_workflows/nodes/solution_changed/v1.rb+++ b/plugins/discourse-solved/lib/discourse_workflows/nodes/solution_changed/v1.rb@@ -17,6 +17,8 @@ if defined?(DiscourseWorkflows)"enum" => CHANGES.values,},),+ DiscourseWorkflows::Schema::POST_AUTHOR_SCHEMA,+ DiscourseWorkflows::Schema::ACTOR_SCHEMA,).freezedescription(@@ -46,10 +48,11 @@ if defined?(DiscourseWorkflows)new(event_name, *args)end- def initialize(event_name, post, *)+ def initialize(event_name, post, payload = {})super(parameters: {})@change = CHANGES[event_name]@post = post+ @actor = payload[:acting_user]enddef valid?@@ -61,6 +64,8 @@ if defined?(DiscourseWorkflows)change: @change,post: serialize_post(@post),topic: serialize_topic_list_item(topic),+ user: serialize_user(@post.user),+ actor: serialize_user(@actor),}enddiff --git a/plugins/discourse-solved/spec/lib/discourse_workflows/nodes/solution_changed_spec.rb b/plugins/discourse-solved/spec/lib/discourse_workflows/nodes/solution_changed_spec.rbindex e6f5a33634f..05b1352450e 100644--- a/plugins/discourse-solved/spec/lib/discourse_workflows/nodes/solution_changed_spec.rb+++ b/plugins/discourse-solved/spec/lib/discourse_workflows/nodes/solution_changed_spec.rb@@ -63,6 +63,10 @@ RSpec.describe DiscourseWorkflows::Nodes::SolutionChanged::V1, discourse_workflo[answer.id, other_answer.id, answer.id],)expect(data.map { |payload| payload.dig("topic", "id") }.uniq).to eq([topic.id])+ expect(data.map { |payload| payload.dig("actor", "username") }.uniq).to eq([admin.username])+ expect(data.map { |payload| payload.dig("user", "id") }).to eq(+ [answer.user_id, other_answer.user_id, answer.user_id],+ )expect(data).to all(match_node_output_schema(described_class))expect(post.topic.reload.topic_answers.pluck(:answer_post_id)).to eq([other_answer.id])enddiff --git a/plugins/discourse-solved/spec/services/discourse_solved/accept_answer_spec.rb b/plugins/discourse-solved/spec/services/discourse_solved/accept_answer_spec.rbindex c4356ce0fb6..754c007a6cd 100644--- a/plugins/discourse-solved/spec/services/discourse_solved/accept_answer_spec.rb+++ b/plugins/discourse-solved/spec/services/discourse_solved/accept_answer_spec.rb@@ -435,7 +435,7 @@ RSpec.describe DiscourseSolved::AcceptAnswer doendit "triggers the :accepted_solution event" do- expect(events).to include(a_hash_including(params: [post]))+ expect(events).to include(a_hash_including(params: [post, { acting_user: }]))endit "broadcasts the accepted solution" dodiff --git a/plugins/discourse-solved/spec/services/discourse_solved/unaccept_answer_spec.rb b/plugins/discourse-solved/spec/services/discourse_solved/unaccept_answer_spec.rbindex e877685d784..a0ef0d9eaf4 100644--- a/plugins/discourse-solved/spec/services/discourse_solved/unaccept_answer_spec.rb+++ b/plugins/discourse-solved/spec/services/discourse_solved/unaccept_answer_spec.rb@@ -163,7 +163,7 @@ RSpec.describe DiscourseSolved::UnacceptAnswer doendit "triggers the :unaccepted_solution event" do- expect(events).to include(a_hash_including(params: [post]))+ expect(events).to include(a_hash_including(params: [post, { acting_user: user }]))endit "broadcasts the unaccepted solution" dodiff --git a/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_lifecycle.rb b/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_lifecycle.rbindex a66cc2926a2..9930b6ebd94 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_lifecycle.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_lifecycle.rb@@ -12,15 +12,20 @@ module DiscourseWorkflowsOUTPUT_CONTRACTS = [{schema:- Schema.merge(Schema::POST_SCHEMA, Schema::TOPIC_LIST_ITEM_SCHEMA, Schema::USER_SCHEMA),+ Schema.merge(+ Schema::POST_SCHEMA,+ Schema::TOPIC_LIST_ITEM_SCHEMA,+ Schema::USER_SCHEMA,+ Schema::ACTOR_SCHEMA,+ ),},].freeze- def initialize(post, opts = nil, user = nil, *)+ def initialize(post, opts = nil, actor = nil, *)super(parameters: {})@post = post@opts = opts- @user = user+ @actor = actorenddef valid?@@ -32,7 +37,8 @@ module DiscourseWorkflows{post: serialize_post(@post),topic: serialize_topic_list_item(topic),- user: serialize_user(@user),+ user: serialize_user(@actor),+ actor: serialize_user(@actor),}enddiff --git a/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_like/v1.rb b/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_like/v1.rbindex a7b298be055..27e57f5dca0 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_like/v1.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_like/v1.rb@@ -5,21 +5,21 @@ module DiscourseWorkflowsmodule PostLikeclass V1 < NodeTypeOPERATIONS = %w[like unlike].freeze- OUTPUT_SCHEMA = {- "$schema" => Schema::DRAFT_URI,- "type" => "object",- "properties" => {- "post_id" => {- "type" => "integer",- },- "username" => {- "type" => "string",- },- "changed" => {- "type" => "boolean",- },- },- }.freeze+ OUTPUT_SCHEMA =+ Schema.merge(+ Schema.document(+ "post_id" => {+ "type" => "integer",+ },+ "username" => {+ "type" => "string",+ },+ "changed" => {+ "type" => "boolean",+ },+ ),+ Schema::ACTOR_SCHEMA,+ ).freezedescription(name: "action:post_like",@@ -81,7 +81,7 @@ module DiscourseWorkflowsraise_node_error!(result.errors.full_messages.join(", "), item_index:) if result.failed?end- { post_id: post.id, username: actor.username, changed: }+ { post_id: post.id, username: actor.username, actor: serialize_user(actor), changed: }endendenddiff --git a/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_like_changed/v1.rb b/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_like_changed/v1.rbindex ce60bfbdc68..b45ca93f734 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_like_changed/v1.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/nodes/post_like_changed/v1.rb@@ -11,6 +11,7 @@ module DiscourseWorkflowsSchema::POST_SCHEMA,Schema::TOPIC_LIST_ITEM_SCHEMA,Schema::USER_SCHEMA,+ Schema::ACTOR_SCHEMA,Schema.document("change" => { "type" => "string", "enum" => CHANGES.values }),).freeze@@ -60,6 +61,7 @@ module DiscourseWorkflowspost: serialize_post(@post),topic: serialize_topic_list_item(@post.topic),user: serialize_user(@user),+ actor: serialize_user(@user),}enddiff --git a/plugins/discourse-workflows/lib/discourse_workflows/nodes/reviewable_approved/v1.rb b/plugins/discourse-workflows/lib/discourse_workflows/nodes/reviewable_approved/v1.rbindex 9e767c42714..59818988466 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/nodes/reviewable_approved/v1.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/nodes/reviewable_approved/v1.rb@@ -21,7 +21,7 @@ module DiscourseWorkflowsenddef output- { reviewable: serialize_reviewable(@reviewable) }+ { reviewable: serialize_reviewable(@reviewable), actor: serialize_user(@actor) }endendenddiff --git a/plugins/discourse-workflows/lib/discourse_workflows/nodes/reviewable_status_changed/v1.rb b/plugins/discourse-workflows/lib/discourse_workflows/nodes/reviewable_status_changed/v1.rbindex a9a82fbe151..c3383ceb06a 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/nodes/reviewable_status_changed/v1.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/nodes/reviewable_status_changed/v1.rb@@ -14,7 +14,9 @@ module DiscourseWorkflowsgroup: "discourse_triggers",palette_visible: false,event: :reviewable_transitioned_to,- output_contracts: [{ schema: Schema::REVIEWABLE_EVENT_SCHEMA }],+ output_contracts: [+ { schema: Schema.merge(Schema::REVIEWABLE_EVENT_SCHEMA, Schema::ACTOR_SCHEMA) },+ ],properties: -> do{statuses: {@@ -43,10 +45,11 @@ module DiscourseWorkflows)end- def initialize(status, reviewable)+ def initialize(status, reviewable, payload = {})super(parameters: {})@status = status.to_s@reviewable = reviewable+ @actor = payload[:acting_user]enddef valid?@@ -56,7 +59,10 @@ module DiscourseWorkflowsenddef output- { reviewable: serialize_reviewable(@reviewable).merge(status: @status) }+ {+ reviewable: serialize_reviewable(@reviewable).merge(status: @status),+ actor: serialize_user(@actor),+ }enddef matches?(trigger_ctx)diff --git a/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_closed/v1.rb b/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_closed/v1.rbindex 29e161674a2..8883ec026a2 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_closed/v1.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_closed/v1.rb@@ -10,12 +10,14 @@ module DiscourseWorkflowsicon: "lock",color: "grey",},- output_contracts: [{ schema: Schema::TOPIC_LIST_ITEM_SCHEMA }],+ output_contracts: [+ { schema: Schema.merge(Schema::TOPIC_LIST_ITEM_SCHEMA, Schema::ACTOR_SCHEMA) },+ ],),)def output- { topic: serialize_topic_list_item(@topic) }+ { topic: serialize_topic_list_item(@topic), actor: serialize_user(@actor) }endendenddiff --git a/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_status_changed/v1.rb b/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_status_changed/v1.rbindex 04ff4a4d6a1..a827cb36d83 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_status_changed/v1.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_status_changed/v1.rb@@ -15,6 +15,7 @@ module DiscourseWorkflowsOUTPUT_SCHEMA =Schema.merge(Schema::TOPIC_LIST_ITEM_SCHEMA,+ Schema::ACTOR_SCHEMA,Schema.document("status" => {"type" => "string",@@ -60,11 +61,12 @@ module DiscourseWorkflows)end- def initialize(topic, status, enabled)+ def initialize(topic, status, enabled, payload = {})super(parameters: {})@topic = topic@status = status.to_s == "autoclosed" ? "closed" : status.to_s@enabled = enabled+ @actor = payload[:acting_user]enddef valid?@@ -76,6 +78,7 @@ module DiscourseWorkflowsdef output{topic: serialize_topic_list_item(@topic),+ actor: serialize_user(@actor),status: @status,enabled: @enabled,change: change,diff --git a/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_tag_changed/v1.rb b/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_tag_changed/v1.rbindex 64cf40555d0..21f74f38c62 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_tag_changed/v1.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/nodes/topic_tag_changed/v1.rb@@ -8,12 +8,10 @@ module DiscourseWorkflowsOUTPUT_SCHEMA =Schema.merge(Schema::TOPIC_LIST_ITEM_SCHEMA,- {- "$schema" => Schema::DRAFT_URI,- "type" => "object",- "properties" =>- %w[old_tags new_tags added_tags removed_tags].index_with { TAG_LIST_SCHEMA },- },+ Schema::ACTOR_SCHEMA,+ Schema.document(+ %w[old_tags new_tags added_tags removed_tags].index_with { TAG_LIST_SCHEMA },+ ),).freezedescription(@@ -50,6 +48,7 @@ module DiscourseWorkflowsnew_tags: @new_tag_names,added_tags: added_tags,removed_tags: removed_tags,+ actor: serialize_user(@user),}enddiff --git a/plugins/discourse-workflows/lib/discourse_workflows/schema.rb b/plugins/discourse-workflows/lib/discourse_workflows/schema.rbindex 20c27afb081..0354e6efc42 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/schema.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/schema.rb@@ -170,6 +170,7 @@ module DiscourseWorkflowsPOST_SCHEMA = entity("post", POST_PROPERTIES, "DiscourseWorkflows::PostSerializer payload")USER_SCHEMA = entity("user", USER_PROPERTIES, "Basic safe user attributes")ACTOR_SCHEMA = document("actor" => nullable_user("User who performed the action"))+ POST_AUTHOR_SCHEMA = document("user" => nullable_user("Post author"))ASSIGNEE_PROPERTIES = {"type" => "object","properties" => {diff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/post_lifecycle_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/post_lifecycle_spec.rbindex 1efeb8adad1..82d1f504868 100644--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/post_lifecycle_spec.rb+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/post_lifecycle_spec.rb@@ -36,7 +36,8 @@ RSpec.describe DiscourseWorkflows::Nodes::PostLifecycle doenddescribe "#output" do- it "returns the post, its topic, and the acting user", :aggregate_failures do+ it "returns the post, its topic and the acting user as both user and actor",+ :aggregate_failures dooutput = trigger.outputexpect(output[:post]).to include(@@ -54,6 +55,7 @@ RSpec.describe DiscourseWorkflows::Nodes::PostLifecycle dousername: topic.user.username,)expect(output[:user]).to include(id: actor.id, username: actor.username)+ expect(output[:actor]).to include(id: actor.id, username: actor.username)expect(output).to match_node_output_schema(klass)enddiff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/post_like_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/post_like_spec.rbindex 5a4e32f2f23..b306cd7b334 100644--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/post_like_spec.rb+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/post_like_spec.rb@@ -15,7 +15,12 @@ RSpec.describe DiscourseWorkflows::Nodes::PostLike::V1 doit "likes the post as the actor" doresult = execute_node(configuration:)- expect(result).to eq("post_id" => post.id, "username" => actor.username, "changed" => true)+ expect(result).to include(+ "post_id" => post.id,+ "username" => actor.username,+ "changed" => true,+ "actor" => include("username" => actor.username),+ )expect(result).to match_node_output_schema(described_class)expect(post.reload.like_count).to eq(1)enddiff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/reviewable_approved_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/reviewable_approved_spec.rbindex 0e29f3bbe4b..c772e8d5aae 100644--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/reviewable_approved_spec.rb+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/reviewable_approved_spec.rb@@ -42,10 +42,12 @@ RSpec.describe DiscourseWorkflows::Nodes::ReviewableApproved::V1 dodescribe "#output" doit "returns reviewable data", :aggregate_failures do+ moderator = Fabricate(:moderator)reviewable.update!(status: :approved)- output = described_class.new(:approved, reviewable).output+ output = described_class.new(:approved, reviewable, acting_user: moderator).outputexpect(output[:reviewable]).to include(status: "approved")+ expect(output[:actor]).to include(id: moderator.id, username: moderator.username)expect(output).to match_node_output_schema(described_class)endenddiff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/reviewable_status_changed_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/reviewable_status_changed_spec.rbindex 6dd73f18785..59f65af709d 100644--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/reviewable_status_changed_spec.rb+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/reviewable_status_changed_spec.rb@@ -43,6 +43,21 @@ RSpec.describe DiscourseWorkflows::Nodes::ReviewableStatusChanged::V1 doenddescribe "#output" do+ it "exposes the new status and the reviewer who transitioned the reviewable",+ :aggregate_failures do+ moderator = Fabricate(:moderator)+ events =+ DiscourseEvent.track_events(:reviewable_transitioned_to) do+ reviewable.transition_to(:rejected, moderator)+ end++ output = described_class.new(*events.sole[:params]).output++ expect(output[:reviewable]).to include(status: "rejected")+ expect(output[:actor]).to include(id: moderator.id, username: moderator.username)+ expect(output).to match_node_output_schema(described_class)+ end+it "uses the target account for user reviewables" doreviewable_user = Fabricate(:reviewable_user)diff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_closed_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_closed_spec.rbindex 1378a6b856f..0662f6242e2 100644--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_closed_spec.rb+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_closed_spec.rb@@ -10,12 +10,14 @@ RSpec.describe DiscourseWorkflows::Nodes::TopicClosed::V1 doenddescribe "#output" do- it "returns topic_id and tags" do- trigger = described_class.new(topic, "closed", true)- output = trigger.output+ it "returns the topic and the actor", :aggregate_failures do+ moderator = Fabricate(:moderator)+ output = described_class.new(topic, "closed", true, acting_user: moderator).outputexpect(output[:topic][:id]).to eq(topic.id)expect(output[:topic][:tags].map { |topic_tag| topic_tag[:name] }).to eq(["test-tag"])+ expect(output[:actor]).to include(id: moderator.id, username: moderator.username)+ expect(output).to match_node_output_schema(described_class)endenddiff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_status_changed_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_status_changed_spec.rbindex d715b54fb26..949a91c98a5 100644--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_status_changed_spec.rb+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_status_changed_spec.rb@@ -34,7 +34,7 @@ RSpec.describe DiscourseWorkflows::Nodes::TopicStatusChanged::V1 dooutput = trigger.outputexpect(output).to match_node_output_schema(node_class)if change == "closed"- expect(output.keys).to eq([:topic])+ expect(output.keys).to eq(%i[topic actor])elseexpect(output).to include(status: status, enabled: enabled, change: change)end@@ -76,6 +76,19 @@ RSpec.describe DiscourseWorkflows::Nodes::TopicStatusChanged::V1 doendend+ it "exposes the user who changed the status" do+ admin = Fabricate(:admin)+ events =+ DiscourseEvent.track_events(:topic_status_updated) do+ topic.update_status("archived", true, admin)+ end++ output = described_class.new(*events.sole[:params]).output++ expect(output[:actor]).to include(id: admin.id, username: admin.username)+ expect(output).to match_node_output_schema(described_class)+ end+describe "#matches?" doit "matches selected changes including automatic changes" dotrigger = described_class.new(topic, "autoclosed", false)diff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_tag_changed_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_tag_changed_spec.rbindex bd721b58d47..4e20cbe2a5b 100644--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_tag_changed_spec.rb+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/nodes/topic_tag_changed_spec.rb@@ -44,6 +44,7 @@ RSpec.describe DiscourseWorkflows::Nodes::TopicTagChanged::V1 doexpect(output[:added_tags]).to eq(%w[urgent])expect(output[:removed_tags]).to eq(%w[help])expect(output[:topic][:posters].map { |poster| poster[:user_id] }).to include(topic.user_id)+ expect(output[:actor]).to include(id: topic.user.id, username: topic.user.username)expect(output).to match_node_output_schema(described_class)enddiff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rbindex ffbabfd4563..b6d12fccb0a 100644--- a/spec/models/reviewable_spec.rb+++ b/spec/models/reviewable_spec.rb@@ -640,6 +640,7 @@ RSpec.describe Reviewable, type: :model doexpect(event).to be_presentexpect(event[:params][0]).to eq(:approved)expect(event[:params][1]).to eq(reviewable)+ expect(event[:params][2]).to eq(acting_user: moderator)endenddiff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex 537dfbe8a2f..53d444f0a52 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -1610,7 +1610,9 @@ RSpec.describe Topic do2.times { topic.update_status("closed", true, user) }end- expect(events.map { |event| event[:params] }).to eq([[topic, "closed", true]])+ expect(events.map { |event| event[:params] }).to eq(+ [[topic, "closed", true, { acting_user: user }]],+ )endit "emits pin status events only when pin attributes change" do@@ -1624,7 +1626,10 @@ RSpec.describe Topic doendexpect(events.map { |event| event[:params] }).to eq(- [[topic, "pinned", true], [topic, "pinned", false]],+ [+ [topic, "pinned", true, { acting_user: user }],+ [topic, "pinned", false, { acting_user: user }],+ ],)end@@ -1642,9 +1647,9 @@ RSpec.describe Topic doexpect(events.map { |event| event[:params] }).to eq([- [topic, "pinned", true],- [topic, "pinned_globally", true],- [topic, "pinned_globally", true],+ [topic, "pinned", true, { acting_user: user }],+ [topic, "pinned_globally", true, { acting_user: user }],+ [topic, "pinned_globally", true, { acting_user: user }],],)enddiff --git a/spec/services/topic_status_updater_spec.rb b/spec/services/topic_status_updater_spec.rbindex dbd7c6aa5eb..00182607eb9 100644--- a/spec/services/topic_status_updater_spec.rb+++ b/spec/services/topic_status_updater_spec.rb@@ -23,7 +23,9 @@ RSpec.describe TopicStatusUpdater dodescribed_class.new(topic, admin).update!("closed", true)end- expect(events.map { |event| event[:params] }).to eq([[topic, "closed", true]])+ expect(events.map { |event| event[:params] }).to eq(+ [[topic, "closed", true, { acting_user: admin }]],+ )ensureDiscourseEvent.off(:topic_status_updated, &handler) if handlerend