FEATURE: add staff action logs for watched words (PR #13574)


Do we want to log if the watch word was updated instead of created?

    WatchedWord.where(action: action).find_each do |watched_word|

I think we should wrap this in a DB transaction or at least only log after watched_word.destroy! does not raise an error.

Ditto: FEATURE: add staff action logs for watched words by techAPJ · Pull Request #13574 · discourse/discourse · GitHub

I think we should avoid repeating this code twice and refactor it into the WatchWord model.

For consistency with other actions, maybe watched_word_create and watched_word_destroy.

  describe '#log_watched_words_creation' do
  describe '#log_watched_words_deletion' do

I believe it’s fine to log update as created otherwise we’ll need to add another user action for update type and keep track of watched word updates.

Thanks for the review @tgxworld! Updated the PR per feedback.

  def get_watched_work_details(watched_word)

I think get_details is too generic considering the method is defined in the staff_action_logger. Otherwise, I think moving this method to the WatchedWord model might not be a bad idea.

I agree. I’ve the method to WatchedWord model.