Done
This commit is contained in:
parent
fae28490cd
commit
673e1bc4a8
@ -10,8 +10,6 @@ public static class Categories
|
||||
{
|
||||
public static TableColumn<CategoryRow, long> ID { get; } = new("id", true);
|
||||
public static TableColumn<CategoryRow, byte[]> Name { get; } = new("name") { DefaultValue = Encoding.UTF8.GetBytes("New Category") };
|
||||
public static TableColumn<CategoryRow, ColorType> ColorType { get; } = new("color_type") { DefaultValue = Luski.Shared.PublicServers.V1.Enums.ColorType.Full};
|
||||
public static TableColumn<CategoryRow, byte[]> Color { get; } = new("color") { DefaultValue = new byte[]{255,255,255,255} };
|
||||
public static TableColumn<CategoryRow, byte[]> Description { get; } = new("description") { DefaultValue = Encoding.UTF8.GetBytes("Description") };
|
||||
public static TableColumn<CategoryRow, long> TitleEncryptionKey { get; } = new("title_encryption_key")
|
||||
{
|
||||
|
@ -20,8 +20,6 @@ public static class Channels
|
||||
Column = Categories.ID
|
||||
}
|
||||
};
|
||||
public static TableColumn<ChannelRow, ColorType> ColorType { get; } = new("color_type") { DefaultValue = Luski.Shared.PublicServers.V1.Enums.ColorType.Full};
|
||||
public static TableColumn<ChannelRow, byte[]> Color { get; } = new("color") {DefaultValue = new byte[]{255,255,255,255} };
|
||||
public static TableColumn<ChannelRow, ChannelType> Type { get; } = new("type");
|
||||
public static TableColumn<ChannelRow, DateTime> Epoch { get; } = new("epoch");
|
||||
public static TableColumn<ChannelRow, byte[]> Name { get; } = new("name") { DefaultValue = Encoding.UTF8.GetBytes("New Channel") };
|
||||
|
@ -1,22 +0,0 @@
|
||||
using Luski.Shared.PublicServers.V1.Enums;
|
||||
using ServerDatabase;
|
||||
using ServerDatabase.SourceGenerator;
|
||||
|
||||
namespace LuskiServer.Classes.TableDef;
|
||||
|
||||
public static class ProfileColors
|
||||
{
|
||||
public static TableColumn<ProfileColorRow, long> Profile { get; } = new("id", true)
|
||||
{
|
||||
ForeignKey = new ForeignKey()
|
||||
{
|
||||
Table = Tables.Profiles,
|
||||
Column = Profiles.ID
|
||||
}
|
||||
};
|
||||
public static TableColumn<ProfileColorRow, ColorType> ColorType { get; } = new("color_type") { DefaultValue = Luski.Shared.PublicServers.V1.Enums.ColorType.Full};
|
||||
public static TableColumn<ProfileColorRow, byte[]> Color { get; } = new("color") { DefaultValue = new byte[]{255,255,255,255}};
|
||||
}
|
||||
|
||||
[TableRow(typeof(ProfileColors))]
|
||||
public partial class ProfileColorRow;
|
@ -1,9 +1,6 @@
|
||||
using Luski.Shared.PublicServers.V1.Enums;
|
||||
using LuskiServer.Enums;
|
||||
using ServerDatabase;
|
||||
using ServerDatabase.SourceGenerator;
|
||||
using ServerDatabase.Utils;
|
||||
using ServerDatabase.Utils.Enums;
|
||||
|
||||
namespace LuskiServer.Classes.TableDef;
|
||||
|
||||
|
@ -23,7 +23,6 @@ public static class Tables
|
||||
public static Table<MessageFileRow> MessageFiles { get; } = new("message_files", null!);
|
||||
public static Table<MessageRow> Messages { get; } = new("messages", null!);
|
||||
public static Table<OfflineDataRow> OfflineData { get; } = new("offline_data", null!);
|
||||
public static Table<ProfileColorRow> ProfileColors { get; } = new("profile_colors", null!);
|
||||
public static Table<ProfileControllerRow> ProfileControllers { get; } = new("profile_controllers", null!);
|
||||
public static Table<ProfileRoleControllerRow> ProfileRoleControllers { get; } = new("profiles_role_controllers", null!);
|
||||
public static Table<ProfileRow> Profiles { get; } = new("profiles", null!);
|
||||
|
@ -26,7 +26,6 @@ public class SocketCategoryController : ControllerBase
|
||||
epoch = DateTime.UtcNow.Date;
|
||||
LuskiFunctions.Snowflake chanSnowflake = LuskiFunctions.Snowflake.GenerateSnowflake(epoch);
|
||||
Tables.Categories.Insert(
|
||||
Categories.ColorType.CreateParameter(ChanReq.ColorType),
|
||||
Categories.ID.CreateParameter(chanSnowflake.ID),
|
||||
Categories.Name.CreateParameter(Convert.FromBase64String(ChanReq.Name)),
|
||||
Categories.Description.CreateParameter(Convert.FromBase64String(ChanReq.Description)),
|
||||
@ -111,9 +110,7 @@ public class SocketCategoryController : ControllerBase
|
||||
TitleEncoderType = chan.TitleEncoderType,
|
||||
DescriptionEncoderType = chan.DescriptionEncoderType,
|
||||
UserOverrides = UO.ToArray(),
|
||||
RoleOverrides = RO.ToArray(),
|
||||
ColorType = chan.ColorType,
|
||||
Color = Convert.ToHexString(chan.Color)
|
||||
RoleOverrides = RO.ToArray()
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -219,9 +216,7 @@ public class SocketCategoryController : ControllerBase
|
||||
TitleEncoderType = chan.TitleEncoderType,
|
||||
DescriptionEncoderType = chan.DescriptionEncoderType,
|
||||
UserOverrides = UO.ToArray(),
|
||||
RoleOverrides = RO.ToArray(),
|
||||
ColorType = chan.ColorType,
|
||||
Color = Convert.ToHexString(chan.Color)
|
||||
RoleOverrides = RO.ToArray()
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -318,9 +313,7 @@ public class SocketCategoryController : ControllerBase
|
||||
TitleEncoderType = chan.TitleEncoderType,
|
||||
DescriptionEncoderType = chan.DescriptionEncoderType,
|
||||
UserOverrides = UO.ToArray(),
|
||||
RoleOverrides = RO.ToArray(),
|
||||
ColorType = chan.ColorType,
|
||||
Color = Convert.ToHexString(chan.Color)
|
||||
RoleOverrides = RO.ToArray()
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -29,8 +29,6 @@ public class SocketChannelController : ControllerBase
|
||||
Tables.Channels.Insert(
|
||||
Channels.ID.CreateParameter(chanSnowflake.ID),
|
||||
Channels.Parent.CreateParameter(ChanReq.Parent),
|
||||
Channels.ColorType.CreateParameter(ChanReq.ColorType),
|
||||
Channels.Color.CreateParameter(Convert.FromHexString(ChanReq.Color)),
|
||||
Channels.Type.CreateParameter(ChanReq.Type),
|
||||
Channels.Epoch.CreateParameter(epoch.Date),
|
||||
Channels.Name.CreateParameter(Convert.FromBase64String(ChanReq.Name)),
|
||||
@ -111,9 +109,7 @@ public class SocketChannelController : ControllerBase
|
||||
EncoderTypes = chan.EncoderTypes,
|
||||
UserOverrides = UO.ToArray(),
|
||||
RoleOverrides = RO.ToArray(),
|
||||
PictureType = chan.PictureType,
|
||||
ColorType = chan.ColorType,
|
||||
Color = Convert.ToHexString(chan.Color)
|
||||
PictureType = chan.PictureType
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -220,9 +216,7 @@ public class SocketChannelController : ControllerBase
|
||||
EncoderTypes = chan.EncoderTypes,
|
||||
UserOverrides = UO.ToArray(),
|
||||
RoleOverrides = RO.ToArray(),
|
||||
PictureType = chan.PictureType,
|
||||
ColorType = chan.ColorType,
|
||||
Color = Convert.ToHexString(chan.Color)
|
||||
PictureType = chan.PictureType
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -58,22 +58,12 @@ public class SocketProfileController : ControllerBase
|
||||
{
|
||||
if (!this.CanTokenRequest(out long ID, out long SID, out IActionResult? toc) && toc != null) return toc;
|
||||
if (!Tables.Profiles.TryReadRow(out ProfileRow PR, Profiles.ID.CreateParameter(Person))) return this.ShowError(ErrorCode.Forbidden, "Profile does not exist");
|
||||
string? color = null;
|
||||
ColorType? ct = null;
|
||||
if (Tables.ProfileColors.TryReadRow(out var b,
|
||||
ProfileColors.Profile.CreateParameter(PR.ID)))
|
||||
{
|
||||
color = Convert.ToHexString(b.Color);
|
||||
ct = b.ColorType;
|
||||
}
|
||||
return this.ResponseToResult(new ProfileSTC()
|
||||
{
|
||||
ID = PR.ID,
|
||||
DisplayName = PR.DisplayName,
|
||||
PictureType = PR.PictureType,
|
||||
Controllers = Tables.ProfileControllers.ReadColumn(ProfileControllers.User, ProfileControllers.Profile.CreateParameter(Person)),
|
||||
ColorType = ct,
|
||||
Color = color,
|
||||
RoleControllers = Tables.ProfileRoleControllers.ReadColumn(ProfileRoleControllers.Role, ProfileRoleControllers.Profile.CreateParameter(Person)),
|
||||
Channels = Tables.ChannelProfiles.ReadColumn(ChannelProfiles.Channel, ChannelProfiles.Profile.CreateParameter(Person)),
|
||||
Categories = Tables.CategoryProfiles.ReadColumn(CategoryProfiles.Category, CategoryProfiles.Profile.CreateParameter(Person)),
|
||||
@ -100,22 +90,12 @@ public class SocketProfileController : ControllerBase
|
||||
{
|
||||
foreach (ProfileRow PR in PcRs)
|
||||
{
|
||||
string? color = null;
|
||||
ColorType? ct = null;
|
||||
if (Tables.ProfileColors.TryReadRow(out ProfileColorRow b,
|
||||
ProfileColors.Profile.CreateParameter(PR.ID)))
|
||||
{
|
||||
color = Convert.ToHexString(b.Color);
|
||||
ct = b.ColorType;
|
||||
}
|
||||
Vals.Add(PR.ID, new()
|
||||
{
|
||||
ID = PR.ID,
|
||||
DisplayName = PR.DisplayName,
|
||||
PictureType = PR.PictureType,
|
||||
Controllers = Tables.ProfileControllers.ReadColumn(ProfileControllers.User, ProfileControllers.Profile.CreateParameter(PR.ID)),
|
||||
ColorType = ct,
|
||||
Color = color,
|
||||
RoleControllers = Tables.ProfileRoleControllers.ReadColumn(ProfileRoleControllers.Role, ProfileRoleControllers.Profile.CreateParameter(PR.ID)),
|
||||
Channels = Tables.ChannelProfiles.ReadColumn(ChannelProfiles.Channel, ChannelProfiles.Profile.CreateParameter(PR.ID)),
|
||||
Categories = Tables.CategoryProfiles.ReadColumn(CategoryProfiles.Category, CategoryProfiles.Profile.CreateParameter(PR.ID)),
|
||||
@ -132,22 +112,12 @@ public class SocketProfileController : ControllerBase
|
||||
{
|
||||
if (!Vals.ContainsKey(PR.ID))
|
||||
{
|
||||
string? color = null;
|
||||
ColorType? ct = null;
|
||||
if (Tables.ProfileColors.TryReadRow(out var b,
|
||||
ProfileColors.Profile.CreateParameter(PR.ID)))
|
||||
{
|
||||
color = Convert.ToHexString(b.Color);
|
||||
ct = b.ColorType;
|
||||
}
|
||||
Vals.Add(PR.ID, new()
|
||||
{
|
||||
ID = PR.ID,
|
||||
DisplayName = PR.DisplayName,
|
||||
PictureType = PR.PictureType,
|
||||
Controllers = Tables.ProfileControllers.ReadColumn(ProfileControllers.User, ProfileControllers.Profile.CreateParameter(PR.ID)),
|
||||
ColorType = ct,
|
||||
Color = color,
|
||||
RoleControllers = Tables.ProfileRoleControllers.ReadColumn(ProfileRoleControllers.Role, ProfileRoleControllers.Profile.CreateParameter(PR.ID)),
|
||||
Channels = Tables.ChannelProfiles.ReadColumn(ChannelProfiles.Channel, ChannelProfiles.Profile.CreateParameter(PR.ID)),
|
||||
Categories = Tables.CategoryProfiles.ReadColumn(CategoryProfiles.Category, CategoryProfiles.Profile.CreateParameter(PR.ID)),
|
||||
|
@ -2,7 +2,6 @@ using Asp.Versioning;
|
||||
using Luski.Shared.PublicServers.V1.ClientToServer.HTTP;
|
||||
using Luski.Shared.PublicServers.V1.Enums;
|
||||
using Luski.Shared.PublicServers.V1.ServerToClient.HTTP;
|
||||
using Luski.Shared.PublicServers.V1.ServerToClient.WSS;
|
||||
using Luski.Shared.PublicServers.V1.Shared;
|
||||
using LuskiServer.Classes;
|
||||
using LuskiServer.Classes.ServerComs;
|
||||
|
@ -10,9 +10,23 @@ namespace LuskiServer.Converters.Matrix;
|
||||
|
||||
public static class Matrix
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="Zip">File Stream</param>
|
||||
/// <param name="Channel">Luski Channel ID</param>
|
||||
/// <param name="defaultuser">ID of user doing the conversion</param>
|
||||
/// <param name="UserMap">Map of matrix name to luski account</param>
|
||||
/// <param name="ProfilesIdList">Map of matrix name to Luski Profile</param>
|
||||
/// <param name="Profiles">Map of matrix names to new Luski Profiles</param>
|
||||
/// <param name="IgnoredUsers">List of ignored matrix names</param>
|
||||
/// <param name="Encoder">The Encoding to use for Luski Messages</param>
|
||||
/// <param name="Encryption">The Encryption key to use for Luski Messages</param>
|
||||
/// <param name="remove">Removes channel if same id is already created</param>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public static void ZipJsonChatExport(Stream Zip, long Channel, long defaultuser, Dictionary<string, long> UserMap,
|
||||
Dictionary<string, int> ChannelProfilesIdList,
|
||||
List<Tuple<string, byte[], PictureType, byte[]>> Profiles,
|
||||
Dictionary<string, int> ProfilesIdList,
|
||||
List<Tuple<string, byte[], PictureType>> Profiles,
|
||||
List<string> IgnoredUsers, EncoderType Encoder, long Encryption, bool remove = true)
|
||||
{
|
||||
Dictionary<int, long> IdConverter = new();
|
||||
@ -30,21 +44,18 @@ public static class Matrix
|
||||
|
||||
void checkFakeUser(string id)
|
||||
{
|
||||
if (!IdConverter.ContainsKey(ChannelProfilesIdList[id]))
|
||||
if (!IdConverter.ContainsKey(ProfilesIdList[id]))
|
||||
{
|
||||
long id2 = LuskiFunctions.Snowflake.GenerateSnowflake().ID;
|
||||
|
||||
Tables.Profiles.Insert(
|
||||
Classes.TableDef.Profiles.ID.CreateParameter(id2),
|
||||
Classes.TableDef.Profiles.PictureType.CreateParameter(Profiles[ChannelProfilesIdList[id]].Item3),
|
||||
Classes.TableDef.Profiles.Picture.CreateParameter(Profiles[ChannelProfilesIdList[id]].Item2),
|
||||
Classes.TableDef.Profiles.DisplayName.CreateParameter(Profiles[ChannelProfilesIdList[id]].Item1));
|
||||
Tables.ProfileColors.Insert(
|
||||
ProfileColors.Profile.CreateParameter(id2),
|
||||
ProfileColors.Color.CreateParameter(Profiles[ChannelProfilesIdList[id]].Item4));
|
||||
IdConverter.Add(ChannelProfilesIdList[id], id2);
|
||||
Classes.TableDef.Profiles.PictureType.CreateParameter(Profiles[ProfilesIdList[id]].Item3),
|
||||
Classes.TableDef.Profiles.Picture.CreateParameter(Profiles[ProfilesIdList[id]].Item2),
|
||||
Classes.TableDef.Profiles.DisplayName.CreateParameter(Profiles[ProfilesIdList[id]].Item1));
|
||||
IdConverter.Add(ProfilesIdList[id], id2);
|
||||
Tables.ChannelProfiles.Insert(ChannelProfiles.Channel.CreateParameter(Channel), ChannelProfiles.Profile.CreateParameter(id2));
|
||||
foreach (KeyValuePair<string, int> v in ChannelProfilesIdList.Where(s => s.Value == ChannelProfilesIdList[id]))
|
||||
foreach (KeyValuePair<string, int> v in ProfilesIdList.Where(s => s.Value == ProfilesIdList[id]))
|
||||
{
|
||||
cps.Add(v.Key, id2);
|
||||
}
|
||||
@ -78,7 +89,7 @@ public static class Matrix
|
||||
Console.WriteLine(inow + " of " + imax);
|
||||
if (msg.Type != "m.room.message")
|
||||
continue;
|
||||
if (!UserMap.ContainsKey(msg.Sender) && !ChannelProfilesIdList.ContainsKey(msg.Sender))
|
||||
if (!UserMap.ContainsKey(msg.Sender) && !ProfilesIdList.ContainsKey(msg.Sender))
|
||||
{
|
||||
if (IgnoredUsers.Contains(msg.Sender))
|
||||
continue;
|
||||
@ -102,10 +113,10 @@ public static class Matrix
|
||||
cur = cur.ToLocalTime();
|
||||
long id;
|
||||
long profile = 0;
|
||||
if (ChannelProfilesIdList.ContainsKey(msg.Sender))
|
||||
if (ProfilesIdList.ContainsKey(msg.Sender))
|
||||
{
|
||||
checkFakeUser(msg.Sender);
|
||||
profile = IdConverter[ChannelProfilesIdList[msg.Sender]];
|
||||
profile = IdConverter[ProfilesIdList[msg.Sender]];
|
||||
id = defaultuser;
|
||||
}
|
||||
else
|
||||
|
@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IncludeBuildOutput>true</IncludeBuildOutput>
|
||||
<FileVersion>1.0.0.0</FileVersion>
|
||||
<FileVersion>1.0.0.1</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
@ -22,7 +22,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="7.0.0" />
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
|
||||
<PackageReference Include="Luski.Shared" Version="1.1.0-alpha43" />
|
||||
<PackageReference Include="Luski.Shared" Version="1.1.0-alpha48" />
|
||||
<PackageReference Include="Markdig" Version="0.36.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
|
||||
|
@ -76,7 +76,6 @@ if (!Tables.Profiles.TryRead(Profiles.ID, out _, Profiles.ID.CreateParameter(0))
|
||||
Profiles.DisplayName.CreateParameter("Server"),
|
||||
Profiles.PictureType.CreateParameter(PictureType.none),
|
||||
Profiles.Picture.CreateParameter(Array.Empty<byte>()));
|
||||
Tables.ProfileColors.Insert(ProfileColors.Profile.CreateParameter(0), ProfileColors.Color.CreateParameter((new byte[] {255,255,255,255})));
|
||||
}
|
||||
|
||||
if (!LuskiFunctions.Database.VersionsTable.TryRead(LuskiFunctions.Database.VersionsTable.ID, out _,
|
||||
@ -143,7 +142,6 @@ if (!Tables.Roles.TryRead(Roles.ID, out _, Roles.ID.CreateParameter(0)))
|
||||
Tables.Roles.Insert(
|
||||
Roles.ID.CreateParameter(0),
|
||||
Roles.DisplayName.CreateParameter("Members"),
|
||||
Roles.Color.CreateDefaultParameter(),
|
||||
Roles.Description.CreateParameter("The default role for the server. Everybody will have this role."),
|
||||
Roles.ServerPermissions.CreateParameter(
|
||||
ServerPermission.ViewChannels |
|
||||
|
Loading…
Reference in New Issue
Block a user