Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Rubick65/calenderyBack/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The chat API manages conversation threads between pairs of users. Every direct message exchange lives inside a Chat record that links exactly two users. All endpoints below require a valid authenticated session with ROLE_USER.

Chat domain entity

FieldTypeDescription
idLongUnique identifier for the conversation
user1UserFirst participant (full User object)
user2UserSecond participant (full User object)

Endpoints

POST /api/chat/saveChat

Creates a new conversation between two users. Returns the ID of the newly persisted chat record. Authentication: ROLE_USER Request body — ChatDto
FieldTypeRequiredDescription
user1LongID of the first participant
user2LongID of the second participant
Response 200 OKChatId
FieldTypeDescription
idChatLongID of the newly created chat
Before calling saveChat, always call getUserChat first to check whether a conversation between the two users already exists. Creating a duplicate chat will result in a second thread being opened between the same pair of users.
curl -X POST "http://localhost:8080/api/chat/saveChat" \
  -H "Authorization: Basic $(echo -n 'user@example.com:password' | base64)" \
  -H "Content-Type: application/json" \
  -d '{
    "user1": 1,
    "user2": 2
  }'
Example response
{
  "idChat": 42
}

GET /api/chat/getChat

Retrieves a single chat record by its ID. Authentication: ROLE_USER Query parameters
ParameterTypeRequiredDescription
idChatLongThe chat ID to fetch
Response 200 OKChatDto
FieldTypeDescription
idLongUnique identifier of the chat
user1LongID of the first participant
user2LongID of the second participant
curl -X GET "http://localhost:8080/api/chat/getChat?idChat=42" \
  -H "Authorization: Basic $(echo -n 'user@example.com:password' | base64)"
Example response
{
  "id": 42,
  "user1": 1,
  "user2": 2
}

GET /api/chat/getUserChats

Returns all chats in which the specified user is a participant (either as user1 or user2). Authentication: ROLE_USER Query parameters
ParameterTypeRequiredDescription
idUsuarioLongThe user whose conversation list to fetch
Response 200 OKList<ChatDto> An array of ChatDto objects (same shape as /getChat).
curl -X GET "http://localhost:8080/api/chat/getUserChats?idUsuario=1" \
  -H "Authorization: Basic $(echo -n 'user@example.com:password' | base64)"
Example response
[
  {
    "id": 42,
    "user1": 1,
    "user2": 2
  },
  {
    "id": 57,
    "user1": 1,
    "user2": 9
  }
]

GET /api/chat/getUserChat

Resolves the shared chat ID between the authenticated user and another user identified by idUsuario. The server derives the authenticated user’s ID from the current Authentication principal (their email), then looks up the matching Chat row. This endpoint is the canonical way to open a direct message thread: resolve the chat ID, then subscribe to the WebSocket queue or load message history via REST. Authentication: ROLE_USER Query parameters
ParameterTypeRequiredDescription
idUsuarioLongID of the other user in the conversation
Response 200 OKChatId
FieldTypeDescription
idChatLongID of the chat shared by the two users
curl -X GET "http://localhost:8080/api/chat/getUserChat?idUsuario=2" \
  -H "Authorization: Basic $(echo -n 'user@example.com:password' | base64)"
Example response
{
  "idChat": 42
}

The checkIfChatExists query

Internally, CalenderyBack exposes a CheckIfChatExistsHandler that accepts a user email and a target user ID, and returns a simple boolean. This logic is also used by the user profile flow to tell the client whether it should show an “Open Chat” or a “Start Chat” action when viewing another user’s profile. It queries the chat repository on both the (user1, user2) and (user2, user1) axis so the result is direction-agnostic.
getUserChat relies on the same underlying repository method as checkIfChatExists. If no chat row is found, the handler throws a domain exception — always verify the chat exists before trying to resolve its ID.

Build docs developers (and LLMs) love