Skip to content

Commit

Permalink
Merge pull request #321 from zaanposni/release/v1.12
Browse files Browse the repository at this point in the history
Release/v1.12
  • Loading branch information
zaanposni authored Jul 17, 2021
2 parents d0ef8c9 + 0a5791e commit 8b08149
Show file tree
Hide file tree
Showing 62 changed files with 1,045 additions and 114 deletions.
2 changes: 2 additions & 0 deletions backend/masz/Controllers/api/v1/GuildConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public async Task<IActionResult> CreateItem([FromBody] GuildConfigForCreateDto g
}
guildConfig.StrictModPermissionCheck = guildConfigForCreateDto.StrictModPermissionCheck;
guildConfig.ExecuteWhoisOnJoin = guildConfigForCreateDto.ExecuteWhoisOnJoin;
guildConfig.PublishModeratorInfo = guildConfigForCreateDto.PublishModeratorInfo;

await database.SaveGuildConfig(guildConfig);
await database.SaveChangesAsync();
Expand Down Expand Up @@ -191,6 +192,7 @@ public async Task<IActionResult> UpdateSpecificItem([FromRoute] string guildid,
}
guildConfig.StrictModPermissionCheck = newValue.StrictModPermissionCheck;
guildConfig.ExecuteWhoisOnJoin = newValue.ExecuteWhoisOnJoin;
guildConfig.PublishModeratorInfo = newValue.PublishModeratorInfo;

database.UpdateGuildConfig(guildConfig);
await database.SaveChangesAsync();
Expand Down
11 changes: 11 additions & 0 deletions backend/masz/Controllers/api/v1/ModCaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public async Task<IActionResult> GetSpecificItem([FromRoute] string guildid, [Fr
}
ModCase modCase = await database.SelectSpecificModCase(guildid, modcaseid);

if (!(await this.HasPermissionOnGuild(DiscordPermission.Moderator, guildid) || (await this.GuildIsRegistered(guildid)).PublishModeratorInfo)) {
modCase.RemoveModeratorInfo();
}

logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 200 Returning ModCase.");
return Ok(modCase);
}
Expand Down Expand Up @@ -326,6 +330,13 @@ public async Task<IActionResult> GetAllItems([FromRoute] string guildid, [FromQu
modCases = await database.SelectAllModcasesForSpecificUserOnGuild(guildid, currentUser.Id, startPage, 20);
}

if (!(await this.HasPermissionOnGuild(DiscordPermission.Moderator, guildid) || (await this.GuildIsRegistered(guildid)).PublishModeratorInfo)) {
foreach (var modCase in modCases)
{
modCase.RemoveModeratorInfo();
}
}

logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 200 Returning ModCases.");
return Ok(modCases);
}
Expand Down
4 changes: 4 additions & 0 deletions backend/masz/Controllers/api/v1/Views/CaseViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ await discord.FetchUserInfo(modCase.UserId, CacheBehavior.OnlyCache),
caseView.DeletedBy = await discord.FetchUserInfo(modCase.DeletedByUserId, CacheBehavior.OnlyCache);
}

if (!(await this.HasPermissionOnGuild(DiscordPermission.Moderator, guildid) || (await this.GuildIsRegistered(guildid)).PublishModeratorInfo)) {
caseView.RemoveModeratorInfo();
}

logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 200 Returning ModCase.");
return Ok(caseView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,19 @@ private async Task<IActionResult> generateTable(string guildid, ModcaseTableType
modCases = modCases.Skip(startPage * 20).Take(20).ToList();
}

bool publishMod = (await this.GuildIsRegistered(guildid)).PublishModeratorInfo || await this.HasPermissionOnGuild(DiscordPermission.Moderator, guildid);
List<ModCaseTableEntry> table = new List<ModCaseTableEntry>();
foreach (var c in modCases)
{
table.Add( new ModCaseTableEntry() {
var entry = new ModCaseTableEntry() {
ModCase = c,
Suspect = await discord.FetchUserInfo(c.UserId, CacheBehavior.OnlyCache),
Moderator = await discord.FetchUserInfo(c.ModId, CacheBehavior.OnlyCache)
});
};
if (!publishMod) {
entry.RemoveModeratorInfo();
}
table.Add(entry);
}

if (!String.IsNullOrWhiteSpace(search)) {
Expand Down
1 change: 1 addition & 0 deletions backend/masz/Dtos/GuildConfig/GuildConfigForCreateDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public class GuildConfigForCreateDto
public string ModInternalNotificationWebhook { get; set; }
public bool ExecuteWhoisOnJoin { get; set; } = false;
public bool StrictModPermissionCheck { get; set; } = false;
public bool PublishModeratorInfo { get; set; } = true;
}
}
3 changes: 2 additions & 1 deletion backend/masz/Dtos/GuildConfig/GuildConfigForPutDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class GuildConfigForPutDto
[Url(ErrorMessage = "Webhook needs to be a valid url")]
[RegularExpression(@"^https://discord(app)?\.com/.*$", ErrorMessage = "please specify a url that starts with 'https://discordapp.com/'.")]
public string ModInternalNotificationWebhook { get; set; }
public bool StrictModPermissionCheck { get; set; }
public bool ExecuteWhoisOnJoin { get; set; }
public bool StrictModPermissionCheck { get; set; }
public bool PublishModeratorInfo { get; set; } = true;
}
}
Loading

0 comments on commit 8b08149

Please sign in to comment.