chore: deleted all the stuff we don't need here
This commit is contained in:
@@ -6,14 +6,6 @@ using GamificationService.Database;
|
||||
using GamificationService.Database.Repositories;
|
||||
using GamificationService.Logs;
|
||||
using GamificationService.Mapper;
|
||||
using GamificationService.Services.Cookies;
|
||||
using GamificationService.Services.CurrentUsers;
|
||||
using GamificationService.Services.JWT;
|
||||
using GamificationService.Services.NotificationService;
|
||||
using GamificationService.Services.Rights;
|
||||
using GamificationService.Services.Roles;
|
||||
using GamificationService.Utils;
|
||||
using GamificationService.Utils.Factory;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
@@ -135,56 +127,6 @@ public static class UtilServicesExtensions
|
||||
{
|
||||
public static IServiceCollection AddUtilServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IJwtService, JwtService>();
|
||||
services.AddScoped<ICookieService, CookieService>();
|
||||
services.AddScoped<INotificationService,NotificationService>();
|
||||
services.AddScoped<IRightsService,RightsService>();
|
||||
services.AddScoped<IRolesService, RolesService>();
|
||||
services.AddScoped<ICurrentUserService, CurrentUserService>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
public static class NotificationSettings
|
||||
{
|
||||
public static IServiceCollection AddPushNotifications(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var notificationSettings = configuration.GetSection("NotificationSettings");
|
||||
var apiKey = notificationSettings["ApiKey"];
|
||||
var token = notificationSettings["Token"];
|
||||
var baseUrl = notificationSettings["Url"];
|
||||
var projectId = notificationSettings["ProjectId"];
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
client.BaseAddress = new Uri(baseUrl);
|
||||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
|
||||
|
||||
services.AddSingleton(provider =>
|
||||
{
|
||||
var logger = provider.GetRequiredService<ILogger<PushNotificationsClient>>();
|
||||
return new PushNotificationsClient(client, logger, token, projectId);
|
||||
});
|
||||
return services;
|
||||
}
|
||||
}
|
||||
public static class EmailExtensions
|
||||
{
|
||||
public static IServiceCollection AddEmail(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var smtpSettings = configuration.GetSection("EmailSettings");
|
||||
var host = smtpSettings["Host"] ?? "localhost";
|
||||
var port = Convert.ToInt32(smtpSettings["Port"] ?? "25");
|
||||
var username = smtpSettings["Username"] ?? "username";
|
||||
var password = smtpSettings["Password"] ?? "password";
|
||||
var email = smtpSettings["EmailFrom"] ?? "email";
|
||||
services.AddScoped<SmtpClient>(sp => new SmtpClient(host)
|
||||
{
|
||||
Port = port,
|
||||
Credentials = new NetworkCredential(username, password),
|
||||
EnableSsl = true,
|
||||
});
|
||||
|
||||
services.AddSingleton<EmailClient>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -193,8 +135,6 @@ public static class FactoryExtensions
|
||||
{
|
||||
public static IServiceCollection AddFactories(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<MailNotificationsFactory>();
|
||||
services.AddSingleton<PushNotificationsFactory>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user