File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using MongoDB . Bson ;
2+
3+ namespace TelegramDownloader . Helpers
4+ {
5+ /// <summary>
6+ /// Custom type mapper for Guid to BsonValue conversion.
7+ /// Used by Serilog.Sinks.MongoDB to properly serialize Guid properties in logs.
8+ /// </summary>
9+ public class GuidTypeMapper : ICustomBsonTypeMapper
10+ {
11+ public bool TryMapToBsonValue ( object value , out BsonValue bsonValue )
12+ {
13+ if ( value is Guid guid )
14+ {
15+ bsonValue = new BsonString ( guid . ToString ( ) ) ;
16+ return true ;
17+ }
18+ bsonValue = null ! ;
19+ return false ;
20+ }
21+ }
22+ }
Original file line number Diff line number Diff line change 1818 </p >
1919 <div class =" version-badge" >
2020 <i class =" bi bi-tag" ></i >
21- v1 . 0 . 0
21+ v @AppVersion
2222 </div >
2323 </div >
2424
186186 private User user { get ; set ; }
187187 private DirectorySizeModel ? dirSize { get ; set ; }
188188 private bool showFilesBreakdown { get ; set ; } = false ;
189+ private string AppVersion => typeof (Program ).Assembly .GetName ().Version ? .ToString () ?? " 0.0.0" ;
189190
190191 private void ToggleFilesBreakdown ()
191192 {
Original file line number Diff line number Diff line change 66using Microsoft . AspNetCore . StaticFiles ;
77using Microsoft . Extensions . FileProviders ;
88using MongoDB . Bson ;
9- using MongoDB . Bson . Serialization ;
10- using MongoDB . Bson . Serialization . Serializers ;
119using Serilog ;
1210using Serilog . Debugging ;
1311using Serilog . Events ;
1614using System . Net . Http ;
1715using TelegramDownloader . Data ;
1816using TelegramDownloader . Data . db ;
17+ using TelegramDownloader . Helpers ;
1918using TelegramDownloader . Models ;
2019using TelegramDownloader . Services ;
2120using TelegramDownloader . Services . GitHub ;
2221using TL ;
2322
24- // Register Guid serializer for MongoDB to handle Guid types in log properties
25- BsonSerializer . RegisterSerializer ( new GuidSerializer ( BsonType . String ) ) ;
23+ // Register Guid type mapper for MongoDB to handle Guid types in log properties (used by Serilog sink)
24+ BsonTypeMapper . RegisterCustomTypeMapper ( typeof ( Guid ) , new GuidTypeMapper ( ) ) ;
2625
2726var extensionProvider = new FileExtensionContentTypeProvider ( ) ;
2827foreach ( var mime in FileService . MIMETypesDictionary )
You can’t perform that action at this time.
0 commit comments