1
0

ejabber.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. from core.config import EJ_URL, DEBUG
  2. import requests
  3. def ej_execute(command, data):
  4. """
  5. API request to jabber server
  6. """
  7. url = EJ_URL + command
  8. if DEBUG: print(f"[URL]: {url}")
  9. res = requests.post(url, json=data)
  10. return res
  11. def pick_support():
  12. return "support"
  13. def get_rooms(service, order_num, support, client, provider):
  14. """
  15. Create names and member list for each room.
  16. Returns a dict {room_name: ("member1", "member2", ...)}
  17. """
  18. service = service.lower()
  19. # Set room names
  20. room_name1 = "_".join(str(attr) for attr in (service, order_num, client, support))
  21. room_name2 = "_".join(str(attr) for attr in (service, order_num, client, "with", provider))
  22. room_name3 = "_".join(str(attr) for attr in (service, order_num, provider, support))
  23. # Set room participants
  24. rooms = {
  25. room_name1: ("client", "support", "owner"),
  26. room_name2: ("client", "provider", "owner"),
  27. room_name3: ("provider", "support", "owner"),
  28. }
  29. return rooms