[feat] User announce.
This commit is contained in:
2
.idea/.idea.Abyss/.idea/dataSources.local.xml
generated
2
.idea/.idea.Abyss/.idea/dataSources.local.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="dataSourceStorageLocal" created-in="RD-252.26199.154">
|
<component name="dataSourceStorageLocal" created-in="RD-252.26830.109">
|
||||||
<data-source name="user" uuid="91acd9d8-5f8b-442f-9d50-17006d4e1ac7">
|
<data-source name="user" uuid="91acd9d8-5f8b-442f-9d50-17006d4e1ac7">
|
||||||
<database-info product="SQLite" version="3.45.1" jdbc-version="4.2" driver-name="SQLite JDBC" driver-version="3.45.1.0" dbms="SQLITE" exact-version="3.45.1" exact-driver-version="3.45">
|
<database-info product="SQLite" version="3.45.1" jdbc-version="4.2" driver-name="SQLite JDBC" driver-version="3.45.1.0" dbms="SQLITE" exact-version="3.45.1" exact-driver-version="3.45">
|
||||||
<identifier-quote-string>"</identifier-quote-string>
|
<identifier-quote-string>"</identifier-quote-string>
|
||||||
|
|||||||
89
.idea/.idea.Abyss/.idea/workspace.xml
generated
89
.idea/.idea.Abyss/.idea/workspace.xml
generated
@@ -11,16 +11,9 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="bf317275-3039-49bb-a475-725a800a0cce" name="Changes" comment="">
|
<list default="true" id="bf317275-3039-49bb-a475-725a800a0cce" name="Changes" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/ChmodModule.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/IncludeModule.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/ListModule.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/abyssctl/App/Modules/ChmodOptions.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/abyssctl/App/Modules/IncludeOptions.cs" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/abyssctl/App/Modules/ListOptions.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Abyss/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Abyss/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Abyss/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Abyss/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Abyss/Components/Controllers/Security/RootController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Controllers/Security/RootController.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Abyss/Components/Controllers/Security/UserController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Controllers/Security/UserController.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Abyss/Toolkits/update-video.py" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Toolkits/update-video.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Abyss/Components/Services/Security/UserService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Services/Security/UserService.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/abyssctl/App/Modules/UserAddOptions.cs" beforeDir="false" afterPath="$PROJECT_DIR$/abyssctl/App/Modules/UserAddOptions.cs" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -54,7 +47,7 @@
|
|||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Media/IndexController.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Media/IndexController.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Media/LiveController.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Media/LiveController.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Middleware/BadRequestExceptionMiddleware.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Middleware/BadRequestExceptionMiddleware.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Security/UserController.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Security/UserController.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Task/TaskController.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Controllers/Task/TaskController.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Attributes/ModuleAttribute.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Attributes/ModuleAttribute.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/CtlService.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/CtlService.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
@@ -63,7 +56,7 @@
|
|||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/HelloModule.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/HelloModule.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/IncludeModule.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/IncludeModule.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/InitModule.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/InitModule.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/ListModule.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/ListModule.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/UserAddModule.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/UserAddModule.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/VersionModule.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Admin/Modules/VersionModule.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Media/ComicService.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Abyss/Components/Services/Media/ComicService.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
@@ -107,7 +100,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
|
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
|
||||||
<component name="ProblemsViewState">
|
<component name="ProblemsViewState">
|
||||||
<option name="selectedTabId" value="SWEA" />
|
<option name="selectedTabId" value="Toolset" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectColorInfo">{
|
<component name="ProjectColorInfo">{
|
||||||
"associatedIndex": 3
|
"associatedIndex": 3
|
||||||
@@ -117,34 +110,34 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
".NET Launch Settings Profile.Abyss: http.executor": "Run",
|
".NET Launch Settings Profile.Abyss: http.executor": "Run",
|
||||||
".NET Launch Settings Profile.Abyss: https.executor": "Debug",
|
".NET Launch Settings Profile.Abyss: https.executor": "Debug",
|
||||||
".NET Project.AbyssCli.executor": "Run",
|
".NET Project.AbyssCli.executor": "Run",
|
||||||
".NET Project.abyssctl.executor": "Debug",
|
".NET Project.abyssctl.executor": "Debug",
|
||||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
"Publish to folder.Publish Abyss to folder x86.executor": "Run",
|
"Publish to folder.Publish Abyss to folder x86.executor": "Run",
|
||||||
"Publish to folder.Publish Abyss to folder.executor": "Run",
|
"Publish to folder.Publish Abyss to folder.executor": "Run",
|
||||||
"Publish to folder.p1.executor": "Run",
|
"Publish to folder.p1.executor": "Run",
|
||||||
"Publish to folder.p2.executor": "Run",
|
"Publish to folder.p2.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"XThreadsFramesViewSplitterKey": "0.55813956",
|
"XThreadsFramesViewSplitterKey": "0.55813956",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"last_opened_file_path": "/home/acite/AciteProjects/Abyss/README.md",
|
"last_opened_file_path": "/home/acite/AciteProjects/Abyss/README.md",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
|
"settings.editor.selected.configurable": "preferences.lookFeel",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RunManager" selected=".NET Launch Settings Profile.Abyss: http">
|
<component name="RunManager" selected="Publish to folder.p2">
|
||||||
<configuration name="p1" type="DotNetFolderPublish" factoryName="Publish to folder" singleton="false">
|
<configuration name="p1" type="DotNetFolderPublish" factoryName="Publish to folder" singleton="false">
|
||||||
<riderPublish configuration="Release" platform="Any CPU" produce_single_file="true" self_contained="true" target_folder="$PROJECT_DIR$/publish" target_framework="net9.0" uuid_high="3690631506471504162" uuid_low="-4858628519588143325">
|
<riderPublish configuration="Release" platform="Any CPU" produce_single_file="true" self_contained="true" target_folder="$PROJECT_DIR$/publish" target_framework="net9.0" uuid_high="3690631506471504162" uuid_low="-4858628519588143325">
|
||||||
<runtimes>
|
<runtimes>
|
||||||
@@ -301,7 +294,23 @@
|
|||||||
<workItem from="1759561043616" duration="201000" />
|
<workItem from="1759561043616" duration="201000" />
|
||||||
<workItem from="1759591584659" duration="8123000" />
|
<workItem from="1759591584659" duration="8123000" />
|
||||||
<workItem from="1759634209525" duration="1767000" />
|
<workItem from="1759634209525" duration="1767000" />
|
||||||
<workItem from="1759639928617" duration="18716000" />
|
<workItem from="1759639928617" duration="19620000" />
|
||||||
|
<workItem from="1759687378138" duration="189000" />
|
||||||
|
<workItem from="1759761027330" duration="124000" />
|
||||||
|
<workItem from="1759762428412" duration="103000" />
|
||||||
|
<workItem from="1759896589590" duration="691000" />
|
||||||
|
<workItem from="1760263567232" duration="4000" />
|
||||||
|
<workItem from="1760270818442" duration="477000" />
|
||||||
|
<workItem from="1760271408229" duration="10000" />
|
||||||
|
<workItem from="1760271525423" duration="10000" />
|
||||||
|
<workItem from="1760271788470" duration="14000" />
|
||||||
|
<workItem from="1760272429219" duration="621000" />
|
||||||
|
<workItem from="1760274170016" duration="1601000" />
|
||||||
|
<workItem from="1760275944851" duration="11000" />
|
||||||
|
<workItem from="1760304622217" duration="25000" />
|
||||||
|
<workItem from="1760629359988" duration="6000" />
|
||||||
|
<workItem from="1760630875664" duration="1000" />
|
||||||
|
<workItem from="1761538960257" duration="66000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -16,6 +16,27 @@ namespace Abyss.Components.Controllers.Security;
|
|||||||
[EnableRateLimiting("Fixed")]
|
[EnableRateLimiting("Fixed")]
|
||||||
public class UserController(UserService userService) : BaseController
|
public class UserController(UserService userService) : BaseController
|
||||||
{
|
{
|
||||||
|
[HttpGet("{user}/announce")]
|
||||||
|
public async Task<IActionResult> GetAnnounce(int user)
|
||||||
|
{
|
||||||
|
var r = userService.GetAnnounce(user);
|
||||||
|
if (r is not null)
|
||||||
|
return Ok(r);
|
||||||
|
|
||||||
|
return _404;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("{user}/announce")]
|
||||||
|
public async Task<IActionResult> SetAnnounce(int user, [FromBody] string data)
|
||||||
|
{
|
||||||
|
var r = userService.SetAnnounce(user, data, Token, Ip);
|
||||||
|
if (r)
|
||||||
|
{
|
||||||
|
return Ok(r);
|
||||||
|
}
|
||||||
|
return _403;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("{user}")]
|
[HttpGet("{user}")]
|
||||||
public async Task<IActionResult> Challenge(string user)
|
public async Task<IActionResult> Challenge(string user)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ public class UserService
|
|||||||
private readonly ILogger<UserService> _logger;
|
private readonly ILogger<UserService> _logger;
|
||||||
private readonly IMemoryCache _cache;
|
private readonly IMemoryCache _cache;
|
||||||
private readonly SQLiteAsyncConnection _database;
|
private readonly SQLiteAsyncConnection _database;
|
||||||
|
private readonly Dictionary<int, string> _userAnnounces = new();
|
||||||
|
|
||||||
public UserService(ILogger<UserService> logger, ConfigureService config, IMemoryCache cache)
|
public UserService(ILogger<UserService> logger, ConfigureService config, IMemoryCache cache)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_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<bool> IsEmptyUser()
|
public async Task<bool> IsEmptyUser()
|
||||||
{
|
{
|
||||||
return await _database.Table<User>().CountAsync() == 0;
|
return await _database.Table<User>().CountAsync() == 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user