Current libraries: the database, media, sanitizer, mail and sign-in libraries are on their latest versions
Build / Build (push) Successful in 35s
Build / Build (push) Successful in 35s
- MongoDB.Entities 26, FFMpegCore 6, HtmlSanitizer 11, Serilog's MongoDB sink 8, OpenIddict 7.8, MailKit 4.18.2, Markdig 1.6, Swashbuckle 10.3, QRCoder 1.8.1 and the .NET 10.0.14 sign-in library; the build uses SDK 10.0.403. The two packages with known vulnerabilities in the old set are gone. - Stored records are read and written exactly as before: ids keep their form, personas and groups still get ids that carry their published day, and an older version can still read what this one writes. - Videos are probed, transcoded and given a poster frame as before. - Federated posts are cleaned exactly as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
This commit is contained in:
1 parent
739a1603ca
commit
8a1e4e419b
9 files changed
+88
-26
No files matched your search
@@ -848,7 +848,7 @@ client's role route never does.
|
|||||||
- **Usernames are `Constants.UserNameRegex`** (`^[a-z0-9_]+$`): the intersection of what Mastodon and Misskey accept. A
|
- **Usernames are `Constants.UserNameRegex`** (`^[a-z0-9_]+$`): the intersection of what Mastodon and Misskey accept. A
|
||||||
name outside it creates a persona nobody on those servers can reach.
|
name outside it creates a persona nobody on those servers can reach.
|
||||||
- **An actor's `published` is `PublishedOn`**, a random whole day up to two weeks before creation, so personas made the
|
- **An actor's `published` is `PublishedOn`**, a random whole day up to two weeks before creation, so personas made the
|
||||||
same day do not share a date. New persona and group ids carry that same day (`GenerateNewID`), because local clients
|
same day do not share a date. New persona and group ids carry that same day (`IOwnId.NewId`), because local clients
|
||||||
see ids. Never emit `CreatedAt`.
|
see ids. Never emit `CreatedAt`.
|
||||||
- **Per-avatar state stays per avatar:** blocks, mutes, notifications, follows, and since R8 featured tags,
|
- **Per-avatar state stays per avatar:** blocks, mutes, notifications, follows, and since R8 featured tags,
|
||||||
endorsements, private notes (`PersonaNote`, never `RootUserNote`) and dismissed suggestions. Nothing may relate sibling
|
endorsements, private notes (`PersonaNote`, never `RootUserNote`) and dismissed suggestions. Nothing may relate sibling
|
||||||
@@ -880,11 +880,18 @@ client's role route never does.
|
|||||||
|
|
||||||
## Data
|
## Data
|
||||||
|
|
||||||
- MongoDB through **MongoDB.Entities 25.1**, instance API: `DB.Default.Find<T>()`, `.SaveAsync(e)`, `.Update<T>()`,
|
- MongoDB through **MongoDB.Entities 26**, instance API: `DB.Default.Find<T>()`, `.SaveAsync(e)`, `.Update<T>()`,
|
||||||
`.DeleteAsync<T>()`, `.CountAsync<T>()`. `DbEntities` wraps the finds.
|
`.DeleteAsync<T>()`, `.CountAsync<T>()`. `DbEntities` wraps the finds.
|
||||||
- **Pass no cancellation token to `DeleteAsync` outside a transaction;** v25 throws if you do.
|
- **Pass no cancellation token to `DeleteAsync` outside a transaction;** the library throws if you do (v25 and v26).
|
||||||
- **Collection name = class name, so never rename an entity class.**
|
- **Collection name = class name, so never rename an entity class.**
|
||||||
- `Entity.ID` is a 24-character lowercase hex string; `GenerateNewID()` returns `object`, so cast it.
|
- **IDs are stored as they always were.** Since v26 the library no longer decides it, so `EntityIds.Register()`
|
||||||
|
(`Infrastructure/Data/EntityIds.cs`) maps `Entity.ID` the way v25 did: an ObjectId-shaped id as a BSON ObjectId,
|
||||||
|
any other string as a string, both read back, nested entities too.
|
||||||
|
- A type that makes its own id implements `IOwnId.NewId()` (`Avatar`, `Group`); every other type gets a 24-character
|
||||||
|
lowercase hex string.
|
||||||
|
- `GenerateNewID()` is now the library's extension method, still returning `object`, so cast it.
|
||||||
|
- Checked on 10 November 2026 against a scratch mongod: records written with v25 read, filter, update and delete
|
||||||
|
under v26, new writes keep the same BSON types, and v25 reads them back.
|
||||||
- New fields must be additive: a deploy rollback restores the binary, not the database.
|
- New fields must be additive: a deploy rollback restores the binary, not the database.
|
||||||
- **Every stored remote object has an `ObjectRecord`** (raw JSON up to 256 KB plus its hash; delivered or fetched; the
|
- **Every stored remote object has an `ObjectRecord`** (raw JSON up to 256 KB plus its hash; delivered or fetched; the
|
||||||
activity, inbox, key and signed headers; received time; up to 10 later revisions). Write it right after the post's
|
activity, inbox, key and signed headers; received time; up to 10 later revisions). Write it right after the post's
|
||||||
@@ -945,7 +952,8 @@ client's role route never does.
|
|||||||
(`ActivityPubRenderer.Timestamp`). GoToSocial (ULIDs) and Mastodon (Snowflakes) derive a remote status's id from
|
(`ActivityPubRenderer.Timestamp`). GoToSocial (ULIDs) and Mastodon (Snowflakes) derive a remote status's id from
|
||||||
`published` at millisecond resolution. With whole seconds, two of our posts from the same second sorted at random
|
`published` at millisecond resolution. With whole seconds, two of our posts from the same second sorted at random
|
||||||
there.
|
there.
|
||||||
- **Startup order:** `EntityMaps.Warm()` (every entity's class map, one at a time; two mapped at once throw "An item
|
- **Startup order:** `EntityIds.Register()` (first: if anything built `Entity`'s class map before it, start-up throws
|
||||||
|
rather than store ids differently), then `EntityMaps.Warm()` (every entity's class map, one at a time; two mapped at once throw "An item
|
||||||
with the same key has already been added" and stay broken), then `MigrateAsync` (`Infrastructure/Data/Migrations`,
|
with the same key has already been added" and stay broken), then `MigrateAsync` (`Infrastructure/Data/Migrations`,
|
||||||
`_NNN_` order, each runs once), then `Indexes.Create()`. A new entity needs nothing; a new unique index needs a
|
`_NNN_` order, each runs once), then `Indexes.Create()`. A new entity needs nothing; a new unique index needs a
|
||||||
dedupe migration before it.
|
dedupe migration before it.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Arasaka.HouseRules.Analyzers" Version="1.0.4" PrivateAssets="all" />
|
<PackageReference Include="Arasaka.HouseRules.Analyzers" Version="1.0.6" PrivateAssets="all" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -601,7 +601,7 @@ namespace PrivaPub.Domain.Media
|
|||||||
await _processing.WaitAsync(token);
|
await _processing.WaitAsync(token);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var probe = await FFProbe.AnalyseAsync(input, default, token, "-protocol_whitelist file");
|
var probe = await FFProbe.AnalyseAsync(input, customArguments: "-protocol_whitelist file", cancellationToken: token);
|
||||||
if (probe.Duration > TimeSpan.FromSeconds(options.MaxSeconds))
|
if (probe.Duration > TimeSpan.FromSeconds(options.MaxSeconds))
|
||||||
return MediaOutcome.Fail(StatusCodes.Status422UnprocessableEntity, "Validation failed: The file is too long");
|
return MediaOutcome.Fail(StatusCodes.Status422UnprocessableEntity, "Validation failed: The file is too long");
|
||||||
var video = attachment.ContentType.StartsWith("video/", StringComparison.Ordinal) ? probe.PrimaryVideoStream : default;
|
var video = attachment.ContentType.StartsWith("video/", StringComparison.Ordinal) ? probe.PrimaryVideoStream : default;
|
||||||
@@ -614,7 +614,7 @@ namespace PrivaPub.Domain.Media
|
|||||||
if (video == default)
|
if (video == default)
|
||||||
arguments = "-map 0:a:0 -vn -dn -sn -map_metadata -1 -map_chapters -1 -c copy" + (extension == "m4a" ? " -movflags +faststart" : string.Empty);
|
arguments = "-map 0:a:0 -vn -dn -sn -map_metadata -1 -map_chapters -1 -c copy" + (extension == "m4a" ? " -movflags +faststart" : string.Empty);
|
||||||
else if (video.CodecName is "h264" or "vp8" or "vp9" or "av1" && (long)video.Width * video.Height <= options.MaxVideoPixels
|
else if (video.CodecName is "h264" or "vp8" or "vp9" or "av1" && (long)video.Width * video.Height <= options.MaxVideoPixels
|
||||||
&& video.FrameRate <= options.MaxFrameRate + 0.5)
|
&& video.RealFrameRate <= options.MaxFrameRate + 0.5)
|
||||||
arguments = "-map 0:v:0 -map 0:a:0? -dn -sn -map_metadata -1 -map_chapters -1 -c copy" + (extension == "mp4" ? " -movflags +faststart" : string.Empty);
|
arguments = "-map 0:v:0 -map 0:a:0? -dn -sn -map_metadata -1 -map_chapters -1 -c copy" + (extension == "mp4" ? " -movflags +faststart" : string.Empty);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -631,13 +631,15 @@ namespace PrivaPub.Domain.Media
|
|||||||
.CancellableThrough(token)
|
.CancellableThrough(token)
|
||||||
.ProcessAsynchronously();
|
.ProcessAsynchronously();
|
||||||
|
|
||||||
var made = await FFProbe.AnalyseAsync(output, default, token, "-protocol_whitelist file");
|
var made = await FFProbe.AnalyseAsync(output, customArguments: "-protocol_whitelist file", cancellationToken: token);
|
||||||
byte[] poster = default;
|
byte[] poster = default;
|
||||||
if (video != default)
|
if (video != default)
|
||||||
{
|
{
|
||||||
attachment.Width = made.PrimaryVideoStream?.Width;
|
attachment.Width = made.PrimaryVideoStream?.Width;
|
||||||
attachment.Height = made.PrimaryVideoStream?.Height;
|
attachment.Height = made.PrimaryVideoStream?.Height;
|
||||||
await FFMpeg.SnapshotAsync(output, frame, captureTime: TimeSpan.FromSeconds(Math.Min(1, made.Duration.TotalSeconds / 2)), cancellationToken: token);
|
await FFMpeg.Snapshot(made, frame, captureTime: TimeSpan.FromSeconds(Math.Min(1, made.Duration.TotalSeconds / 2)))
|
||||||
|
.CancellableThrough(token)
|
||||||
|
.ProcessAsynchronously();
|
||||||
var still = ProcessImage(await File.ReadAllBytesAsync(frame, token), 640, options.PreviewSide);
|
var still = ProcessImage(await File.ReadAllBytesAsync(frame, token), 640, options.PreviewSide);
|
||||||
poster = still.Preview;
|
poster = still.Preview;
|
||||||
attachment.Blurhash = still.Blurhash;
|
attachment.Blurhash = still.Blurhash;
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Bson.Serialization;
|
||||||
|
using MongoDB.Entities;
|
||||||
|
|
||||||
|
namespace PrivaPub.Infrastructure.Data
|
||||||
|
{
|
||||||
|
public interface IOwnId
|
||||||
|
{
|
||||||
|
string NewId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class EntityIds
|
||||||
|
{
|
||||||
|
static readonly Lock Gate = new();
|
||||||
|
|
||||||
|
public static void Register()
|
||||||
|
{
|
||||||
|
lock (Gate)
|
||||||
|
{
|
||||||
|
if (BsonClassMap.IsClassMapRegistered(typeof(Entity)))
|
||||||
|
{
|
||||||
|
if (BsonClassMap.LookupClassMap(typeof(Entity)).IdMemberMap?.IdGenerator is Generator)
|
||||||
|
return;
|
||||||
|
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"The BSON map of Entity was built before EntityIds.Register(), so IDs would not be stored as they always were. Register them before anything touches a stored record.");
|
||||||
|
}
|
||||||
|
|
||||||
|
BsonClassMap.RegisterClassMap<Entity>(map =>
|
||||||
|
{
|
||||||
|
map.AutoMap();
|
||||||
|
map.SetIgnoreExtraElements(true);
|
||||||
|
var id = map.MapIdProperty(entity => entity.ID);
|
||||||
|
((IBsonMemberMapAttribute)new AsObjectIdAttribute()).Apply(id);
|
||||||
|
id.SetIdGenerator(new Generator());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class Generator : IIdGenerator
|
||||||
|
{
|
||||||
|
public object GenerateId(object container, object document)
|
||||||
|
=> document is IOwnId own ? own.NewId() : ObjectId.GenerateNewId().ToString();
|
||||||
|
|
||||||
|
public bool IsEmpty(object id)
|
||||||
|
=> string.IsNullOrEmpty(id as string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
using MongoDB.Entities;
|
using MongoDB.Entities;
|
||||||
|
|
||||||
|
using PrivaPub.Infrastructure.Data;
|
||||||
using PrivaPub.Infrastructure.Ids;
|
using PrivaPub.Infrastructure.Ids;
|
||||||
|
|
||||||
namespace PrivaPub.Models.Group
|
namespace PrivaPub.Models.Group
|
||||||
{
|
{
|
||||||
public class Group : Entity
|
public class Group : Entity, IOwnId
|
||||||
{
|
{
|
||||||
public string UserName { get; set; }//preferredUsername
|
public string UserName { get; set; }//preferredUsername
|
||||||
public string Name { get; set; }//name
|
public string Name { get; set; }//name
|
||||||
@@ -35,7 +36,7 @@ namespace PrivaPub.Models.Group
|
|||||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||||
public DateTime? DeletionAt { get; set; }
|
public DateTime? DeletionAt { get; set; }
|
||||||
|
|
||||||
public override object GenerateNewID() => PrivacyIds.ForDay(PublishedOn);
|
public string NewId() => PrivacyIds.ForDay(PublishedOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GroupMember
|
public class GroupMember
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
using MongoDB.Entities;
|
using MongoDB.Entities;
|
||||||
|
|
||||||
|
using PrivaPub.Infrastructure.Data;
|
||||||
using PrivaPub.Infrastructure.Ids;
|
using PrivaPub.Infrastructure.Ids;
|
||||||
|
|
||||||
namespace PrivaPub.Models.User
|
namespace PrivaPub.Models.User
|
||||||
{
|
{
|
||||||
public class Avatar : Entity
|
public class Avatar : Entity, IOwnId
|
||||||
{
|
{
|
||||||
public string Url { get; set; }//url
|
public string Url { get; set; }//url
|
||||||
public string Name { get; set; }//name
|
public string Name { get; set; }//name
|
||||||
@@ -40,7 +41,7 @@ namespace PrivaPub.Models.User
|
|||||||
public DateTime? BannedAt { get; set; }
|
public DateTime? BannedAt { get; set; }
|
||||||
public DateTime? DeletionAt { get; set; }
|
public DateTime? DeletionAt { get; set; }
|
||||||
|
|
||||||
public override object GenerateNewID() => PrivacyIds.ForDay(PublishedOn);
|
public string NewId() => PrivacyIds.ForDay(PublishedOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ForeignAvatar : Entity
|
public class ForeignAvatar : Entity
|
||||||
|
|||||||
+11
-11
@@ -8,22 +8,22 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />
|
<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />
|
||||||
<PackageReference Include="FFMpegCore" Version="5.5.0" />
|
<PackageReference Include="FFMpegCore" Version="6.0.0" />
|
||||||
<PackageReference Include="HtmlSanitizer" Version="9.2.1039" />
|
<PackageReference Include="HtmlSanitizer" Version="11.0.26" />
|
||||||
<PackageReference Include="MailKit" Version="4.18.0" />
|
<PackageReference Include="MailKit" Version="4.18.2" />
|
||||||
<PackageReference Include="Markdig" Version="1.4.0" />
|
<PackageReference Include="Markdig" Version="1.6.0" />
|
||||||
<PackageReference Include="MaxMind.Db" Version="5.2.0" />
|
<PackageReference Include="MaxMind.Db" Version="5.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.9" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.14" />
|
||||||
<PackageReference Include="MongoDB.Entities" Version="25.1.0" />
|
<PackageReference Include="MongoDB.Entities" Version="26.0.0" />
|
||||||
<PackageReference Include="NetVips" Version="3.2.0" />
|
<PackageReference Include="NetVips" Version="3.2.0" />
|
||||||
<PackageReference Include="NetVips.Native.linux-x64" Version="8.18.7" />
|
<PackageReference Include="NetVips.Native.linux-x64" Version="8.18.7" />
|
||||||
<PackageReference Include="OpenIddict.AspNetCore" Version="7.7.1" />
|
<PackageReference Include="OpenIddict.AspNetCore" Version="7.8.0" />
|
||||||
<PackageReference Include="OpenIddict.MongoDb" Version="7.7.1" />
|
<PackageReference Include="OpenIddict.MongoDb" Version="7.8.0" />
|
||||||
<PackageReference Include="Otp.NET" Version="1.4.1" />
|
<PackageReference Include="Otp.NET" Version="1.4.1" />
|
||||||
<PackageReference Include="QRCoder" Version="1.8.0" />
|
<PackageReference Include="QRCoder" Version="1.8.1" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.MongoDB" Version="7.3.0" />
|
<PackageReference Include="Serilog.Sinks.MongoDB" Version="8.0.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ try
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
BsonSerializer.TryRegisterSerializer(new GuidSerializer(GuidRepresentation.Standard));
|
BsonSerializer.TryRegisterSerializer(new GuidSerializer(GuidRepresentation.Standard));
|
||||||
|
EntityIds.Register();
|
||||||
var mongoSettings = builder.Configuration.GetSection(nameof(MongoSettings)).Get<MongoSettings>();
|
var mongoSettings = builder.Configuration.GetSection(nameof(MongoSettings)).Get<MongoSettings>();
|
||||||
await DB.InitAsync(mongoSettings.Database, MongoClientSettings.FromConnectionString(mongoSettings.ConnectionString));
|
await DB.InitAsync(mongoSettings.Database, MongoClientSettings.FromConnectionString(mongoSettings.ConnectionString));
|
||||||
EntityMaps.Warm();
|
EntityMaps.Warm();
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "10.0.100",
|
"version": "10.0.403",
|
||||||
"rollForward": "latestFeature",
|
"rollForward": "latestFeature",
|
||||||
"allowPrerelease": false
|
"allowPrerelease": false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user