FIX: No small action created when a non-author removes itself from a PM (#20502)

Fixes a small issue where allowed user removes themselves from a private message before the post activity (small action) is created.

I also added some test coverage to prevent regression.

/t/92811
This commit is contained in:
David Battersby
2023-03-02 13:47:54 +08:00
committed by GitHub
parent 607c123d90
commit 96d03ea9c0
2 changed files with 18 additions and 2 deletions

View File

@ -1103,14 +1103,13 @@ class Topic < ActiveRecord::Base
topic_user = topic_allowed_users.find_by(user_id: user.id)
if topic_user
topic_user.destroy
if user.id == removed_by&.id
add_small_action(removed_by, "user_left", user.username)
else
add_small_action(removed_by, "removed_user", user.username)
end
topic_user.destroy
return true
end
end