API call to watch categories and tags

Based on the plugin, I wrote a ruby snippet to execute in the rails console (get a shell in your docker using ./launcher enter app and then rails c).

# based on https://github.com/discourse/discourse-watch-category-mcneel/blob/master/plugin.rb

# let a group watch or watch_first_post a category

group_name = "trust_level_0"
category_slug = "news"

group = Group.find_by_name(group_name)
category = Category.find_by_slug(category_slug)

unless category.nil? || group.nil?
  group.users.each do |user|
    # levels: :watching :watching_first_post
    level = :watching_first_post
    watched_categories = CategoryUser.lookup(user, level).pluck(:category_id)
    CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[level], category.id) unless watched_categories.include?(category.id)
  end
end

I had some troubles when I pasted the code into the console due to less that displays the results of the query for the group and category and consumes apparently some following code lines.