using Microsoft.AspNetCore.Mvc; using PhilExampleCrawler.Common.Models; using PhilExampleCrawler.DataBase; using PhilExampleCrawler.DataBase.Models; namespace WebAPI.Controllers { [ApiController] [Route("[controller]")] public class UserController : ControllerBase { private readonly ILogger _logger; public UserController(ILogger logger) { _logger = logger; } [HttpGet(Name = "GetUser")] public async Task GetAsync(int userID) { var user = await ThreadSafeCache.GetUserAsync(userID); return user; } [HttpPost(Name = "RegisterUser")] public async Task PostAsync(string authCode, string phoneNumber, bool optin_telegram) { if (authCode == null) return null; if (optin_telegram && phoneNumber == null) return null; User? user = await ThreadSafeCache.AddUserAsync(authCode, phoneNumber, optin_telegram); return user; } } }