Skip to content

Commit

Permalink
Merge pull request #4 from SorenNeedsCoffee/development
Browse files Browse the repository at this point in the history
v1.0.3 - last minute bug fixes/cleanup
  • Loading branch information
murl-digital authored Feb 5, 2021
2 parents a563a3f + a7d35d7 commit 2e8e719
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 86 deletions.
2 changes: 1 addition & 1 deletion GarbageCan/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0
COPY bin/Release/netcoreapp5.0 GarbageCan/
WORKDIR /GarbageCan
COPY bin/Release/netcoreapp5.0 GarbageCan/
ENTRYPOINT ["dotnet", "GarbageCan.dll"]
24 changes: 14 additions & 10 deletions GarbageCan/Roles/RoleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ private Task HandleJoinRoles(DiscordClient sender, GuildMemberUpdateEventArgs e)
{
if (e.Member.IsBot) return Task.CompletedTask;
if (!_watchedUsers.Contains(e.Member.Id)) return Task.CompletedTask;
if (e.Member.IsPending ?? true) return Task.CompletedTask;
_watchedUsers.Remove(e.Member.Id);

Task.Run(async () =>
Expand Down Expand Up @@ -152,22 +151,27 @@ private static void HandleLevelRoles(object sender, XpEventArgs args)
try
{
var lvlArgs = (LevelUpArgs) args;
var member = await args.context.Guild.GetMemberAsync(args.id);
await using var context = new Context();
var removeRoles = context.levelRoles.Where(r => r.lvl == lvlArgs.oldLvl && !r.remain).ForEachAsync(
async r =>
var roles = context.levelRoles.OrderBy(r => r.lvl).Where(r => !r.remain).ToList();
var index = 0;
foreach (var r in roles)
{
if (r.lvl == lvlArgs.lvl && index > 0)
{
var role = args.context.Guild.GetRole(r.roleId);
var member = await args.context.Guild.GetMemberAsync(args.id);
var role = args.context.Guild.GetRole(roles[index-1].roleId);
await member.RevokeRoleAsync(role);
});
var addRoles = context.levelRoles.Where(r => r.lvl == lvlArgs.lvl).ForEachAsync(async r =>
break;
}
index++;
}
await context.levelRoles.Where(r => r.lvl == lvlArgs.lvl).ForEachAsync(async r =>
{
var role = args.context.Guild.GetRole(r.roleId);
var member = await args.context.Guild.GetMemberAsync(args.id);
await member.GrantRoleAsync(role);
});
await Task.WhenAll(removeRoles, addRoles);
}
catch (Exception e)
{
Expand Down
40 changes: 0 additions & 40 deletions GarbageCan/Web/Controllers/WeatherForecastController.cs

This file was deleted.

12 changes: 12 additions & 0 deletions GarbageCan/Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
Expand Down Expand Up @@ -49,6 +51,16 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
}

//app.UseHttpsRedirection();

var forwardedHeadersOptions = new ForwardedHeadersOptions {
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
};
forwardedHeadersOptions.KnownNetworks.Clear();
forwardedHeadersOptions.KnownProxies.Clear();
app.UseForwardedHeaders(forwardedHeadersOptions);

var rewriteOptions = new RewriteOptions().AddRedirectToHttps(308);
app.UseRewriter(rewriteOptions);

app.UseRouting();
app.UseCors("gbc");
Expand Down
15 changes: 0 additions & 15 deletions GarbageCan/Web/WeatherForecast.cs

This file was deleted.

2 changes: 1 addition & 1 deletion GarbageCan/Web/Program.cs → GarbageCan/Web/WebAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace GarbageCan.Web
{
public class Program : IFeature
public class WebAPI : IFeature
{
public IHost HostObj;

Expand Down
9 changes: 0 additions & 9 deletions GarbageCan/Web/appsettings.Development.json

This file was deleted.

10 changes: 0 additions & 10 deletions GarbageCan/Web/appsettings.json

This file was deleted.

0 comments on commit 2e8e719

Please sign in to comment.