According to a reply by @Falco on my post, there’s a way to set users to watch categories using the API. I’ve spent hours searching the web and combing through the API documentation but I cannot find this call.
Does anyone know what API call could be used to set a user to watch a specific category?
You can search for "reverse engineer api " for tips on how to figure out the API call. Also, there is a plugin that will make people in a certain group follow a set of categories.
Thanks for the reply @pfaffman. Are you suggesting the API documentation is incomplete and I need to reverse engineer the API code to find the undocumented API call?
I’m sure @Osama’s method works, but setting user watches via the category seemed a bit weird to me. The following sets the watch list directly against the user (This is via python requests, but shows what is required).
DISCOURSE_URL - domain, including http(s)
username - user to change
DISCOURSE_API_KEY - api key generated by, and associated with a user
DISCOURSE_API_USERNAME - user who the key is associated with
watch_category - a list of categories the user should be watching
Não tenho certeza se esse código consegue fazer o que estou procurando, mas…
Gostaria de adicionar um hiperlink que tivesse algum tipo de parâmetro de URL que, quando um usuário clicasse no link, o status dele fosse Definido como Assistindo/Rastreando/Normal/Silenciado para uma categoria específica.
Um caso de uso prático seria: em vez de eu dizer às pessoas para Visitarem a categoria… e clicarem no ícone do sino e escolherem _____… eu poderia dizer algo como…
CLIQUE AQUI se você quiser ser notificado sempre que uma nova postagem for adicionada a este fórum.
Então, quando o usuário clicar nesse hiperlink, ele será inscrito no nível que definirmos no parâmetro da URL.
Acho que isso seria relativamente simples de implementar como um plugin ou componente de tema, algum tipo de entidade incorporável que possa realizar essas ações por você. O problema com o código AJAX postado acima é que você está enviando a chave de API global de todos os usuários para o cliente. Isso é totalmente uma má ideia.
O problema que você terá ao criar um link, conforme mencionado pelo autor do tópico (OP), é que a chamada à API exige uma ação REST POST, enquanto links só podem emitir uma ação REST GET.