Unlist topic with Ruby?


(Joe Seyfried) #1

Hi all, extensive grep’ing did not produce any usable results, so here’s my tiny question: how do I unlist a topic from Ruby?


(Robin Ward) #2

Looks like we have some tech debt as invisbile was renamed to unlisted.

It is changed by calling Topic#update_status with :visible - discourse/topic.rb at master · discourse/discourse · GitHub


(Jens Maier) #3
topic = Topic.find(topic_id)
user = User.find(moderator_id) || Discourse.system_user
topic.update_status(:visible, false, user)

(Joe Seyfried) #4

Perfect, you two - works like a charm. Thanks!


(Régis Hanol) #5