Add MAX contacts and direct chat creation
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QMax.Api.Contracts;
|
||||
using QMax.Api.Infrastructure.Max;
|
||||
|
||||
namespace QMax.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/contacts")]
|
||||
public sealed class ContactsController(IMaxBridgeClient maxBridge) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IReadOnlyList<ContactDto>>> GetContacts(CancellationToken cancellationToken)
|
||||
{
|
||||
var contacts = await maxBridge.FetchContactsAsync(cancellationToken);
|
||||
return contacts
|
||||
.Select(contact => new ContactDto(
|
||||
contact.UserId,
|
||||
contact.ExternalChatId,
|
||||
contact.DisplayName,
|
||||
contact.AvatarUrl,
|
||||
contact.PhoneNumber,
|
||||
contact.Status))
|
||||
.OrderBy(contact => contact.DisplayName, StringComparer.CurrentCultureIgnoreCase)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user