A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4 KiB

  1. export namespace JsonAPI {
  2. export let principleName: string = localStorage.getItem("username") || "";
  3. export let contactName: string = "";
  4. export let authToken: string = localStorage.getItem("authToken") || "";
  5. export const CHAT_PAGE_SIZE: number = parseInt(localStorage.getItem("CHAT_PAGE_SIZE") || "9") || 9;
  6. export const ACTIVE_USERS_GET = `/api/chat/get/active-users`;
  7. /**
  8. * Json API URL for retrieving all messages between two users
  9. *
  10. * ### With sprintf
  11. * const url = Sprintf(JsonAPI.CHAT_MESSAGES_GET, contactName);
  12. *
  13. * @format /api/chat/get/messages/{contactName}
  14. * @example /api/chat/get/messages/some-user
  15. *
  16. *
  17. * @param contactName
  18. * The user whose messages we wish to retrieve.
  19. */
  20. export const CHAT_MESSAGES_GET = `/api/chat/get/messages/%s`;
  21. export const MESSAGE_POST = "/api/chat/post/message";
  22. /**
  23. * Json API URL for retrieving paginated messages between two users
  24. * Page index starts with 0
  25. *
  26. * ### With sprintf
  27. * const url = Sprintf(JsonAPI.CHAT_MESSAGES_GET, contactName);
  28. *
  29. * @example /api/chat/get/messages/some-user?page=0&size=5 will give the first page where each page has size 5
  30. *
  31. *
  32. *
  33. * @param contactName the user whose messages we wish to retrieve
  34. * @param page denotes the page required
  35. * @param size denotes the size of each page
  36. */
  37. export const CHAT_MESSAGE_PAGE_GET = `/api/chat/get/messages/%s?page=%d&size=%d`;
  38. }