ejabber.py 999 B

123456789101112131415161718192021222324252627282930313233
  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. # Set room names
  19. room_name1 = "_".join(str(attr) for attr in (service, order_num, client, support))
  20. room_name2 = "_".join(str(attr) for attr in (service, order_num, client, "with", provider))
  21. room_name3 = "_".join(str(attr) for attr in (service, order_num, provider, support))
  22. # Set room participants
  23. rooms = {
  24. room_name1: ("client", "support", "owner"),
  25. room_name2: ("client", "provider", "owner"),
  26. room_name3: ("provider", "support", "owner"),
  27. }
  28. return rooms