Skip to content

Commit

Permalink
Merge pull request #549 from zaanposni/release/v3.2.1
Browse files Browse the repository at this point in the history
Release/v3.2.1
  • Loading branch information
zaanposni authored Nov 12, 2022
2 parents a0c0263 + e245f91 commit 9dc978d
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 49 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@
**A website and a discord bot** - to use MASZ\
**Full API and plugin support** - for custom scripts and automations

### 🚀 Demo

[![https://demomasz.zaanposni.com](https://img.shields.io/badge/demo-online-%234c1?style=for-the-badge)](https://demomasz.zaanposni.com)

Visit [https://demomasz.zaanposni.com](https://demomasz.zaanposni.com) for a demo.\
Furthermore, join the demo guild [https://discord.gg/7ubU6aWX9c](https://discord.gg/7ubU6aWX9c) to get the required permissions.

### 👀 Preview
## 👀 Preview

![dashboard preview](/docs/dashboard.png)

Expand Down
7 changes: 7 additions & 0 deletions backend/MASZ/AutoModeration/AutoModerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ private async Task<bool> IsProtectedByFilter(IMessage message, AutoModerationCon
return true;
}

if (message.Channel is ITextChannel textChannel)
{
if (textChannel.CategoryId.HasValue) {
return autoModerationConfig.IgnoreChannels.Contains(message.Channel.Id) || autoModerationConfig.IgnoreChannels.Contains(textChannel.CategoryId.Value);
}
}

return autoModerationConfig.IgnoreChannels.Contains((message.Channel as ITextChannel).Id);
}

Expand Down
2 changes: 1 addition & 1 deletion backend/MASZ/MASZ.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.Discord" Version="6.0.1" />
<PackageReference Include="AspNetCoreRateLimit" Version="4.0.1" />
<PackageReference Include="Discord.Net" Version="3.8.0" />
<PackageReference Include="Discord.Net" Version="3.8.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.1" />
Expand Down
9 changes: 8 additions & 1 deletion backend/MASZ/Models/Views/Discord/DiscordChannelView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ public DiscordChannelView(IGuildChannel channel)
Id = channel.Id.ToString();
Name = channel.Name;
Position = channel.Position;
Type = (int)channel.GetChannelType();
// forum channels currently throw an error, will be fixed in new d.net version that is not yet released
// https://github.com/discord-net/Discord.Net/pull/2469
try {
Type = (int)channel.GetChannelType();
}
catch(Exception) {
Type = -1;
}
}

public static DiscordChannelView CreateOrDefault(IGuildChannel channel)
Expand Down
6 changes: 5 additions & 1 deletion backend/MASZ/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@

// SINGLETONS


// message content intent not yet released in stable d.net
// https://github.com/discord-net/Discord.Net/blob/dev/src/Discord.Net.Core/GatewayIntents.cs#L46

.AddSingleton(new DiscordSocketConfig
{
AlwaysDownloadUsers = true,
MessageCacheSize = 10240,
LogLevel = LogSeverity.Debug,
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.GuildMembers | GatewayIntents.GuildMessages | GatewayIntents.DirectMessages,
GatewayIntents = (GatewayIntents)((int) GatewayIntents.AllUnprivileged | (int) GatewayIntents.GuildMembers | (int) GatewayIntents.GuildMessages | (int) GatewayIntents.DirectMessages | 1 << 15),
LogGatewayIntentWarnings = false
})

Expand Down
66 changes: 38 additions & 28 deletions backend/MASZ/Services/GuildAuditLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public async Task<bool> CheckForIgnoredRoles(ulong guildId, GuildAuditLogEvent e
return await CheckForIgnoredRoles(guildId, eventType, roles.Select(role => role.Id).ToList());
}

public async Task<bool> CheckForIgnoredChannel(ulong guildId, GuildAuditLogEvent eventType, ulong channelId)
public async Task<bool> CheckForIgnoredChannel(ulong guildId, GuildAuditLogEvent eventType, INestedChannel channel)
{
using var scope = _serviceProvider.CreateScope();

Expand All @@ -171,7 +171,17 @@ public async Task<bool> CheckForIgnoredChannel(ulong guildId, GuildAuditLogEvent
{
return false;
}
return auditLogConfig.IgnoreChannels?.Contains(channelId) ?? false;

if (auditLogConfig.IgnoreChannels == null)
{
return false;
}

if (channel.CategoryId.HasValue) {
return auditLogConfig.IgnoreChannels.Contains(channel.Id) || auditLogConfig.IgnoreChannels.Contains(channel.CategoryId.Value);
} else {
return auditLogConfig.IgnoreChannels.Contains(channel.Id);
}
}
catch (ResourceNotFoundException) { }
return false;
Expand Down Expand Up @@ -333,10 +343,10 @@ private async Task HandleReactionRemoved(Cacheable<IUserMessage, ulong> message,
{
using var scope = _serviceProvider.CreateScope();

IGuildChannel guildChannel;
ITextChannel guildChannel;
try
{
guildChannel = (IGuildChannel)await _client.GetChannelAsync(channel.Id);
guildChannel = (ITextChannel)await _client.GetChannelAsync(channel.Id);
if (guildChannel == null)
{
return;
Expand All @@ -347,7 +357,7 @@ private async Task HandleReactionRemoved(Cacheable<IUserMessage, ulong> message,
return;
}

if (await CheckForIgnoredChannel(guildChannel.GuildId, GuildAuditLogEvent.ReactionRemoved, guildChannel.Id))
if (await CheckForIgnoredChannel(guildChannel.GuildId, GuildAuditLogEvent.ReactionRemoved, guildChannel))
{
return;
}
Expand Down Expand Up @@ -385,10 +395,10 @@ private async Task HandleReactionAdded(Cacheable<IUserMessage, ulong> message, C
{
using var scope = _serviceProvider.CreateScope();

IGuildChannel guildChannel;
ITextChannel guildChannel;
try
{
guildChannel = (IGuildChannel)await _client.GetChannelAsync(channel.Id);
guildChannel = (ITextChannel)await _client.GetChannelAsync(channel.Id);
if (guildChannel == null)
{
return;
Expand All @@ -399,7 +409,7 @@ private async Task HandleReactionAdded(Cacheable<IUserMessage, ulong> message, C
return;
}

if (await CheckForIgnoredChannel(guildChannel.GuildId, GuildAuditLogEvent.ReactionRemoved, guildChannel.Id))
if (await CheckForIgnoredChannel(guildChannel.GuildId, GuildAuditLogEvent.ReactionAdded, guildChannel))
{
return;
}
Expand Down Expand Up @@ -497,27 +507,27 @@ private async Task HandleVoiceStateUpdated(SocketUser user, SocketVoiceState voi

if (eventType == GuildAuditLogEvent.VoiceJoined)
{
if (await CheckForIgnoredChannel(guildId, GuildAuditLogEvent.VoiceJoined, afterChannel.Id))
if (await CheckForIgnoredChannel(guildId, GuildAuditLogEvent.VoiceJoined, afterChannel))
{
return;
}
description.AppendLine($"> **{translator.T().GuildAuditLogChannel()}:** {afterChannel.Name} - {afterChannel.Mention}");
}
else if (eventType == GuildAuditLogEvent.VoiceLeft)
{
if (await CheckForIgnoredChannel(guildId, GuildAuditLogEvent.VoiceLeft, beforeChannel.Id))
if (await CheckForIgnoredChannel(guildId, GuildAuditLogEvent.VoiceLeft, beforeChannel))
{
return;
}
description.AppendLine($"> **{translator.T().GuildAuditLogChannel()}:** {beforeChannel.Name} - {beforeChannel.Mention}");
}
else
{
if (await CheckForIgnoredChannel(guildId, GuildAuditLogEvent.VoiceMoved, beforeChannel.Id))
if (await CheckForIgnoredChannel(guildId, GuildAuditLogEvent.VoiceMoved, beforeChannel))
{
return;
}
if (await CheckForIgnoredChannel(guildId, GuildAuditLogEvent.VoiceMoved, afterChannel.Id))
if (await CheckForIgnoredChannel(guildId, GuildAuditLogEvent.VoiceMoved, afterChannel))
{
return;
}
Expand Down Expand Up @@ -593,11 +603,10 @@ public async Task HandleInviteCreated(SocketInvite invite)
if (invite.Channel is ITextChannel tChannel)
{
description.AppendLine($"> **{translator.T().GuildAuditLogInviteCreatedTargetChannel()}:** {tChannel.Name} - {tChannel.Mention}");
}

if (invite.GuildId.HasValue && await CheckForIgnoredChannel(invite.GuildId.Value, GuildAuditLogEvent.InviteCreated, invite.ChannelId))
{
return;
if (invite.GuildId.HasValue && await CheckForIgnoredChannel(invite.GuildId.Value, GuildAuditLogEvent.InviteCreated, tChannel))
{
return;
}
}

embed.WithTitle(translator.T().GuildAuditLogInviteCreatedTitle())
Expand Down Expand Up @@ -645,11 +654,10 @@ public async Task HandleInviteDeleted(SocketGuildChannel channel, string tracker
if (channel is ITextChannel tChannel)
{
description.AppendLine($"> **{translator.T().GuildAuditLogInviteCreatedTargetChannel()}:** {tChannel.Name} - {tChannel.Mention}");
}

if (await CheckForIgnoredChannel(invite.GuildId, GuildAuditLogEvent.InviteCreated, channel.Id))
{
return;
if (await CheckForIgnoredChannel(invite.GuildId, GuildAuditLogEvent.InviteCreated, tChannel))
{
return;
}
}

embed.WithTitle(translator.T().GuildAuditLogInviteDeletedTitle())
Expand Down Expand Up @@ -711,7 +719,7 @@ public async Task HandleMessageDeleted(Cacheable<IMessage, ulong> messageCached,

if (message.Channel is ITextChannel tchannel)
{
if (await CheckForIgnoredChannel(tchannel.GuildId, GuildAuditLogEvent.MessageDeleted, tchannel.Id))
if (await CheckForIgnoredChannel(tchannel.GuildId, GuildAuditLogEvent.MessageDeleted, tchannel))
{
return;
}
Expand Down Expand Up @@ -797,7 +805,7 @@ public async Task HandleMessageSent(IMessage message)
{
if (message.Channel is ITextChannel tchannel)
{
if (await CheckForIgnoredChannel(tchannel.GuildId, GuildAuditLogEvent.MessageSent, tchannel.Id))
if (await CheckForIgnoredChannel(tchannel.GuildId, GuildAuditLogEvent.MessageSent, tchannel))
{
return;
}
Expand Down Expand Up @@ -873,7 +881,7 @@ public async Task HandleMessageUpdated(Cacheable<IMessage, ulong> messageBefore,
{
if (channel is ITextChannel tchannel)
{
if (await CheckForIgnoredChannel(tchannel.GuildId, GuildAuditLogEvent.MessageUpdated, tchannel.Id))
if (await CheckForIgnoredChannel(tchannel.GuildId, GuildAuditLogEvent.MessageUpdated, tchannel))
{
return;
}
Expand Down Expand Up @@ -967,9 +975,11 @@ public async Task HandleMessageUpdated(Cacheable<IMessage, ulong> messageBefore,

public async Task HandleThreadCreated(SocketThreadChannel thread)
{
if (await CheckForIgnoredChannel(thread.Guild.Id, GuildAuditLogEvent.ThreadCreated, thread.ParentChannel.Id))
{
return;
if (thread.ParentChannel is ITextChannel tChannel) {
if (await CheckForIgnoredChannel(thread.Guild.Id, GuildAuditLogEvent.ThreadCreated, tChannel))
{
return;
}
}

using var scope = _serviceProvider.CreateScope();
Expand Down
12 changes: 6 additions & 6 deletions nginx/masz-svelte/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
const channelPromise = API.get(`/discord/guilds/${$currentParams.guildId}/channels`, CacheMode.PREFER_CACHE, true).then((response) => {
channels.set(
response
.filter((x) => x.type === 0)
.filter((x) => x.type === 0 || x.type === -1)
.sort((a, b) => (a.position > b.position ? 1 : -1))
.map((channel: IDiscordChannel) => ({
id: channel.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
API.get(`/discord/guilds/${$currentParams.guildId}/channels`, CacheMode.PREFER_CACHE, true).then((response) => {
channels.set(
response
.filter((x) => x.type === 0)
.filter((x) => x.type === 0 || x.type === -1)
.sort((a, b) => (a.position > b.position ? 1 : -1))
.map((channel: IDiscordChannel) => ({
id: channel.id,
Expand Down
2 changes: 1 addition & 1 deletion nginx/masz-svelte/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const LOCAL_STORAGE_KEY_GUILD_QUICKSEARCH_HISTORY = "__masz-guild-quickse
export const FEEDBACK_COOKIE_NAME = "__masz-feedback";

export const APP_NAME = "MASZ";
export const APP_VERSION = "v3.2.0";
export const APP_VERSION = "v3.2.1";

export const GUILD_QUICKSEARCH_MAX_HISTORY_ENTRIES = 10;

Expand Down
32 changes: 32 additions & 0 deletions nginx/static/patchnotes.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
[
{
"title": "Version 3.2.1",
"version": "v3.2.1",
"released_at": "2022-11-12",
"contributors": [
{
"name": "FlixProd",
"link": "https://github.com/FlixProd",
"icon": "https://avatars.githubusercontent.com/u/68478616?v=4"
}
],
"fixes": [
{
"title": "Fixed internal server error for channel API.",
"description": "A bug has been fixed that caused channel lists to be empty or fail, if the guild has a forum channel."
},
{
"title": "Fixed reaction added guild auditlog filter.",
"description": "The reaction added guild auditlog did not correctly respect the filtered channels."
}
],
"technical": [
{
"title": "Correctly request message content intent.",
"description": "MASZ will now correctly use the message content intent when connecting to the Discord API."
},
{
"title": "Removed demo instance from readme and website.",
"description": "The demo instance of MASZ will be shut down soon. The links to the demo instance have been removed from the readme and website."
}
]
},
{
"title": "Version 3.2.0",
"version": "v3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion nginx/static/version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v3.2.0",
"version": "v3.2.1",
"wrapper_version": 4,
"pre_release": false
}

0 comments on commit 9dc978d

Please sign in to comment.