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
No estoy seguro de si este código puede lograr lo que busco, pero…
Me gustaría agregar un hipervínculo que tenga algún tipo de parámetro de URL para que, cuando un usuario haga clic en el enlace, esté Observando/Rastreando/Normal/En silencio para una categoría en particular.
Un caso de uso práctico sería, en lugar de decirle a la gente que Visite la categoría… y haga clic en el icono de la campana y elija _____…, podría decir algo como…
HAZ CLIC AQUÍ si quieres ser notificado cada vez que se agregue una nueva publicación a este foro.
Entonces, cuando el usuario hace clic en ese hipervínculo, se suscribe al nivel que definimos en el parámetro de la URL.
Creo que esto sería relativamente sencillo de implementar como un plugin o un componente de tema, algún tipo de entidad incrustable que pueda realizar estas acciones por ti. El problema con el código AJAX publicado anteriormente es que estás enviando la clave API global de todos los usuarios al cliente. Esto es absolutamente una mala idea.
El problema que encontrarás al crear un enlace, como indica el autor del tema original (OP), es que la llamada a la API requiere una acción REST POST, mientras que los enlaces solo pueden ejecutar una acción REST GET.