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.
Preciso criar tópicos via API como usuários em estágio (o remetente não precisa ter conta no Discourse), então tenho que fazer isso pelo endpoint /admin/email/handle_mail. No entanto, ele não retorna o ID do tópico e parece funcionar em lote.
Qual é a melhor maneira de atribuir esse tópico?
O ideal para mim seria se o endpoint /admin/email/handle_mail pudesse aceitar um campo de atribuição.
Estou usando o plugin Discourse Assign e consegui fazer funcionar, aqui está o código Python:
import requests
# Você pode obter isso por engenharia reversa da solicitação de atribuição e verificando os parâmetros e valores no console, como alguém mencionou antes :)
base_url = 'SUA_URL'
endpoint = '/assign/assign'
payload = {
'username': 'SEU_NOME_DE_USUÁRIO', # O nome de usuário da pessoa para quem você deseja atribuir o tópico
'group_name': '',
'target_id': NUMERO_DO_TOPICO,
'target_type': 'Topic'
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'URL_DO_TOPICO',
'Accept': '*/*',
'Api-Key': 'SUA_API_KEY',
'Api-Username': 'SEU_NOME_DE_USUÁRIO'
}
response = requests.put(f"{base_url}{endpoint}", data=payload, headers=headers)
if response.status_code == 200:
print("Atribuição bem-sucedida!")
else:
print(f"Falha na atribuição com código de status {response.status_code}: {response.text}")