Skip to content

Commit 62e7711

Browse files
committed
fix images service being required even if feature is disabled
1 parent 1053db9 commit 62e7711

File tree

5 files changed

+79
-72
lines changed

5 files changed

+79
-72
lines changed

OutOfSchool/OutOfSchool.WebApi/Extensions/Startup/FileStorageExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ public static IServiceCollection AddImagesStorage(this IServiceCollection servic
3434
{
3535
_ = services ?? throw new ArgumentNullException(nameof(services));
3636

37-
var isDevelopment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development;
38-
39-
if (turnOnFakeStorage && isDevelopment)
37+
if (turnOnFakeStorage)
4038
{
4139
return services.AddTransient<IImageFilesStorage, FakeImagesStorage>();
4240
}

OutOfSchool/OutOfSchool.WebApi/Startup.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ public static void AddApplicationServices(this WebApplicationBuilder builder)
242242
services.AddTransient<IProviderRepository, ProviderRepository>();
243243
services.AddTransient<IWorkshopRepository, WorkshopRepository>();
244244
//services.AddTransient<IExternalImageStorage, ExternalImageStorage>();
245-
services.AddImagesStorage(turnOnFakeStorage: configuration.GetValue<bool>("TurnOnFakeImagesStorage"));
245+
var featuresConfig = configuration.GetSection(FeatureManagementConfig.Name).Get<FeatureManagementConfig>();
246+
var isImagesEnabled = featuresConfig.Images;
247+
var turnOnFakeStorage = configuration.GetValue<bool>("Images:TurnOnFakeImagesStorage") || !isImagesEnabled;
248+
services.AddImagesStorage(turnOnFakeStorage: turnOnFakeStorage);
246249

247250
services.AddTransient<IElasticsearchSyncRecordRepository, ElasticsearchSyncRecordRepository>();
248251
services.AddTransient<INotificationRepository, NotificationRepository>();
@@ -332,7 +335,7 @@ public static void AddApplicationServices(this WebApplicationBuilder builder)
332335
quartzConfig.ConnectionStringKey,
333336
q =>
334337
{
335-
if (!builder.Environment.IsEnvironment("Release"))
338+
if (!turnOnFakeStorage)
336339
{
337340
// TODO: for now this is not used in release
338341
q.AddGcpSynchronization(services, quartzConfig);

OutOfSchool/OutOfSchool.WebApi/appsettings.Development.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
"Quartz": {
4343
"ConnectionStringKey": "QuartzConnection"
4444
},
45-
"TurnOnFakeImagesStorage": true,
4645
"Redis": {
4746
"Password": "Qwerty123!"
47+
},
48+
"Images": {
49+
"TurnOnFakeImagesStorage": true
4850
}
4951
}

OutOfSchool/OutOfSchool.WebApi/appsettings.Release.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
"FeatureManagement": {
7272
"Release1": true,
73-
"Release2": true,
73+
"Release2": false,
7474
"Release3": false,
7575
"Images": false
7676
},
@@ -144,6 +144,9 @@
144144
},
145145
"StatisticReports": {
146146
"UseExternalStorage": false
147+
},
148+
"Images": {
149+
"TurnOnFakeImagesStorage": true
147150
}
148151
}
149152

OutOfSchool/OutOfSchool.WebApi/appsettings.json

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -80,60 +80,61 @@
8080
}
8181
},
8282
"Images": {
83-
"Workshop": {
84-
"Specs": {
85-
"MinWidthPixels": 350,
86-
"MaxWidthPixels": 10000,
87-
"MinHeightPixels": 250,
88-
"MaxHeightPixels": 8000,
89-
"MaxSizeBytes": 16777216,
90-
"MinWidthHeightRatio": 1,
91-
"MaxWidthHeightRatio": 3,
92-
"SupportedFormats": [
93-
"jpeg",
94-
"png"
95-
]
96-
},
97-
"Limits": {
98-
"MaxCountOfFiles": 10
99-
}
83+
"TurnOnFakeImagesStorage": false,
84+
"Workshop": {
85+
"Specs": {
86+
"MinWidthPixels": 350,
87+
"MaxWidthPixels": 10000,
88+
"MinHeightPixels": 250,
89+
"MaxHeightPixels": 8000,
90+
"MaxSizeBytes": 16777216,
91+
"MinWidthHeightRatio": 1,
92+
"MaxWidthHeightRatio": 3,
93+
"SupportedFormats": [
94+
"jpeg",
95+
"png"
96+
]
10097
},
101-
"Teacher": {
102-
"Specs": {
103-
"MinWidthPixels": 350,
104-
"MaxWidthPixels": 10000,
105-
"MinHeightPixels": 250,
106-
"MaxHeightPixels": 8000,
107-
"MaxSizeBytes": 16777216,
108-
"MinWidthHeightRatio": 0.5,
109-
"MaxWidthHeightRatio": 2,
110-
"SupportedFormats": [
111-
"jpeg",
112-
"png"
113-
]
114-
},
115-
"Limits": {
116-
"MaxCountOfFiles": 1
117-
}
98+
"Limits": {
99+
"MaxCountOfFiles": 10
100+
}
101+
},
102+
"Teacher": {
103+
"Specs": {
104+
"MinWidthPixels": 350,
105+
"MaxWidthPixels": 10000,
106+
"MinHeightPixels": 250,
107+
"MaxHeightPixels": 8000,
108+
"MaxSizeBytes": 16777216,
109+
"MinWidthHeightRatio": 0.5,
110+
"MaxWidthHeightRatio": 2,
111+
"SupportedFormats": [
112+
"jpeg",
113+
"png"
114+
]
118115
},
119-
"Provider": {
120-
"Specs": {
121-
"MinWidthPixels": 350,
122-
"MaxWidthPixels": 10000,
123-
"MinHeightPixels": 250,
124-
"MaxHeightPixels": 8000,
125-
"MaxSizeBytes": 16777216,
126-
"MinWidthHeightRatio": 0.5,
127-
"MaxWidthHeightRatio": 2,
128-
"SupportedFormats": [
129-
"jpeg",
130-
"png"
131-
]
132-
},
133-
"Limits": {
134-
"MaxCountOfFiles": 4
135-
}
116+
"Limits": {
117+
"MaxCountOfFiles": 1
118+
}
119+
},
120+
"Provider": {
121+
"Specs": {
122+
"MinWidthPixels": 350,
123+
"MaxWidthPixels": 10000,
124+
"MinHeightPixels": 250,
125+
"MaxHeightPixels": 8000,
126+
"MaxSizeBytes": 16777216,
127+
"MinWidthHeightRatio": 0.5,
128+
"MaxWidthHeightRatio": 2,
129+
"SupportedFormats": [
130+
"jpeg",
131+
"png"
132+
]
133+
},
134+
"Limits": {
135+
"MaxCountOfFiles": 4
136136
}
137+
}
137138
},
138139

139140
"AllowedHosts": "*",
@@ -213,21 +214,21 @@
213214
}
214215
},
215216

216-
"ChangesLog": {
217-
"TrackedProperties": {
218-
"Provider": [ "FullTitle", "EdrpouIpn", "Director", "LegalAddress", "InstitutionId" ],
219-
"Application": [ "Status" ]
220-
}
221-
},
222-
"GeoCoding": {
223-
"BaseUrl": "https://api.visicom.ua/data-api/5.0/uk/geocode.json",
224-
"ApiKey": "",
225-
"Radius": 50
226-
},
227-
228-
"StatisticReports": {
229-
"UseExternalStorage": false
217+
"ChangesLog": {
218+
"TrackedProperties": {
219+
"Provider": [ "FullTitle", "EdrpouIpn", "Director", "LegalAddress", "InstitutionId" ],
220+
"Application": [ "Status" ]
230221
}
222+
},
223+
"GeoCoding": {
224+
"BaseUrl": "https://api.visicom.ua/data-api/5.0/uk/geocode.json",
225+
"ApiKey": "",
226+
"Radius": 50
227+
},
228+
229+
"StatisticReports": {
230+
"UseExternalStorage": false
231+
}
231232
}
232233

233234

0 commit comments

Comments
 (0)