I’d like to be able to create messages that are assigned to specific users. Is this something that is possible already and I am missing something, or that you would consider adding?
I am not seeing reference to the assign plugin in the API docs. Seems to me an e.g. assigned_to=usernname should be an option.
The background to this is that I am using discourse as a ticket system, using @angus’s Tickets Plugin 🎟. The easiest way for me to allow members to create tickets is to create a gravity form in wordpress that creates the message in discourse. I know this can work and I have the rest of it lined up, just not the ability to assign tickets to specific users upon creation.
I need to create topics by API as staged users (sender does not need to have account in Discourse), so I have to do it by the /admin/email/handle_mail endpoint. But it does not return topic ID and seems to work in a batch.
What is the best way how to assign that topic?
The best for me would be if /admin/email/handle_mail endpoint could accept an assign field.
J’utilise le plugin Discourse Assign et j’ai réussi à le faire fonctionner, voici le code Python :
import requests
# Vous pouvez l'obtenir en faisant de l'ingénierie inverse de la requête d'assignation et en vérifiant les paramètres et les valeurs dans la console comme quelqu'un l'a mentionné auparavant :)
base_url = 'VOTRE_URL'
endpoint = '/assign/assign'
payload = {
'username': 'NOM_UTILISATEUR', # Le nom d'utilisateur de la personne à qui vous voulez assigner le sujet
'group_name': '',
'target_id': NUMERO_DU_SUJET,
'target_type': 'Topic'
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'URL_DU_SUJET',
'Accept': '*/*',
'Api-Key': 'VOTRE_CLE_API',
'Api-Username': 'VOTRE_NOM_UTILISATEUR'
}
response = requests.put(f"{base_url}{endpoint}", data=payload, headers=headers)
if response.status_code == 200:
print("Assignation réussie !")
else:
print(f"L'assignation a échoué avec le code d'état {response.status_code}: {response.text}")