Skip to content

Commit f11e2ef

Browse files
LukasHuebscherLukas Huebscher
andauthored
Remove chat endpoint that creates chat with two userids (#64)
Co-authored-by: Lukas Huebscher <lukas.huebscher@roche.com>
1 parent 1204c17 commit f11e2ef

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

src/backend/Hermes.SituationRoom.Web/Controllers/ChatController.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public class ChatController(IControllerInfrastructure controllerInfrastructure,
1818
{
1919
[HttpPost("internal/chats")]
2020
[SwaggerOperation(Tags = [SwaggerTagDescriptions.ENDPOINT_TAG_INTERNAL_CHAT])]
21-
[ProducesResponseType(typeof(string), StatusCodes.Status201Created)]
21+
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
2222
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
23-
public async Task<IActionResult> AddAsync([FromBody] ChatBo newChatBo) => Ok(await chatService.AddAsync(newChatBo));
23+
public async Task<ActionResult<Guid>> AddAsync([FromBody] ChatBo newChatBo) => Ok(await chatService.AddAsync(newChatBo));
2424

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

47-
[HttpGet("internal/chats/get-or-create-by-user-pair")]
48-
[SwaggerOperation(Tags = [SwaggerTagDescriptions.ENDPOINT_TAG_INTERNAL_CHAT])]
49-
[ProducesResponseType(typeof(ChatBo), StatusCodes.Status200OK)]
50-
public async Task<ActionResult<ChatBo>> GetOrCreateChatByUserPairAsync([FromQuery] [Required] Guid user1Id,
51-
[FromQuery] [Required] Guid user2Id
52-
)
53-
{
54-
var chat = await chatService.GetOrCreateChatByUserPairAsync(user1Id, user2Id);
55-
return Ok(chat);
56-
}
57-
5847
[HttpGet("internal/chats/by-user/{userId:guid}")]
5948
[SwaggerOperation(Tags = [SwaggerTagDescriptions.ENDPOINT_TAG_INTERNAL_CHAT])]
6049
[ProducesResponseType(typeof(IReadOnlyList<ChatBo>), StatusCodes.Status200OK)]

src/frontend/src/services/api/chats-api.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ export default function chatsApi(apiBaseClient: ApiBaseClient) {
3434
* This method will never return 404 - it creates the chat if it doesn't exist
3535
*/
3636
async getOrCreateChatByUserPair(user1Id: string, user2Id: string): Promise<BaseResultBo<ChatBo>> {
37-
const params = {
38-
user1Id: user1Id,
39-
user2Id: user2Id
37+
const createChatDto = {
38+
user1Uid: user1Id,
39+
user2Uid: user2Id
4040
};
41-
return await apiBaseClient.get<ChatBo>('services/api/internal/chats/get-or-create-by-user-pair', params);
41+
42+
const response = await apiBaseClient.post<CreateChatDto>('services/api/internal/chats', createChatDto);
43+
const chatId = response.data;
44+
45+
return await apiBaseClient.get<ChatBo>(`services/api/internal/chats/${chatId}`);
4246
},
4347

4448
/**

0 commit comments

Comments
 (0)