diff --git a/.idea/.idea.Abyss/.idea/dataSources.local.xml b/.idea/.idea.Abyss/.idea/dataSources.local.xml index 89fd2d7..087b8e5 100644 --- a/.idea/.idea.Abyss/.idea/dataSources.local.xml +++ b/.idea/.idea.Abyss/.idea/dataSources.local.xml @@ -1,6 +1,6 @@ - + " diff --git a/.idea/.idea.Abyss/.idea/workspace.xml b/.idea/.idea.Abyss/.idea/workspace.xml index caadd27..6af6c93 100644 --- a/.idea/.idea.Abyss/.idea/workspace.xml +++ b/.idea/.idea.Abyss/.idea/workspace.xml @@ -11,16 +11,9 @@ - - - - - - - - - + + - { "associatedIndex": 3 @@ -117,34 +110,34 @@ - { + "keyToString": { + ".NET Launch Settings Profile.Abyss: http.executor": "Run", + ".NET Launch Settings Profile.Abyss: https.executor": "Debug", + ".NET Project.AbyssCli.executor": "Run", + ".NET Project.abyssctl.executor": "Debug", + "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", + "ModuleVcsDetector.initialDetectionPerformed": "true", + "Publish to folder.Publish Abyss to folder x86.executor": "Run", + "Publish to folder.Publish Abyss to folder.executor": "Run", + "Publish to folder.p1.executor": "Run", + "Publish to folder.p2.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", + "RunOnceActivity.git.unshallow": "true", + "XThreadsFramesViewSplitterKey": "0.55813956", + "git-widget-placeholder": "main", + "last_opened_file_path": "/home/acite/AciteProjects/Abyss/README.md", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "preferences.lookFeel", + "vue.rearranger.settings.migration": "true" } -}]]> - +} + @@ -301,7 +294,23 @@ - + + + + + + + + + + + + + + + + + diff --git a/Abyss/Components/Controllers/Security/UserController.cs b/Abyss/Components/Controllers/Security/UserController.cs index ce725bb..4624ad9 100644 --- a/Abyss/Components/Controllers/Security/UserController.cs +++ b/Abyss/Components/Controllers/Security/UserController.cs @@ -16,6 +16,27 @@ namespace Abyss.Components.Controllers.Security; [EnableRateLimiting("Fixed")] public class UserController(UserService userService) : BaseController { + [HttpGet("{user}/announce")] + public async Task GetAnnounce(int user) + { + var r = userService.GetAnnounce(user); + if (r is not null) + return Ok(r); + + return _404; + } + + [HttpPost("{user}/announce")] + public async Task SetAnnounce(int user, [FromBody] string data) + { + var r = userService.SetAnnounce(user, data, Token, Ip); + if (r) + { + return Ok(r); + } + return _403; + } + [HttpGet("{user}")] public async Task Challenge(string user) { diff --git a/Abyss/Components/Services/Security/UserService.cs b/Abyss/Components/Services/Security/UserService.cs index 0bc74f7..90eef82 100644 --- a/Abyss/Components/Services/Security/UserService.cs +++ b/Abyss/Components/Services/Security/UserService.cs @@ -18,6 +18,8 @@ public class UserService private readonly ILogger _logger; private readonly IMemoryCache _cache; private readonly SQLiteAsyncConnection _database; + private readonly Dictionary _userAnnounces = new(); + public UserService(ILogger logger, ConfigureService config, IMemoryCache cache) { _logger = logger; @@ -32,6 +34,28 @@ public class UserService } + public string? GetAnnounce(int id) + { + return _userAnnounces.GetValueOrDefault(id); + } + + public bool SetAnnounce(int id, string? value, string token, string ip) + { + if (Validate(token, ip) == -1) + { + return false; + } + + if (value == null) + { + _userAnnounces.Remove(id); + return true; + } + + _userAnnounces[id] = value; + return true; + } + public async Task IsEmptyUser() { return await _database.Table().CountAsync() == 0;