Fix MongoDB class map hierarchy for inherited Content property

This commit is contained in:
Халимов Рустам
2026-03-19 23:02:28 +03:00
parent 74cae687a5
commit 1f8746bd03
2 changed files with 6 additions and 7 deletions
@@ -31,6 +31,7 @@ public static class MongoDbMapConfigurator
cm.MapField("_deletedFor").SetElementName("DeletedFor");
cm.MapField("_readBy").SetElementName("ReadBy");
cm.MapField("_reactions").SetElementName("Reactions");
cm.MapProperty(c => c.Content).SetSerializer(new EncryptedStringSerializer());
cm.MapProperty(c => c.Quote).SetSerializer(new EncryptedStringSerializer());
cm.SetIsRootClass(true);
});
@@ -39,7 +40,6 @@ public static class MongoDbMapConfigurator
{
cm.AutoMap();
cm.SetDiscriminator("TextMessage");
cm.MapProperty(c => c.Content).SetSerializer(new EncryptedStringSerializer());
});
BsonClassMap.RegisterClassMap<MediaMessage>(cm =>
@@ -47,14 +47,13 @@ public static class MongoDbMapConfigurator
cm.AutoMap();
cm.MapField("_media").SetElementName("Media");
cm.SetDiscriminator("MediaMessage");
cm.MapProperty(c => c.Caption).SetSerializer(new EncryptedStringSerializer());
cm.UnmapProperty(c => c.Caption); // Avoid DB duplication, Content is already saved
});
BsonClassMap.RegisterClassMap<StoryMessage>(cm =>
{
cm.AutoMap();
cm.SetDiscriminator("StoryMessage");
cm.MapProperty(c => c.Content).SetSerializer(new EncryptedStringSerializer());
cm.MapProperty(c => c.InternalStoryMediaUrl).SetSerializer(new EncryptedStringSerializer());
});
+4 -4
View File
@@ -4,7 +4,7 @@ services:
container_name: knot-db
restart: always
env_file:
- .env
- ../.env
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
@@ -17,7 +17,7 @@ services:
container_name: knot-server
restart: always
env_file:
- .env
- ../.env
depends_on:
- db
- minio
@@ -30,7 +30,7 @@ services:
container_name: knot-minio
restart: always
env_file:
- .env
- ../.env
ports:
- "9000:9000"
- "9001:9001"
@@ -55,7 +55,7 @@ services:
ports:
- "9090:80"
env_file:
- .env
- ../.env
depends_on:
- server