Skip to content

Commit

Permalink
Merge pull request #418 from zaanposni/release/v1.14
Browse files Browse the repository at this point in the history
Version 2
  • Loading branch information
zaanposni authored Oct 15, 2021
2 parents 50fd48f + 5963302 commit bf325c9
Show file tree
Hide file tree
Showing 548 changed files with 23,505 additions and 10,045 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: DockerPublish

on:
push:
branches:
- "master"

jobs:
DockerPublish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Determine version
run: |
VERSION=$(cat nginx/static/version.json | jq -r '.version')$($(cat nginx/static/version.json | jq -r '.pre_release') && echo "a" || :)
echo "I found version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build backend
run: |
cd backend
docker build -t ghcr.io/${{ github.repository_owner }}/masz_backend:latest -t ghcr.io/${{ github.repository_owner }}/masz_backend:${{ env.VERSION }} .
- name: Build frontend
run: |
cd nginx
docker build -t ghcr.io/${{ github.repository_owner }}/masz_nginx:latest -t ghcr.io/${{ github.repository_owner }}/masz_nginx:${{ env.VERSION }} .
- name: Push images
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u zaanposni --password-stdin
docker push ghcr.io/${{ github.repository_owner }}/masz_backend:latest
docker push ghcr.io/${{ github.repository_owner }}/masz_backend:${{ env.VERSION }}
docker push ghcr.io/${{ github.repository_owner }}/masz_nginx:latest
docker push ghcr.io/${{ github.repository_owner }}/masz_nginx:${{ env.VERSION }}
- name: Calculate image sizes
run: |
SIZE_BACKEND=$(docker image inspect ghcr.io/${{ github.repository_owner }}/masz_backend:latest | jq -r '.[0].Size' | numfmt --to=si)
SIZE_NGINX=$(docker image inspect ghcr.io/${{ github.repository_owner }}/masz_nginx:latest | jq -r '.[0].Size' | numfmt --to=si)
echo "I found backend size: $SIZE_BACKEND"
echo "I found nginx size: $SIZE_NGINX"
echo "SIZE_BACKEND=$SIZE_BACKEND" >> $GITHUB_ENV
echo "SIZE_NGINX=$SIZE_NGINX" >> $GITHUB_ENV
- name: Send discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "🚀 Published `masz_backend:${{ env.VERSION }}` and `masz_backend:latest` with `${{ env.SIZE_BACKEND }}`.\n🚀 Published `masz_nginx:${{ env.VERSION }}` and `masz_nginx:latest` with `${{ env.SIZE_NGINX }}`."
28 changes: 0 additions & 28 deletions .github/workflows/pythonlint.yml

This file was deleted.

21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ Feel free to comment existing issues/discussions or create a new one if you have
- Discord: `zaanposni#9295`
- [mail me](mailto:[email protected])

## Translations

Contributions to add new translations/languages or correcting existing ones are welcome!<br/>
Tranlating in MASZ is fairly simple and done via i18n (on the website).<br/>
The Backend uses custom generated code but this does not concerns you as a translator.<br/>

There are json files that include translation nodes and look like this:<br/>
![](/docs/translation_example.png)

As you can see there is a `description` that tells you what this translation node is about.<br/>
To add your translation - lets say for french - simply add `'fr': 'Sourdine'`.

Backend translation (used for notifications) are located in the `./translations` directory while translations for the website are located in every subfolder of `./nginx/MASZ/src/app`.<br/>
To quickly find your translation node either search for a known english translation or the existing translation you want to adjust.<br/>
You can use tools like `Visual Studio Code` to search through the entire codebase.

## How to publish my changes

You have to follow the process of `branch -> commit -> pull request`.<br/>
If you are not sure what that means, check out [this tutorial](https://github.com/firstcontributions/first-contributions). <br/>

## Issues and Discussions

Feel free to open issues and discussions of any type. No matter if support, questions or feature requests!
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Yannick
Copyright (c) 2020-2021 zaanposni

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
35 changes: 21 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
**Infractions and managed (temporary) punishments** - to moderate your server<br/>
**Userscan** - quickly spot relations between users with a included visualization<br/>
**Quicksearch** - to reliably search for any infractions or notes a user has<br/>
**Localization** - timezones and languages are fully customizable<br/>
**Automoderation** - to give trolls no chance<br/>
**Ban appeals and webhook notifications** - to moderate your server transparently<br/>
**A website and a discord bot** - to use MASZ<br/>
Expand Down Expand Up @@ -50,11 +51,11 @@ If you have any questions, feel free to contact me. <br/>

- Create a discord application at https://discord.com/developers/applications
- Set redirect urls on your discord application [as defined](https://github.com/zaanposni/discord-masz#discord-oauth).
- Enable **Server Members Intent** in your bot settings.
- Execute the `setup.py` script to configure your app and `start.sh` (or `start.ps1` on windows) to start it.
- Enable **Server Members Intent** in your bot settings.
- Execute the `setup.py` script to configure your app and `docker-compose up -d` to start it.
- App will be hosted on `127.0.0.1:5565`, if you are hosting the app on a domain, redirect your reverse proxy to this local port!

## Requirements
## Requirements

- [docker](https://docs.docker.com/engine/install/ubuntu/) & [docker-compose](https://docs.docker.com/compose/) (`docker-compose -v` > 1.25)
- [python3](https://www.python.org/) for setup
Expand All @@ -81,7 +82,7 @@ Enable **Server Members Intent** in your bot settings.

- Download this repository `git clone https://github.com/zaanposni/discord-masz` ([zip link](https://codeload.github.com/zaanposni/discord-masz/zip/master))
- Use `python3 setup.py` (`python setup.py` on windows) to setup the configuration.
- Start the application with `./start.sh` (`start.ps1` on windows).
- Start the application with `docker-compose up -d`.
- App will be hosted on `127.0.0.1:5565`, if you are hosting the app on a domain, redirect your reverse proxy to this local port!

## First steps
Expand Down Expand Up @@ -127,9 +128,10 @@ If you do not enable this mode, moderators can create any modcase.
## 🛰️ Update

To install a new update of MASZ just use:
```
git pull
./start.sh

```bash
docker-compose pull
docker-compose up -d
```

## 🗃️ Backup
Expand All @@ -141,8 +143,19 @@ There are backup example scripts in the `scripts` directory to backup uploaded f
As a siteadmin you can create a token to authenticate yourself while making API requests.<br/>
You can also use my [python library](https://github.com/zaanposni/masz-api-wrapper) to integrate the MASZ API into your project.

# 🤝 Contribute

Contributions are welcome. <br/>
You can find our contributions guidelines [here](CONTRIBUTING.md).<br/>
If you are new to open source, checkout [this tutorial](https://github.com/firstcontributions/first-contributions). <br/>
Feel free to get in touch with me via our support server https://discord.gg/5zjpzw6h3S or via friend request on discord: **zaanposni#9295**.

# Development

```bash
docker-compose -f docker-compose-dev.yml up --force-recreate --build
```

## Config

- Using the `setup.py` script. Choose "local" deployment for best development experience.
Expand All @@ -153,10 +166,4 @@ If you are using a local deployed backend you have to define `https://127.0.0.1:

## Angular

If you want to develop on the angular frontend, it would be best if you deploy the backend via `./start.sh` and enable cors in the `Startup.cs` then use the `config.ts` to redirect all requests to `127.0.0.1:5565`.

# 🤝 Contribute

Contributions are welcome. <br/>
If you are new to open source, checkout [this tutorial](https://github.com/firstcontributions/first-contributions). <br/>
Feel free to get in touch with me via our support server https://discord.gg/5zjpzw6h3S or via friend request on discord: **zaanposni#9295**.
If you want to develop on the angular frontend, set the env var `ENABLE_CORS=true` for the backend container.
40 changes: 0 additions & 40 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,8 @@
FROM python:3 as init

ARG MYSQL_DATABASE
ENV MYSQL_DATABASE $MYSQL_DATABASE

ARG MYSQL_USER
ENV MYSQL_USER $MYSQL_USER

ARG MYSQL_PASSWORD
ENV MYSQL_PASSWORD $MYSQL_PASSWORD

ARG MYSQL_PORT
ENV MYSQL_PORT $MYSQL_PORT

ARG MYSQL_HOST
ENV MYSQL_HOST $MYSQL_HOST

ARG DISCORD_BOT_TOKEN
ENV DISCORD_BOT_TOKEN $DISCORD_BOT_TOKEN

ARG DISCORD_OAUTH_CLIENT_ID
ENV DISCORD_OAUTH_CLIENT_ID $DISCORD_OAUTH_CLIENT_ID

ARG DISCORD_OAUTH_CLIENT_SECRET
ENV DISCORD_OAUTH_CLIENT_SECRET $DISCORD_OAUTH_CLIENT_SECRET

ARG DISCORD_SITE_ADMINS
ENV DISCORD_SITE_ADMINS $DISCORD_SITE_ADMINS

ARG META_SERVICE_BASE_URL
ENV META_SERVICE_BASE_URL $META_SERVICE_BASE_URL

WORKDIR /app

COPY setup_app.py .
COPY ./masz/appsettings.json ./masz/

RUN python3 setup_app.py

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app

# Copy everything and build
COPY ./ ./
COPY --from=init /app/masz/appsettings.json /app/masz/
RUN dotnet publish -c Release -o ./bin

# Build runtime image
Expand Down
22 changes: 0 additions & 22 deletions backend/bootstrap.sh

This file was deleted.

22 changes: 22 additions & 0 deletions backend/masz/AutoModerations/AttachmentCheck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using DSharpPlus;
using DSharpPlus.Entities;
using masz.Models;

namespace masz.AutoModerations
{
public static class AttachmentCheck
{
public static bool Check(DiscordMessage message, AutoModerationConfig config, DiscordClient client)
{
if (config.Limit == null)
{
return false;
}
if (message.Attachments == null)
{
return false;
}
return message.Attachments.Count > config.Limit;
}
}
}
Loading

0 comments on commit bf325c9

Please sign in to comment.