Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into stable #23

Merged
merged 159 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 151 commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
2c96e36
A few optimizations
raidensakura May 9, 2023
3d5bd91
Pull modmail-dev/modmail#3281
raidensakura May 9, 2023
7fb3f7a
Pull modmail-dev/modmail#3279
raidensakura May 9, 2023
68c44c3
Pull modmail-dev/modmail#3278
raidensakura May 9, 2023
9e9317c
Pull modmail-dev/modmail#3277 & proper indentation
raidensakura May 9, 2023
0e99fe8
Squashed commit of the following:
raidensakura May 9, 2023
53b66c7
Pull modmail-dev/modmail##3271
raidensakura May 9, 2023
c1df103
Squashed commit of the following:
raidensakura May 9, 2023
49f9dfd
Format with black
raidensakura May 9, 2023
b2780fc
Pull modmail-dev/modmail##3233
raidensakura May 9, 2023
c999004
Squashed commit of the following:
raidensakura May 9, 2023
b84bbf2
Update changelog, workflow & remove bandit
raidensakura May 9, 2023
7936080
Pull modmail-dev#3272 + lock dependencies
raidensakura May 9, 2023
ed849d4
Add docs boilerplate + bumppython version
raidensakura May 9, 2023
ad33aac
Dpy bump, add versions for ?about
raidensakura May 9, 2023
29190bd
Format with black
raidensakura May 9, 2023
3f525ec
Update README.md
raidensakura May 9, 2023
fce12b7
Fix permission error when installing plugin
raidensakura May 20, 2023
13ae200
Add new mention_message config, black + ruff
raidensakura May 22, 2023
2cba222
Switch from root to app user for Docker
raidensakura May 23, 2023
884c845
Add support for trailing space in prefix
raidensakura May 28, 2023
a637ef4
Add logviewer as built-in plugin
raidensakura Jun 2, 2023
762c1ff
logviewer plugin enhancements
raidensakura Jun 3, 2023
0e7b5a5
Minor logviewer changes
raidensakura Jun 3, 2023
7e88d20
Update changelog + logviewer pomelo change
raidensakura Jun 3, 2023
8323e8f
add pomelo for logbase
raidensakura Jun 3, 2023
4dd624d
Change logviewer favicon
raidensakura Jun 3, 2023
cc08e56
Refactor loglist object with proper serialization
raidensakura Jun 3, 2023
7a5dc01
Remove favicon to untrack later
raidensakura Jun 4, 2023
566c5dc
fix log entry key error
raidensakura Jun 4, 2023
a0130d6
Replace local favicon with remote avatar
raidensakura Jun 4, 2023
bdc4550
Add markdown header support
raidensakura Jun 4, 2023
afb0319
Switch repo link and branch
raidensakura Jun 4, 2023
173c394
Change more repo links
raidensakura Jun 4, 2023
2a25beb
Handle properly when loglist is the index page
raidensakura Jun 4, 2023
5773577
toggle off internal message checkbox on load
raidensakura Jun 4, 2023
cba479e
Remove trailing slash, fix broken log url on index
raidensakura Jun 4, 2023
e82c954
Fix broken default avatar url
raidensakura Jun 5, 2023
10e6840
Fix pathing issue on displaying log list in index
raidensakura Jun 5, 2023
c3fcb3b
Add placeholder for not logged in user
raidensakura Jun 5, 2023
bd1c6f8
Fix blockquote parsing emote ending
raidensakura Jun 5, 2023
48fcbac
Whoops, remove comment
raidensakura Jun 5, 2023
561e093
Fix blockquote parsing + oauth navbar indicator
raidensakura Jun 5, 2023
50748fd
Update docs
raidensakura Jun 5, 2023
0fdcbfa
config and docs change
raidensakura Jun 5, 2023
7655e86
Update FUNDING.yml
raidensakura Jun 6, 2023
20f2045
Update docs
raidensakura Jun 6, 2023
1ac907e
Update ignores + workflow
raidensakura Jun 6, 2023
36f386b
Tweak loadcheck
raidensakura Jun 6, 2023
a3e1c10
tweak loadcheck (2)
raidensakura Jun 6, 2023
13b0f24
blegh
raidensakura Jun 6, 2023
1b1d046
raidensakura Jun 6, 2023
ca60f0f
Attempt to fix invalid guild_id on test
raidensakura Jun 6, 2023
f2d6915
Docs update
raidensakura Jun 6, 2023
04fe9cc
Terminate process more gracefully
raidensakura Jun 6, 2023
033076c
Update dependencies for Python 3.11
raidensakura Jun 8, 2023
beaa661
Refactor logviewer pomelo changes
raidensakura Jun 8, 2023
d6ec5b0
Minify docker image size
raidensakura Jun 8, 2023
54d9aee
Remove unused files
raidensakura Jun 8, 2023
bfbf291
bump black to fix checks
raidensakura Jun 8, 2023
cafd223
Update dev requirements
raidensakura Jun 9, 2023
34d68bc
Update workflow
raidensakura Jun 9, 2023
ff97b9a
More pomelo changes
raidensakura Jun 9, 2023
18007cd
Replace avatar with local asset
raidensakura Jun 9, 2023
62f9e6b
Fix broken author avatar on `logs` command
raidensakura Jun 9, 2023
0d8157e
Implement pomelo on channel name
raidensakura Jun 9, 2023
baeff97
Format with black
raidensakura Jun 9, 2023
119eb3c
Add pre-commit hook
raidensakura Jun 9, 2023
7fba67e
Update requirements
raidensakura Jun 9, 2023
d8f79df
Overhaul block functionality
raidensakura Jun 11, 2023
cb634df
Add plugin uninstall alias
raidensakura Jun 11, 2023
018b18e
Update python badge
raidensakura Jun 11, 2023
41a878b
Update README.md
raidensakura Jun 11, 2023
216eeeb
Update README.md
raidensakura Jun 11, 2023
8a586c0
Fix block datetime not being timezone aware
raidensakura Jun 12, 2023
534a3d6
Remove cairosvg
raidensakura Jun 12, 2023
321196d
Fix copy paste mistake
raidensakura Jun 13, 2023
9fd425c
Another copy paste issue sigh
raidensakura Jun 13, 2023
e3d1a48
Fix NoneType on parse
raidensakura Jun 13, 2023
6bf8521
Improve block check and add message cooldown
raidensakura Jun 13, 2023
063f739
bump dpy
raidensakura Jun 13, 2023
2a4615c
Update internal dpy version
raidensakura Jun 13, 2023
a823517
Update ?info command for pomelo
raidensakura Jun 15, 2023
6af93d8
Bump version
raidensakura Jun 17, 2023
a43184c
Merge branch 'stable' into develop
raidensakura Jun 17, 2023
b101b25
Fix missing package error
raidensakura Jun 17, 2023
66a6269
Fix index compile error
raidensakura Jun 17, 2023
0707c55
Merge branch 'develop' into temp
raidensakura Jun 17, 2023
bce8dad
Merge pull request #7 from raidensakura/temp
raidensakura Jun 17, 2023
15a84cf
Fix space in filepath failing to load local plugin
raidensakura Jun 27, 2023
5692500
Escape codeblock language in class name
raidensakura Jul 6, 2023
f2804ca
Fix genesis message retrieval failure
raidensakura Jul 9, 2023
a38e6a5
Update docs
raidensakura Jul 13, 2023
73774de
Don't build image on PR
raidensakura Jul 18, 2023
c9a9d00
Blocklist rewrite (#11)
khakers Jul 18, 2023
e7635f1
fix note code
khakers Jul 21, 2023
e1a7af7
Fix failing tests and docker build
raidensakura Jul 23, 2023
3234c93
fix blocklist bugs (#13)
khakers Jul 23, 2023
ed10c02
oops
raidensakura Jul 23, 2023
8de9c38
Fix object is not subscriptable for 3.8
raidensakura Jul 23, 2023
b2c083f
Pull 2 changes from upstream (#14)
raidensakura Jul 23, 2023
b1cd3cd
Format with black
raidensakura Jul 23, 2023
9bf357d
More blocklist fixes (#15)
khakers Jul 25, 2023
cf4e377
Add index for channel_id
khakers Jul 25, 2023
4cb5b5a
Update CHANGELOG.md
khakers Jul 28, 2023
9a9afb4
Remove CairoSVG dependencies from Dockerfile
khakers Jul 28, 2023
c6d3339
Improve is_image detection to actually detect images (excluding video…
khakers Aug 3, 2023
8f57bad
Fix logviewer positional arg error
raidensakura Aug 12, 2023
86400a0
Merge branch 'develop' of https://github.com/raidensakura/modmail int…
raidensakura Aug 12, 2023
2e9e07b
partially reverts 2f762025 which added lottie sticker support and upd…
khakers Aug 18, 2023
0e73de8
Synchronize thread NSFW status and title with the database (#18)
khakers Aug 18, 2023
c9d0dbe
Refactor docker workflow to multiplatform build (#21)
khakers Dec 20, 2023
f19f08e
Update funding
raidensakura Dec 22, 2023
fa8456e
Remove internal logviewer plugin
raidensakura Dec 22, 2023
2df3b01
Add .gitignore for local plugin
raidensakura Dec 22, 2023
4c89469
Migrate to poetry
raidensakura Dec 22, 2023
306058a
Update workflow for poetry
raidensakura Dec 22, 2023
2707486
Update workflow
raidensakura Dec 22, 2023
028c1d8
Oops, forgot to install deps
raidensakura Dec 22, 2023
7a8de1f
Update launch command
raidensakura Dec 22, 2023
3360848
Attempt to solve image not building arm64
raidensakura Dec 22, 2023
d20c2fa
Add missing libffi
raidensakura Dec 22, 2023
357d5cc
Refactor Dockerfile
raidensakura Dec 22, 2023
1bdcf2e
Resolve deprecated pkg_resources warning
raidensakura Dec 22, 2023
ea491e6
Update changelog
raidensakura Dec 22, 2023
a93271c
Bump workflow versions
raidensakura Dec 22, 2023
b8d6f90
oops
raidensakura Dec 23, 2023
5bf4870
Add [speed] extra for dpy
raidensakura Dec 23, 2023
0e04349
Bump dpy, don't exit when dpy version mismatch
raidensakura Dec 23, 2023
1e95eb1
Fix sticker replies not sending
raidensakura Dec 23, 2023
44442c5
Update changelog
raidensakura Dec 23, 2023
f0815a6
Improved join/leave message for multiple servers.
raidensakura Dec 23, 2023
2d995b7
Fix code scanning alert #5
raidensakura Dec 23, 2023
49d26d4
Fixed compat with MissingRequiredArgument requiring additional param
raidensakura Dec 23, 2023
a8608fe
Fix plugin update bug on broken plugin
raidensakura Dec 23, 2023
ee4bab7
Update CHANGELOG.md
raidensakura Dec 23, 2023
5548380
Fix rate limit issue on raw reaction add/remove events
raidensakura Dec 23, 2023
bb8a3a8
Remove Heroku Reference from Debug Command
raidensakura Dec 23, 2023
7b07c7a
Update CHANGELOG.md
raidensakura Dec 23, 2023
8b86dd7
Remove unused files
raidensakura Dec 23, 2023
a95b6bd
Update pip
raidensakura Dec 24, 2023
5999f52
Bump aiohttp and use [speedups]
raidensakura Dec 24, 2023
7d2a78e
Update .dockerignore
raidensakura Dec 24, 2023
d0df190
Rename project
raidensakura Dec 24, 2023
01be728
Add shell script for pm2
raidensakura Dec 24, 2023
131df98
Update docs
raidensakura Dec 24, 2023
5496f52
Update env example
raidensakura Dec 25, 2023
c7d8fec
Remove app.json
raidensakura Dec 25, 2023
cb86faf
Update dependencies
raidensakura Dec 25, 2023
b23f5ee
Update readme
raidensakura Dec 25, 2023
b1e4e6c
Add config to manage how long logs are stored (#3257)
raidensakura Dec 26, 2023
cae3baf
Add presence intent into .env.example
raidensakura Dec 26, 2023
6c042d4
Formating
raidensakura Dec 26, 2023
79c8c67
Fix missing guild icon url
raidensakura Dec 26, 2023
36578bf
Revert gyazo image embedding
raidensakura Dec 26, 2023
b14c562
Fix overly permissive regex
raidensakura Dec 27, 2023
55a0e24
Specify fork on metadata
raidensakura Dec 27, 2023
f9587e1
Update changelog
raidensakura Dec 27, 2023
c4959cb
Bump version
raidensakura Dec 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,27 @@ dmypy.json
package-lock.json
node_modules/

# Modmail
# Unused Modmail files
config.json
plugins/
!plugins/registry.json
!plugins/@local/
temp/
test.py

# Other stuff
# Unused repository files
.env.example
.gitignore
.dockerignore
.github/
.pre-commit-config.yaml
app.json
Procfile
pyproject.toml
*.md
.*.json
Dockerfile
docker-compose.yml
requirements.txt
LICENSE
PRIVACY.md

Expand Down
47 changes: 43 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# Your Discord bot token
TOKEN=MyBotToken
LOG_URL=https://logviewername.herokuapp.com/
GUILD_ID=1234567890
OWNERS=Owner1ID,Owner2ID,Owner3ID
CONNECTION_URI=mongodb+srv://mongodburi

# ID of your Discord server
GUILD_ID=123456

# ID of the server the thread channels will be created in
# MODMAIL_GUILD_ID=123456

# Discord ID of the owners
OWNERS=123456,123456

# Connection URI for your mongodb
CONNECTION_URI=mongod+srv://mongo.net

# The url of logviewer for viewing self-hosted logs
# LOG_URL=https://logviewername.domain.com/

# The path to your log viewer extending from your `LOG_URL`, defaults to "/logs"
# LOG_URL_PREFIX=/logs

# A github personal access token with the repo scope to access private repository
# GITHUB_TOKEN=abcdef

# If set to true, only plugins that are in the registry can be loaded
# REGISTRY_PLUGINS_ONLY=false

# Client ID for your application, used by logviewer`
# OAUTH2_CLIENT_ID=12345

# Client Secret for your application, used by logviewer
# OAUTH2_CLIENT_SECRET=abcdef

# The redirect URL for logviewer OAuth. You must also add this URL in your application's Redirects section
# OAUTH2_REDIRECT_URI=https://logviewername.herokuapp.com/callback

# The host address logviewer will bind itself to. Defaults to 0.0.0.0
# HOST=0.0.0.0

# The port logviewer plugin will listen to. Defaults to 8000
# PORT=8000

# The number of logs to display per page on logviewer. Defaults to 25
# LOGVIEWER_PAGINATION=25
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ko_fi: raidensakura
github: raidensakura
22 changes: 14 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:
- 'develop'
tags:
- 'v*'
pull_request:
branches:
- 'develop'

env:
REGISTRY: ghcr.io
Expand All @@ -25,18 +22,24 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3

uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -51,9 +54,12 @@ jobs:
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}

- name: Build and push Docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
python-version: ["3.11"]
name: Python ${{ matrix.python-version }} on ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand Down
25 changes: 12 additions & 13 deletions .github/workflows/load-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,39 @@ jobs:

name: Load Modmail - Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache venv
id: cache-venv
- uses: Gr1N/setup-poetry@v8
- name: Cache poetry
id: cache-poetry
uses: actions/cache@v3
with:
path: .venv
key: ${{ matrix.python-version }}-${{ hashFiles('Pipfile') }}-${{ secrets.CACHE_V }}
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}

- name: Maybe make pipenv
- name: Maybe install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
pip install pipenv && PIPENV_VENV_IN_PROJECT=1
pipenv install --deploy
run: poetry install --no-root

- name: Run script loadcheck.py
run: |
pipenv run python .github/workflows/scripts/loadcheck.py
poetry run python .github/workflows/scripts/loadcheck.py
env:
TOKEN: ${{ secrets.DISCORD_TEST_BOT }}
CONNECTION_URI: ${{ secrets.CONNECTION_URI }}
LOG_URL: https://domain.example
GUILD_ID: "616969119685935162"
MODMAIL_GUILD_ID: "1100011945207271494"
OWNERS: "243316261264556032,505386507440488458"
DATA_COLLECTION: off
LOG_LEVEL: DEBUG

- name: Save Modmail output as Artifact
if: always() # still run if prev step failed
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "Modmail log - Python ${{ matrix.python-version }}"
path: modmail.log
2 changes: 1 addition & 1 deletion .github/workflows/scripts/loadcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

file = open("modmail.log", "w")
proc = subprocess.Popen(
"pipenv run bot",
"poetry run python bot.py",
stdout=file,
stderr=subprocess.STDOUT,
shell=True,
Expand Down
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,42 @@ however, insignificant breaking changes do not guarantee a major version bump, s

# [UNRELEASED]

### Breaking
- Completely rewritten blocklist system. Blocklisting now runs off its own mongoDB collection. This once again introduces backwards incompatible schema changes, so a manual migration is required. You may upgrade from both v4.0 and v4.1 using the `[p]migrate blocklist` command. This removes any need to perform the previous migration steps in v4.1.0, you may upgrade directly to this version. After running the command, blocklist functionality will return and legacy config based blocks will have been deleted. You should always back up your config before migration.
- Migrated package manager from pipenv to Poetry. Dockerfile and GitHub Actions are also now set up to install using Poetry.

### Deprecated
- Legacy blocklist properties are deprecated and no longer function. They now log a warning when used and provide no functionality. They have been replaced with methods in blocklist.py

### Added
- Added `content_type` to attachments stored in the database.
- Introduced multiplatform Docker workflow for GitHub Actions.
- Improved join/leave message for multiple servers.

### Changed
- Changing a threads title or NSFW status immediately updates the status in the database.

### Removed
- The logviewer plugin is no longer included locally.
- Removed lottie sticker support and its dependencies due to unnecessary bulk.

### Fixed
- Persistent notes have been fixed after the previous discord.py update.
- `is_image` now is true only if the image is actually an image.
- Resolved deprecated pkg_resources warning in certain Python environment.
- Improved genesis message retrieval checks where it would fail under certain circumstances.
- Fixed failure on installing local plugins when plugin path contains whitespace.
- Fixed sticker replies not being sent in a Modmail thread.
- Fixed plugin update command where it would fail to remove the plugin when the plugin is invalid.
- Fixed MissingRequiredArgument requiring additional param.
- Fixed rate limit issue on raw reaction add/remove events.

### Internal
- Add `update_title` and `update_nsfw` methods to `ApiClient` to update thread title and nsfw status in the database.
- `thread.set_title` now requires `channel_id` to be passed as keyword arguments.
- New `thread.set_nsfw_status` method to set nsfw status of a thread.
- Updated discord.py to 2.3.2, with [speed] extra.

# v4.1.0

### Breaking
Expand Down Expand Up @@ -46,6 +82,9 @@ however, insignificant breaking changes do not guarantee a major version bump, s
- Fixed blocked roles improperly saving in `blocked_users` config.
- Fixed `?block` command improperly parsing reason as timestamp.

### Internal
- `ConfigManager.get` no longer accepts two positional arguments: the `convert` argument is now keyword-only.

# v4.0.2

### Breaking
Expand Down
40 changes: 25 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
FROM python:3.11-alpine as base

RUN apk update && apk add git \
# cairosvg dependencies
cairo-dev cairo cairo-tools \
# pillow dependencies
jpeg-dev zlib-dev
jpeg-dev zlib-dev && \
pip install --upgrade pip && \
adduser -D -h /home/modmail -g 'Modmail' modmail

FROM base as python-deps
WORKDIR /home/modmail

RUN apk add --virtual build-deps build-base gcc libffi-dev
COPY requirements.txt /
RUN pip install --prefix=/inst -U -r /requirements.txt
FROM base as builder

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache

RUN apk add build-base libffi-dev && \
pip install -U poetry

COPY --chown=modmail:modmail poetry.lock pyproject.toml /home/modmail/

RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root

FROM base as runtime

ENV USING_DOCKER yes
COPY --from=python-deps /inst /usr/local
ENV VIRTUAL_ENV=/home/modmail/.venv \
PATH="/home/modmail/.venv/bin:$PATH" \
USING_DOCKER=yes

COPY . /modmail
WORKDIR /modmail
COPY --from=builder --chown=modmail:modmail ${VIRTUAL_ENV} ${VIRTUAL_ENV}

CMD ["python", "bot.py"]
COPY --chown=modmail:modmail . .

USER modmail

RUN adduser --disabled-password --gecos '' app && \
chown -R app /modmail
USER app
CMD ["python", "bot.py"]
35 changes: 0 additions & 35 deletions Pipfile

This file was deleted.

Loading
Loading