initial commit

This commit is contained in:
Hampus Kraft
2026-01-01 20:42:59 +00:00
commit 2f557eda8c
9029 changed files with 1490197 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
export enum AuditLogActionType {
GUILD_UPDATE = 1,
CHANNEL_CREATE = 10,
CHANNEL_UPDATE = 11,
CHANNEL_DELETE = 12,
CHANNEL_OVERWRITE_CREATE = 13,
CHANNEL_OVERWRITE_UPDATE = 14,
CHANNEL_OVERWRITE_DELETE = 15,
MEMBER_KICK = 20,
MEMBER_PRUNE = 21,
MEMBER_BAN_ADD = 22,
MEMBER_BAN_REMOVE = 23,
MEMBER_UPDATE = 24,
MEMBER_ROLE_UPDATE = 25,
MEMBER_MOVE = 26,
MEMBER_DISCONNECT = 27,
BOT_ADD = 28,
ROLE_CREATE = 30,
ROLE_UPDATE = 31,
ROLE_DELETE = 32,
INVITE_CREATE = 40,
INVITE_UPDATE = 41,
INVITE_DELETE = 42,
WEBHOOK_CREATE = 50,
WEBHOOK_UPDATE = 51,
WEBHOOK_DELETE = 52,
EMOJI_CREATE = 60,
EMOJI_UPDATE = 61,
EMOJI_DELETE = 62,
STICKER_CREATE = 90,
STICKER_UPDATE = 91,
STICKER_DELETE = 92,
MESSAGE_DELETE = 72,
MESSAGE_BULK_DELETE = 73,
MESSAGE_PIN = 74,
MESSAGE_UNPIN = 75,
}
export const ALL_AUDIT_LOG_ACTION_TYPES: ReadonlyArray<AuditLogActionType> = [
AuditLogActionType.GUILD_UPDATE,
AuditLogActionType.CHANNEL_CREATE,
AuditLogActionType.CHANNEL_UPDATE,
AuditLogActionType.CHANNEL_DELETE,
AuditLogActionType.CHANNEL_OVERWRITE_CREATE,
AuditLogActionType.CHANNEL_OVERWRITE_UPDATE,
AuditLogActionType.CHANNEL_OVERWRITE_DELETE,
AuditLogActionType.MEMBER_KICK,
AuditLogActionType.MEMBER_PRUNE,
AuditLogActionType.MEMBER_BAN_ADD,
AuditLogActionType.MEMBER_BAN_REMOVE,
AuditLogActionType.MEMBER_UPDATE,
AuditLogActionType.MEMBER_ROLE_UPDATE,
AuditLogActionType.MEMBER_MOVE,
AuditLogActionType.MEMBER_DISCONNECT,
AuditLogActionType.BOT_ADD,
AuditLogActionType.ROLE_CREATE,
AuditLogActionType.ROLE_UPDATE,
AuditLogActionType.ROLE_DELETE,
AuditLogActionType.INVITE_CREATE,
AuditLogActionType.INVITE_UPDATE,
AuditLogActionType.INVITE_DELETE,
AuditLogActionType.WEBHOOK_CREATE,
AuditLogActionType.WEBHOOK_UPDATE,
AuditLogActionType.WEBHOOK_DELETE,
AuditLogActionType.EMOJI_CREATE,
AuditLogActionType.EMOJI_UPDATE,
AuditLogActionType.EMOJI_DELETE,
AuditLogActionType.STICKER_CREATE,
AuditLogActionType.STICKER_UPDATE,
AuditLogActionType.STICKER_DELETE,
AuditLogActionType.MESSAGE_DELETE,
AuditLogActionType.MESSAGE_BULK_DELETE,
AuditLogActionType.MESSAGE_PIN,
AuditLogActionType.MESSAGE_UNPIN,
];

View File

@@ -0,0 +1,251 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
import type {I18n, MessageDescriptor} from '@lingui/core';
import {msg} from '@lingui/core/macro';
import {AuditLogActionType} from './AuditLogActionType';
export const AUDIT_LOG_TARGET_TYPES = {
GUILD: 'guild',
MEMBER: 'member',
ROLE: 'role',
CHANNEL: 'channel',
EMOJI: 'emoji',
STICKER: 'sticker',
INVITE: 'invite',
WEBHOOK: 'webhook',
} as const;
export type AuditLogTargetType = (typeof AUDIT_LOG_TARGET_TYPES)[keyof typeof AUDIT_LOG_TARGET_TYPES];
export interface AuditLogActionDefinition {
value: AuditLogActionType;
label: MessageDescriptor;
targetType: AuditLogTargetType;
}
export const AUDIT_LOG_ACTIONS: ReadonlyArray<AuditLogActionDefinition> = [
{
value: AuditLogActionType.GUILD_UPDATE,
label: msg`Community Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.GUILD,
},
{
value: AuditLogActionType.CHANNEL_CREATE,
label: msg`Channel Created`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.CHANNEL_UPDATE,
label: msg`Channel Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.CHANNEL_DELETE,
label: msg`Channel Deleted`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.CHANNEL_OVERWRITE_CREATE,
label: msg`Channel Overwrite Added`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.CHANNEL_OVERWRITE_UPDATE,
label: msg`Channel Overwrite Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.CHANNEL_OVERWRITE_DELETE,
label: msg`Channel Overwrite Removed`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.MEMBER_KICK,
label: msg`Member Kicked`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.MEMBER_PRUNE,
label: msg`Members Pruned`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.MEMBER_BAN_ADD,
label: msg`Member Banned`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.MEMBER_BAN_REMOVE,
label: msg`Member Unbanned`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.MEMBER_UPDATE,
label: msg`Member Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.MEMBER_ROLE_UPDATE,
label: msg`Member Roles Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.MEMBER_MOVE,
label: msg`Member Moved`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.MEMBER_DISCONNECT,
label: msg`Member Disconnected`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.BOT_ADD,
label: msg`Bot Added`,
targetType: AUDIT_LOG_TARGET_TYPES.MEMBER,
},
{
value: AuditLogActionType.ROLE_CREATE,
label: msg`Role Created`,
targetType: AUDIT_LOG_TARGET_TYPES.ROLE,
},
{
value: AuditLogActionType.ROLE_UPDATE,
label: msg`Role Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.ROLE,
},
{
value: AuditLogActionType.ROLE_DELETE,
label: msg`Role Deleted`,
targetType: AUDIT_LOG_TARGET_TYPES.ROLE,
},
{
value: AuditLogActionType.INVITE_CREATE,
label: msg`Invite Created`,
targetType: AUDIT_LOG_TARGET_TYPES.INVITE,
},
{
value: AuditLogActionType.INVITE_UPDATE,
label: msg`Invite Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.INVITE,
},
{
value: AuditLogActionType.INVITE_DELETE,
label: msg`Invite Deleted`,
targetType: AUDIT_LOG_TARGET_TYPES.INVITE,
},
{
value: AuditLogActionType.WEBHOOK_CREATE,
label: msg`Webhook Created`,
targetType: AUDIT_LOG_TARGET_TYPES.WEBHOOK,
},
{
value: AuditLogActionType.WEBHOOK_UPDATE,
label: msg`Webhook Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.WEBHOOK,
},
{
value: AuditLogActionType.WEBHOOK_DELETE,
label: msg`Webhook Deleted`,
targetType: AUDIT_LOG_TARGET_TYPES.WEBHOOK,
},
{
value: AuditLogActionType.EMOJI_CREATE,
label: msg`Emoji Created`,
targetType: AUDIT_LOG_TARGET_TYPES.EMOJI,
},
{
value: AuditLogActionType.EMOJI_UPDATE,
label: msg`Emoji Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.EMOJI,
},
{
value: AuditLogActionType.EMOJI_DELETE,
label: msg`Emoji Deleted`,
targetType: AUDIT_LOG_TARGET_TYPES.EMOJI,
},
{
value: AuditLogActionType.STICKER_CREATE,
label: msg`Sticker Created`,
targetType: AUDIT_LOG_TARGET_TYPES.STICKER,
},
{
value: AuditLogActionType.STICKER_UPDATE,
label: msg`Sticker Updated`,
targetType: AUDIT_LOG_TARGET_TYPES.STICKER,
},
{
value: AuditLogActionType.STICKER_DELETE,
label: msg`Sticker Deleted`,
targetType: AUDIT_LOG_TARGET_TYPES.STICKER,
},
{
value: AuditLogActionType.MESSAGE_DELETE,
label: msg`Message Deleted`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.MESSAGE_BULK_DELETE,
label: msg`Messages Deleted`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.MESSAGE_PIN,
label: msg`Message Pinned`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
{
value: AuditLogActionType.MESSAGE_UNPIN,
label: msg`Message Unpinned`,
targetType: AUDIT_LOG_TARGET_TYPES.CHANNEL,
},
];
export function getTranslatedAuditLogActions(i18n: I18n): Array<{
value: AuditLogActionType;
label: string;
targetType: AuditLogTargetType;
}> {
return AUDIT_LOG_ACTIONS.map((action) => ({
...action,
label: i18n._(action.label),
}));
}
export const AUDIT_LOG_TARGET_LABELS: Record<AuditLogTargetType, MessageDescriptor> = {
[AUDIT_LOG_TARGET_TYPES.GUILD]: msg`Community`,
[AUDIT_LOG_TARGET_TYPES.MEMBER]: msg`Member`,
[AUDIT_LOG_TARGET_TYPES.ROLE]: msg`Role`,
[AUDIT_LOG_TARGET_TYPES.CHANNEL]: msg`Channel`,
[AUDIT_LOG_TARGET_TYPES.EMOJI]: msg`Emoji`,
[AUDIT_LOG_TARGET_TYPES.STICKER]: msg`Sticker`,
[AUDIT_LOG_TARGET_TYPES.INVITE]: msg`Invite`,
[AUDIT_LOG_TARGET_TYPES.WEBHOOK]: msg`Webhook`,
};
export function getTranslatedAuditLogTargetLabels(i18n: I18n): Record<AuditLogTargetType, string> {
const translatedLabels: Record<AuditLogTargetType, string> = {} as Record<AuditLogTargetType, string>;
for (const [key, descriptor] of Object.entries(AUDIT_LOG_TARGET_LABELS)) {
translatedLabels[key as AuditLogTargetType] = i18n._(descriptor);
}
return translatedLabels;
}

View File

@@ -0,0 +1,206 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
import type {I18n, MessageDescriptor} from '@lingui/core';
import {msg} from '@lingui/core/macro';
export interface ViolationCategoryDescriptor {
value: string;
name: MessageDescriptor;
desc: MessageDescriptor;
}
const MESSAGE_VIOLATION_CATEGORIES_DESCRIPTORS: Array<ViolationCategoryDescriptor> = [
{
value: 'harassment',
name: msg`Harassment or Bullying`,
desc: msg`Targeted attacks, threats, or sustained harassment`,
},
{
value: 'hate_speech',
name: msg`Hate Speech`,
desc: msg`Content promoting hatred based on protected characteristics`,
},
{
value: 'violent_content',
name: msg`Violent or Graphic Content`,
desc: msg`Glorification of violence or disturbing imagery`,
},
{
value: 'spam',
name: msg`Spam or Scam`,
desc: msg`Unsolicited advertising, phishing, or fraudulent content`,
},
{
value: 'nsfw_violation',
name: msg`NSFW Policy Violation`,
desc: msg`Sexual content in non-NSFW spaces or without consent`,
},
{
value: 'illegal_activity',
name: msg`Illegal Activity`,
desc: msg`Discussion or promotion of illegal activities`,
},
{
value: 'doxxing',
name: msg`Sharing Personal Information`,
desc: msg`Sharing private information without consent`,
},
{
value: 'self_harm',
name: msg`Self-Harm or Suicide`,
desc: msg`Content promoting self-harm or suicide`,
},
{
value: 'child_safety',
name: msg`Child Safety Concerns`,
desc: msg`Content sexualizing or endangering minors`,
},
{
value: 'malicious_links',
name: msg`Malicious Links`,
desc: msg`Phishing, malware, or dangerous links`,
},
{
value: 'impersonation',
name: msg`Impersonation`,
desc: msg`Pretending to be someone else or a company/organization`,
},
{
value: 'other',
name: msg`Other`,
desc: msg`Something else that violates Terms of Service or Community Guidelines`,
},
];
export interface ViolationCategory {
value: string;
name: string;
desc: string;
}
export function getMessageViolationCategories(i18n: I18n): Array<ViolationCategory> {
return MESSAGE_VIOLATION_CATEGORIES_DESCRIPTORS.map((category) => ({
value: category.value,
name: i18n._(category.name),
desc: i18n._(category.desc),
}));
}
const USER_VIOLATION_CATEGORIES_DESCRIPTORS: Array<ViolationCategoryDescriptor> = [
{
value: 'harassment',
name: msg`Harassment or Bullying`,
desc: msg`Targeted attacks, threats, or sustained harassment`,
},
{
value: 'hate_speech',
name: msg`Hate Speech`,
desc: msg`Content promoting hatred based on protected characteristics`,
},
{
value: 'spam_account',
name: msg`Spam Account`,
desc: msg`Account appears to exist solely for spamming`,
},
{
value: 'impersonation',
name: msg`Impersonation`,
desc: msg`User is impersonating someone else`,
},
{
value: 'underage_user',
name: msg`Underage User`,
desc: msg`User appears to be under 13 years old`,
},
{
value: 'inappropriate_profile',
name: msg`Inappropriate Profile`,
desc: msg`Profile contains offensive or NSFW content`,
},
{
value: 'other',
name: msg`Other`,
desc: msg`Something else that violates Terms of Service or Community Guidelines`,
},
];
export function getUserViolationCategories(i18n: I18n): Array<ViolationCategory> {
return USER_VIOLATION_CATEGORIES_DESCRIPTORS.map((category) => ({
value: category.value,
name: i18n._(category.name),
desc: i18n._(category.desc),
}));
}
const GUILD_VIOLATION_CATEGORIES_DESCRIPTORS: Array<ViolationCategoryDescriptor> = [
{
value: 'harassment',
name: msg`Harassment`,
desc: msg`Community engages in or enables targeted harassment`,
},
{
value: 'hate_speech',
name: msg`Hate Speech`,
desc: msg`Community promotes hatred based on protected characteristics`,
},
{
value: 'extremist_community',
name: msg`Extremist Community`,
desc: msg`Community promotes extremist ideologies`,
},
{
value: 'illegal_activity',
name: msg`Illegal Activity`,
desc: msg`Community promotes or facilitates illegal activities`,
},
{
value: 'child_safety',
name: msg`Child Safety Concerns`,
desc: msg`Content sexualizing or endangering minors`,
},
{
value: 'raid_coordination',
name: msg`Raid Coordination`,
desc: msg`Community organizes raids or harassment campaigns`,
},
{
value: 'spam',
name: msg`Spam or Scam Community`,
desc: msg`Community exists solely for spam or fraudulent purposes`,
},
{
value: 'malware_distribution',
name: msg`Malware Distribution`,
desc: msg`Community distributes malicious files or links`,
},
{
value: 'other',
name: msg`Other`,
desc: msg`Something else that violates Terms of Service or Community Guidelines`,
},
];
export function getGuildViolationCategories(i18n: I18n): Array<ViolationCategory> {
return GUILD_VIOLATION_CATEGORIES_DESCRIPTORS.map((category) => ({
value: category.value,
name: i18n._(category.name),
desc: i18n._(category.desc),
}));
}