Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions src/backend/Hermes.SituationRoom.Web/Controllers/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class ChatController(IControllerInfrastructure controllerInfrastructure,
{
[HttpPost("internal/chats")]
[SwaggerOperation(Tags = [SwaggerTagDescriptions.ENDPOINT_TAG_INTERNAL_CHAT])]
[ProducesResponseType(typeof(string), StatusCodes.Status201Created)]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> AddAsync([FromBody] ChatBo newChatBo) => Ok(await chatService.AddAsync(newChatBo));
public async Task<ActionResult<Guid>> AddAsync([FromBody] ChatBo newChatBo) => Ok(await chatService.AddAsync(newChatBo));

[HttpGet("internal/chats/{chatId:guid}")]
[SwaggerOperation(Tags = [SwaggerTagDescriptions.ENDPOINT_TAG_INTERNAL_CHAT])]
Expand All @@ -44,17 +44,6 @@ [FromQuery] [Required] Guid user2Id
return Ok(chat);
}

[HttpGet("internal/chats/get-or-create-by-user-pair")]
[SwaggerOperation(Tags = [SwaggerTagDescriptions.ENDPOINT_TAG_INTERNAL_CHAT])]
[ProducesResponseType(typeof(ChatBo), StatusCodes.Status200OK)]
public async Task<ActionResult<ChatBo>> GetOrCreateChatByUserPairAsync([FromQuery] [Required] Guid user1Id,
[FromQuery] [Required] Guid user2Id
)
{
var chat = await chatService.GetOrCreateChatByUserPairAsync(user1Id, user2Id);
return Ok(chat);
}

[HttpGet("internal/chats/by-user/{userId:guid}")]
[SwaggerOperation(Tags = [SwaggerTagDescriptions.ENDPOINT_TAG_INTERNAL_CHAT])]
[ProducesResponseType(typeof(IReadOnlyList<ChatBo>), StatusCodes.Status200OK)]
Expand Down
12 changes: 8 additions & 4 deletions src/frontend/src/services/api/chats-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ export default function chatsApi(apiBaseClient: ApiBaseClient) {
* This method will never return 404 - it creates the chat if it doesn't exist
*/
async getOrCreateChatByUserPair(user1Id: string, user2Id: string): Promise<BaseResultBo<ChatBo>> {
const params = {
user1Id: user1Id,
user2Id: user2Id
const createChatDto = {
user1Uid: user1Id,
user2Uid: user2Id
};
return await apiBaseClient.get<ChatBo>('services/api/internal/chats/get-or-create-by-user-pair', params);

const response = await apiBaseClient.post<CreateChatDto>('services/api/internal/chats', createChatDto);
const chatId = response.data;

return await apiBaseClient.get<ChatBo>(`services/api/internal/chats/${chatId}`);
},

/**
Expand Down