using RecRoomArchive.Models.API.Activities; using System.Text.Json; namespace RecRoomArchive.Services { /// /// Service used to get the message of the day as it is used in multiple areas of the server /// public class MessageOfTheDayService { /// /// HttpClient for making requests to Gitea /// private static readonly HttpClient httpClient = new(); /// /// MessageOfTheDay reference /// private static string? MessageOfTheDay { get; set; } /// /// Gets the message of the day from Gitea. If the URL cannot be resolved, it will fall back to "Welcome to RecRoomArchive!" /// /// String related to the Message of the Day public async Task GetMessageOfTheDay() { // I wouldn't want to re-request the MOTD from the server a bunch of times... if (string.IsNullOrEmpty(MessageOfTheDay)) { //var motd = await httpClient.GetAsync($"https://git.recroomarchive.org/RecRoomArchive/RRAC/raw/branch/main/MOTD"); //if (!motd.IsSuccessStatusCode) // return "Welcome to RecRoomArchive!"; //MessageOfTheDay = await motd.Content.ReadAsStringAsync(); MessageOfTheDay = "Welcome to RecRoomArchive!"; } return MessageOfTheDay; } // move out of motdservice private DateTime CharadesWordsLastFetchedAt { get; set; } private List CachedCharadesWords { get; set; } = []; public async Task > GetCharadesWordsList() { if (CharadesWordsLastFetchedAt - DateTime.UtcNow > TimeSpan.FromMinutes(30)) return CachedCharadesWords; //var request = await httpClient.GetAsync("https://git.recroomarchive.org/RecRoomArchive/RRAC/raw/branch/main/CharadesWords"); //if (!request.IsSuccessStatusCode) // return []; //var words = await request.Content.ReadAsStringAsync(); //if (words == null) // return []; return []; //CachedCharadesWords = JsonSerializer.Deserialize>(words)!; //return CachedCharadesWords; } } }