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
Non sono sicuro che questo codice possa realizzare ciò che ho in mente, ma…
Vorrei aggiungere un collegamento ipertestuale con un parametro URL che, quando un utente clicca sul link, imposti lo stato di Osservazione/Tracciamento/Normale/Muto per una determinata categoria.
Un caso d’uso pratico sarebbe: invece di dire alle persone di visitare la categoria… e cliccare sull’icona della campanella per scegliere _____, potrei dire qualcosa come…
CLICCA QUI se vuoi ricevere una notifica ogni volta che viene aggiunto un nuovo post a questo forum.
Così, quando l’utente clicca sul collegamento ipertestuale, viene iscritto al livello definito nel parametro dell’URL.
Penso che sarebbe relativamente semplice implementarlo come plugin o componente del tema, una sorta di entità incorporabile in grado di eseguire queste azioni per te. Il problema con il codice AJAX pubblicato sopra è che stai inviando la chiave API globale di tutti gli utenti al client. Questa è assolutamente una cattiva idea.
Il problema che incontrerai creando un link, come indicato dall’OP, è che la chiamata API richiede un’azione REST POST, mentre i link possono emettere solo un’azione REST GET.