mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-14 17:37:57 +00:00
Admin API: send guild member leave events
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
[
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-V3Vwl1MtVMRTPo7a9lAgs6UaeMnFV3eEsKnLyPaPMHA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-so4y7Wrp/oWhQ7wd1rK9ha9GtPme1l5H8SrQz7sf8MQ="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Analyzers",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-Wed75M4RdQ7bCUWSc+q/0YqL6R5CrIZ2X0t/LpU7ZZA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.EntityFrameworkCore.Relational",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-WwGoCwNxDXyqfBvUX9fGa/6X+yiDBuE7hf3csU78+Os="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Caching.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-/vLXWvT42HQAm/JLjWGeFo9AvLn/mu4nCNjabm+wABE="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Caching.Memory",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-+0sK/vSyB4KFC9kliECROfK1WaiWwlRrhLpi03pT+3w="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Configuration.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-bvEQLGSOpJHKdPD6kd59IIi4x57lKapVMgOORtcjJPs="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.DependencyInjection",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-hbpKNzN0KIszhlpM5iAT/V3B7QRs3FGTZI9Wq/cYc1A="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.DependencyInjection.Abstractions",
|
||||
"version": "10.0.0",
|
||||
"hash": "sha256-9iodXP39YqgxomnOPOxd/mzbG0JfOSXzFoNU3omT2Ps="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.DependencyInjection.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-0QhVYjk9Cxy6NFef9VKftGmscTZnvcD1bhBQoXz3mwA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-eneXBu83dGBiWMFabheGFPYiZJQ+WMewG6bTs2oJ7RA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging.Abstractions",
|
||||
"version": "10.0.0",
|
||||
"hash": "sha256-BnhgGZc01HwTSxogavq7Ueq4V7iMA3wPnbfRwQ4RhGk="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Logging.Abstractions",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-dvBRBgEf4Bw9NW2J2XDlEeJw2TNhJ+6gV98dPE13/J0="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Options",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-ybyUtpSs/irdarkVjsGhqDcj0w8TNUgh0Kp0j3EVfIA="
|
||||
},
|
||||
{
|
||||
"pname": "Microsoft.Extensions.Primitives",
|
||||
"version": "10.0.4",
|
||||
"hash": "sha256-ePpEFzrKQbEMY6Kh/xyxKHq6txNru62Vh4LVZO5Rrvg="
|
||||
},
|
||||
{
|
||||
"pname": "Npgsql",
|
||||
"version": "10.0.3",
|
||||
"hash": "sha256-ddCXCSOoyfy7035OvnL+4LEDYqHjZyPoZ3ffG2coMW0="
|
||||
},
|
||||
{
|
||||
"pname": "Npgsql.EntityFrameworkCore.PostgreSQL",
|
||||
"version": "10.0.3",
|
||||
"hash": "sha256-2ImviEfJ21Dk7pjLJRFCndi5fqDLOl4gkmtGxH3O48Q="
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Spacebar.Models.Generic;
|
||||
|
||||
namespace Spacebar.Models.Gateway;
|
||||
|
||||
public class GuildMemberEvents {
|
||||
public class Add : Member {
|
||||
[JsonPropertyName("guild_id"), JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
public long GuildId { get; set; }
|
||||
}
|
||||
|
||||
public class Update {
|
||||
[JsonPropertyName("guild_id"), JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
public long GuildId { get; set; }
|
||||
|
||||
[JsonPropertyName("user")]
|
||||
public PartialUser User { get; set; } // TODO: not partial
|
||||
|
||||
[JsonPropertyName("roles"), JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
public List<long> Roles { get; set; }
|
||||
|
||||
[JsonPropertyName("nick")]
|
||||
public string? Nick { get; set; }
|
||||
|
||||
[JsonPropertyName("joined_at")]
|
||||
public DateTime? JoinedAt { get; set; }
|
||||
|
||||
[JsonPropertyName("premium_since")]
|
||||
public DateTime? PremiumSince { get; set; } // TODO serialise as unix?
|
||||
|
||||
[JsonPropertyName("pending")]
|
||||
public bool? Pending { get; set; }
|
||||
}
|
||||
|
||||
public class Remove {
|
||||
[JsonPropertyName("guild_id"), JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
public long GuildId { get; set; }
|
||||
|
||||
[JsonPropertyName("user")]
|
||||
public PartialUser User { get; set; } // TODO: not partial
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Linq.Expressions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Spacebar.AdminApi.Extensions;
|
||||
using Spacebar.DataMappings.Generic;
|
||||
using Spacebar.Interop.Authentication;
|
||||
using Spacebar.Interop.Authentication.AspNetCore;
|
||||
using Spacebar.Interop.Replication.Abstractions;
|
||||
@@ -280,6 +281,15 @@ public class UserController(
|
||||
await foreach (var membership in memberships) {
|
||||
db2.Members.Remove(membership);
|
||||
guildIds.Add(membership.GuildId.ToString());
|
||||
await replication.SendAsync<GuildMemberEvents.Remove>(new() {
|
||||
Event = "MESSAGE_BULK_DELETE",
|
||||
GuildId = membership.GuildId,
|
||||
Payload = new() {
|
||||
GuildId = membership.GuildId,
|
||||
User = user.ToPartialUser() // TODO PublicUser?
|
||||
},
|
||||
Origin = "AdminApi/DeleteUser",
|
||||
});
|
||||
}
|
||||
|
||||
await db2.SaveChangesAsync();
|
||||
|
||||
@@ -14,12 +14,17 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DataMappings\Spacebar.DataMappings.AdminApi\Spacebar.DataMappings.AdminApi.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.DataMappings.AdminApi" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
<ProjectReference Include="..\DataMappings\Spacebar.DataMappings.Generic\Spacebar.DataMappings.Generic.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.DataMappings.Generic" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Authentication.AspNetCore\Spacebar.Interop.Authentication.AspNetCore.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Authentication.AspNetCore" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Replication.UnixSocket\Spacebar.Interop.Replication.UnixSocket.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Replication.UnixSocket" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
<ProjectReference Include="..\Models\Spacebar.Models.AdminApi\Spacebar.Models.AdminApi.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Models.AdminApi" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
<ProjectReference Include="..\Models\Spacebar.Models.Api\Spacebar.Models.Api.csproj" />
|
||||
<ProjectReference Include="..\Models\Spacebar.Models.Config\Spacebar.Models.Config.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Models.Config" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
<ProjectReference Include="..\Models\Spacebar.Models.Db\Spacebar.Models.Db.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
|
||||
@@ -26,6 +26,16 @@ nixpkgs.lib.recursiveUpdate (
|
||||
{
|
||||
packages = {
|
||||
# Data mappings
|
||||
Spacebar-DataMappings-AdminApi = buildSpacebarDotnetModule {
|
||||
name = "Spacebar.DataMappings.AdminApi";
|
||||
projectFile = "Spacebar.DataMappings.AdminApi.csproj";
|
||||
nugetDeps = DataMappings/Spacebar.DataMappings.AdminApi/deps.json;
|
||||
srcRoot = DataMappings/Spacebar.DataMappings.AdminApi;
|
||||
projectReferences = [
|
||||
proj.Spacebar-Models-Db
|
||||
proj.Spacebar-Models-AdminApi
|
||||
];
|
||||
};
|
||||
Spacebar-DataMappings-Generic = buildSpacebarDotnetModule {
|
||||
name = "Spacebar.DataMappings.Generic";
|
||||
projectFile = "Spacebar.DataMappings.Generic.csproj";
|
||||
@@ -176,6 +186,8 @@ nixpkgs.lib.recursiveUpdate (
|
||||
srcRoot = ./Spacebar.AdminApi;
|
||||
packNupkg = false;
|
||||
projectReferences = [
|
||||
proj.Spacebar-DataMappings-AdminApi
|
||||
proj.Spacebar-DataMappings-Generic
|
||||
proj.Spacebar-Interop-Authentication
|
||||
proj.Spacebar-Interop-Authentication-AspNetCore
|
||||
proj.Spacebar-Interop-Replication-Abstractions
|
||||
|
||||
Reference in New Issue
Block a user