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.
Ich muss Topics über die API als gestaffelte Benutzer erstellen (der Absender muss kein Konto in Discourse haben), daher muss ich dies über den Endpunkt /admin/email/handle_mail tun. Dieser Endpunkt gibt jedoch keine Topic-ID zurück und scheint im Batch-Modus zu arbeiten.
Was ist der beste Weg, um dieses Topic zuzuweisen?
Am besten wäre es für mich, wenn der Endpunkt /admin/email/handle_mail ein Feld „assign
ich benutze das Discourse Assign-Plugin und habe es geschafft. Hier ist der Python-Code:
import requests
# Diesen kannst du erhalten, indem du die Assign-Anfrage umkehrst und die Parameter und Werte in der Konsole überprüfst, wie bereits jemand erwähnt hat :)
base_url = 'DEINE_URL'
endpoint = '/assign/assign'
payload = {
'username': 'BENUTZERNAME', # Der Benutzername der Person, der du das Thema zuweisen möchtest
'group_name': '',
'target_id': THEMA_NUMMER,
'target_type': 'Topic'
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'URL_DES_THEMAS',
'Accept': '*/*',
'Api-Key': 'DEIN_API_SCHLÜSSEL',
'Api-Username': 'DEIN_BENUTZERNAME'
}
response = requests.put(f"{base_url}{endpoint}", data=payload, headers=headers)
if response.status_code == 200:
print("Zuweisung erfolgreich!")
else:
print(f"Zuweisung fehlgeschlagen mit Statuscode {response.status_code}: {response.text}")