1010using Chats . BE . Services . Security ;
1111using Microsoft . AspNetCore . Authentication ;
1212using Microsoft . AspNetCore . Mvc ;
13+ using System . Reflection ;
1314using System . Runtime . CompilerServices ;
1415using Chats . BE . Services . FileServices ;
1516using Microsoft . AspNetCore . StaticFiles ;
1617using Chats . BE . Services . Models . ChatServices ;
18+ using Chats . BE . Controllers . Admin . GlobalConfigs ;
1719
1820[ assembly: InternalsVisibleTo ( "Chats.BE.Tests" ) ]
1921
2022namespace Chats . BE ;
2123
2224public class Program
2325{
26+ private static string ? CurrentVersion => typeof ( Program ) . Assembly
27+ . GetCustomAttribute < AssemblyFileVersionAttribute > ( ) ?
28+ . Version ;
29+
2430 public static async Task Main ( string [ ] args )
2531 {
2632 WebApplicationBuilder builder = WebApplication . CreateBuilder ( args ) ;
@@ -38,7 +44,10 @@ public static async Task Main(string[] args)
3844 builder . Services . AddEndpointsApiExplorer ( ) ;
3945 builder . Services . AddSwaggerGen ( ) ;
4046 builder . Services . AddDbContext < ChatsDB > ( o => o . Configure ( builder . Configuration , builder . Environment ) ) ;
41- builder . Services . AddHttpClient ( ) ;
47+ builder . Services . AddHttpClient ( string . Empty , httpClient =>
48+ {
49+ httpClient . DefaultRequestHeaders . UserAgent . ParseAdd ( $ "Sdcb-Chats/{ CurrentVersion } ") ;
50+ } ) ;
4251 builder . Services . AddSingleton < InitService > ( ) ;
4352 builder . Services . AddSingleton < AppConfigService > ( ) ;
4453 builder . Services . AddSingleton < CsrfTokenService > ( ) ;
@@ -77,6 +86,7 @@ public static async Task Main(string[] args)
7786 builder . Services . AddSingleton < FileImageInfoService > ( ) ;
7887 builder . Services . AddSingleton < AsyncClientInfoManager > ( ) ;
7988 builder . Services . AddSingleton < AsyncCacheUsageManager > ( ) ;
89+ builder . Services . AddSingleton < GitHubReleaseChecker > ( ) ;
8090
8191 builder . Services . AddScoped < CurrentUser > ( ) ;
8292 builder . Services . AddScoped < CurrentApiKey > ( ) ;
0 commit comments