Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8976273410 |
No files matched your search
@@ -1,147 +0,0 @@
|
|||||||
name: Bug Report
|
|
||||||
description: Report a bug in Stoat — please fill out every required field to help us triage quickly.
|
|
||||||
title: "[Bug]: "
|
|
||||||
labels:
|
|
||||||
- bug
|
|
||||||
- unconfirmed
|
|
||||||
|
|
||||||
body:
|
|
||||||
# ── Thank you section ────────────────────────────────────────────────────────
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
**Thank you for taking the time to report a bug for Stoat!**
|
|
||||||
|
|
||||||
Please follow the instructions below and provide as much detail as possible to help us understand and reproduce the issue.
|
|
||||||
|
|
||||||
# ── Pre-flight checks ────────────────────────────────────────────────────────
|
|
||||||
- type: checkboxes
|
|
||||||
id: preflight
|
|
||||||
attributes:
|
|
||||||
label: Pre-flight checklist
|
|
||||||
description: Please confirm all of the following before submitting.
|
|
||||||
options:
|
|
||||||
- label: I am on the latest available version of Stoat.
|
|
||||||
required: true
|
|
||||||
- label: I searched existing issues and did not find a duplicate.
|
|
||||||
required: true
|
|
||||||
- label: This is a bug report, not a support question or feature request.
|
|
||||||
required: true
|
|
||||||
|
|
||||||
# ── Bug description ──────────────────────────────────────────────────────────
|
|
||||||
- type: textarea
|
|
||||||
id: description
|
|
||||||
attributes:
|
|
||||||
label: Bug description
|
|
||||||
description: >
|
|
||||||
What happened? What did you expect to happen instead?
|
|
||||||
Keep this brief — detailed steps go in the next field.
|
|
||||||
placeholder: "Example: When I open a DM thread, new messages from the other person do not appear unless I reload the page."
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
# ── Steps to reproduce ───────────────────────────────────────────────────────
|
|
||||||
- type: textarea
|
|
||||||
id: steps
|
|
||||||
attributes:
|
|
||||||
label: Steps to reproduce
|
|
||||||
description: >
|
|
||||||
Provide a numbered list of every step needed to trigger the bug.
|
|
||||||
The clearer this is, the faster we can fix it.
|
|
||||||
placeholder: |
|
|
||||||
1. Log in to Stoat on the web client.
|
|
||||||
2. Open a direct message conversation.
|
|
||||||
3. Ask the other person to send a message.
|
|
||||||
4. Observe that the message does not appear without reloading.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
# ── Expected behavior ────────────────────────────────────────────────────────
|
|
||||||
- type: textarea
|
|
||||||
id: expected
|
|
||||||
attributes:
|
|
||||||
label: Expected behavior
|
|
||||||
description: What should have happened?
|
|
||||||
placeholder: "New messages should appear in real time without a page reload."
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
# ── Client / platform ────────────────────────────────────────────────────────
|
|
||||||
- type: dropdown
|
|
||||||
id: platform
|
|
||||||
attributes:
|
|
||||||
label: Client / platform
|
|
||||||
description: Which Stoat client are you using?
|
|
||||||
options:
|
|
||||||
- Web (browser)
|
|
||||||
- Stoat for Desktop
|
|
||||||
- Android
|
|
||||||
- iOS
|
|
||||||
- Self-hosted server
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
# ── Client version ───────────────────────────────────────────────────────────
|
|
||||||
- type: input
|
|
||||||
id: version
|
|
||||||
attributes:
|
|
||||||
label: Client version
|
|
||||||
description: >
|
|
||||||
Find this in **Settings**. For the web client, include the build
|
|
||||||
number shown in the footer or About page.
|
|
||||||
placeholder: "e.g. Stoat for Desktop 1.3.0 or 0.2.1 (2025-10-10)"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
# ── OS / browser details ─────────────────────────────────────────────────────
|
|
||||||
- type: input
|
|
||||||
id: os
|
|
||||||
attributes:
|
|
||||||
label: OS / browser details
|
|
||||||
description: Your operating system and, for web bugs, your browser and its version.
|
|
||||||
placeholder: "e.g. Windows 11, Chrome 121 or macOS 14.3, Stoat for Desktop 1.3.0 or Android 14"
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
# ── Reproducibility ──────────────────────────────────────────────────────────
|
|
||||||
- type: dropdown
|
|
||||||
id: reproducibility
|
|
||||||
attributes:
|
|
||||||
label: Reproducibility
|
|
||||||
description: How consistently does this bug occur?
|
|
||||||
options:
|
|
||||||
- Always
|
|
||||||
- Usually
|
|
||||||
- Rarely
|
|
||||||
- Only once
|
|
||||||
- Unknown
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
# ── Screenshots or video ─────────────────────────────────────────────────────
|
|
||||||
- type: textarea
|
|
||||||
id: screenshots
|
|
||||||
attributes:
|
|
||||||
label: Screenshots or video
|
|
||||||
description: Paste images or drag-and-drop a screen recording here. GitHub accepts common image and video formats.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
|
|
||||||
# ── Additional context ───────────────────────────────────────────────────────
|
|
||||||
- type: textarea
|
|
||||||
id: additional
|
|
||||||
attributes:
|
|
||||||
label: Additional context
|
|
||||||
description: >
|
|
||||||
Anything else that might help: workarounds you found, links to related issues,
|
|
||||||
self-hosted configuration details (Redis, MongoDB, LiveKit, SMTP), network environment, etc.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
|
|
||||||
# ── Closing note ─────────────────────────────────────────────────────────────
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
---
|
|
||||||
A maintainer will review your report. Please watch for follow-up questions — issues
|
|
||||||
that go unanswered are harder to resolve and may be closed after 30 days of inactivity.
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<!-- Describe your changes -->
|
|
||||||
|
|
||||||
Fixes # (issue)
|
|
||||||
|
|
||||||
## How was this PR tested?
|
|
||||||
|
|
||||||
<!-- What did you do to test your changes? -->
|
|
||||||
|
|
||||||
- [ ] Test A
|
|
||||||
- [ ] Test B
|
|
||||||
|
|
||||||
## Checklist:
|
|
||||||
|
|
||||||
- [ ] I have carefully read [the contributing guidelines](https://developers.stoat.chat/developing/contrib/)
|
|
||||||
- [ ] I have performed a self-review of my own code
|
|
||||||
- [ ] I have made corresponding changes to the documentation if applicable
|
|
||||||
- [ ] I have no unrelated changes in the PR
|
|
||||||
- [ ] I have confirmed that any new dependencies are strictly necessary
|
|
||||||
- [ ] I have written tests for new code (if applicable)
|
|
||||||
- [ ] I have followed naming conventions/patterns in the surrounding code
|
|
||||||
|
|
||||||
## Please declare, if any, LLM usage involved in creating this PR
|
|
||||||
|
|
||||||
...
|
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
# DO NOT EDIT DIRECTLY IN REPOSITORY
|
|
||||||
# Managed in Terraform templates
|
|
||||||
|
|
||||||
name: Git Town
|
name: Git Town
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -11,7 +8,7 @@ jobs:
|
|||||||
name: Display the branch stack
|
name: Display the branch stack
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-slim
|
||||||
|
|
||||||
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'release-please--') }}
|
if: ${{ !startsWith(github.head_ref, 'release-please--') }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -20,4 +17,3 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||||
- uses: stoatchat/action-git-town@4bc5c942e4603bffa0806b51d5fe5f0bc5deb0ac
|
- uses: stoatchat/action-git-town@4bc5c942e4603bffa0806b51d5fe5f0bc5deb0ac
|
||||||
continue-on-error: true
|
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
# DO NOT EDIT DIRECTLY IN REPOSITORY
|
|
||||||
# Managed in Terraform templates
|
|
||||||
|
|
||||||
name: Release Webhook
|
name: Release Webhook
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
# DO NOT EDIT DIRECTLY IN REPOSITORY
|
|
||||||
# Managed in Terraform templates
|
|
||||||
|
|
||||||
name: "Lint PR"
|
name: "Lint PR"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -18,6 +15,6 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
steps:
|
steps:
|
||||||
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
|
- uses: amannn/action-semantic-pull-request@v6
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -16,13 +16,4 @@ idiomatic_version_file_enable_tools = ["rust"]
|
|||||||
[tasks.start]
|
[tasks.start]
|
||||||
description = "Run all services"
|
description = "Run all services"
|
||||||
depends = ["docker:start", "build"]
|
depends = ["docker:start", "build"]
|
||||||
wait_for = ["docker:start", "build"]
|
|
||||||
run = [{ task = "service:*" }]
|
run = [{ task = "service:*" }]
|
||||||
|
|
||||||
[env]
|
|
||||||
BUILDER = "cargo"
|
|
||||||
DOCKER_NETWORK_NAME = "stoatchat_default"
|
|
||||||
DATABASE_PORT = "27017"
|
|
||||||
RABBIT_PORT = "5672"
|
|
||||||
REDIS_PORT = "6379"
|
|
||||||
_.file = { path = ".env", tools = true }
|
|
||||||
+1
-1
@@ -2,4 +2,4 @@
|
|||||||
#MISE description="Build project"
|
#MISE description="Build project"
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
${BUILDER} build "$@"
|
cargo build "$@"
|
||||||
@@ -3,11 +3,3 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
docker run \
|
|
||||||
--network=${DOCKER_NETWORK_NAME} \
|
|
||||||
--name wait \
|
|
||||||
--rm dokku/wait -c \
|
|
||||||
rabbit:${RABBIT_PORT},\
|
|
||||||
database:${DATABASE_PORT},\
|
|
||||||
redis:${REDIS_PORT}
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "0.13.5"
|
".": "0.11.3"
|
||||||
}
|
}
|
||||||
-124
@@ -1,129 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [0.13.5](https://github.com/stoatchat/stoatchat/compare/v0.13.4...v0.13.5) (2026-05-17)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* dont panic on hash missing when deleting files ([#755](https://github.com/stoatchat/stoatchat/issues/755)) ([c902077](https://github.com/stoatchat/stoatchat/commit/c902077cf51076fee11712eb732dc8a8f786fc4b))
|
|
||||||
|
|
||||||
## [0.13.4](https://github.com/stoatchat/stoatchat/compare/v0.13.3...v0.13.4) (2026-05-16)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* add TLS feature to livekit-api crate ([#753](https://github.com/stoatchat/stoatchat/issues/753)) ([6cfee1f](https://github.com/stoatchat/stoatchat/commit/6cfee1f601c1e084df7c8f1e7a5e8a560d1dd514))
|
|
||||||
|
|
||||||
## [0.13.3](https://github.com/stoatchat/stoatchat/compare/v0.13.2...v0.13.3) (2026-05-15)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* don't automatically set up rabbitmq in delta ([#749](https://github.com/stoatchat/stoatchat/issues/749)) ([7647cfc](https://github.com/stoatchat/stoatchat/commit/7647cfc8d93aba99f5faef13eb3d970097540d76))
|
|
||||||
* don't declare queues which seem to cause the backend to crash in prod ([7647cfc](https://github.com/stoatchat/stoatchat/commit/7647cfc8d93aba99f5faef13eb3d970097540d76))
|
|
||||||
|
|
||||||
## [0.13.2](https://github.com/stoatchat/stoatchat/compare/v0.13.1...v0.13.2) (2026-05-11)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* update default exchange to `revolt.default` ([#746](https://github.com/stoatchat/stoatchat/issues/746)) ([fcb8091](https://github.com/stoatchat/stoatchat/commit/fcb8091cd7a00d7f26c798daa33aae4b923b2a8b))
|
|
||||||
|
|
||||||
## [0.13.1](https://github.com/stoatchat/stoatchat/compare/v0.13.0...v0.13.1) (2026-05-10)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* amqprs startup bug ([#744](https://github.com/stoatchat/stoatchat/issues/744)) ([1100eaf](https://github.com/stoatchat/stoatchat/commit/1100eaf46f849f2509ae01ac497556ca33bde778))
|
|
||||||
|
|
||||||
## [0.13.0](https://github.com/stoatchat/stoatchat/compare/v0.12.1...v0.13.0) (2026-05-08)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add embed support for YouTube Shorts ([#734](https://github.com/stoatchat/stoatchat/issues/734)) ([d46c7f7](https://github.com/stoatchat/stoatchat/commit/d46c7f7f3c04524c0639c3e0a122626f8e0b3bf7))
|
|
||||||
* add emoji rename endpoint ([#714](https://github.com/stoatchat/stoatchat/issues/714)) ([23ad135](https://github.com/stoatchat/stoatchat/commit/23ad1359834bb7d07a460b8678d6a6ebffc73eb0))
|
|
||||||
* add legal links to root payload ([#733](https://github.com/stoatchat/stoatchat/issues/733)) ([21d8201](https://github.com/stoatchat/stoatchat/commit/21d82018cf84ab0fdd10613d254b9562aea8eea3))
|
|
||||||
* add role icon support ([#724](https://github.com/stoatchat/stoatchat/issues/724)) ([841985d](https://github.com/stoatchat/stoatchat/commit/841985d3b994df1c6eefab2fc7ecbd77ab22c493))
|
|
||||||
* Add webhook endpoints for editing and deleting messages ([#682](https://github.com/stoatchat/stoatchat/issues/682)) ([6f3441c](https://github.com/stoatchat/stoatchat/commit/6f3441cf4acac2a8e6e1bf07a279a153b80f7956))
|
|
||||||
* automatically sanitise usernames on create/update ([#689](https://github.com/stoatchat/stoatchat/issues/689)) ([e937697](https://github.com/stoatchat/stoatchat/commit/e93769786c7669485a659ee471630740d3cea702))
|
|
||||||
* blacklist private ip ranges and add january domain blocklist ([#731](https://github.com/stoatchat/stoatchat/issues/731)) ([6b41db9](https://github.com/stoatchat/stoatchat/commit/6b41db984bb491b2e58324309cc70d8c14e0b814))
|
|
||||||
* Rewrite acks ([#741](https://github.com/stoatchat/stoatchat/issues/741)) ([ab5bd47](https://github.com/stoatchat/stoatchat/commit/ab5bd47a39ee889de0b5ae6e7b560620853daead))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* add new_user_hours to configuration limits ([#729](https://github.com/stoatchat/stoatchat/issues/729)) ([279f5d5](https://github.com/stoatchat/stoatchat/commit/279f5d5fd7af2df55902c706859ec07f569cdb1e))
|
|
||||||
* add reconnection policy to Redis subscriber to prevent ghost state ([#708](https://github.com/stoatchat/stoatchat/issues/708)) ([057f2bb](https://github.com/stoatchat/stoatchat/commit/057f2bb8b359f8b942741a30ff54eeb8fbe3e0b1))
|
|
||||||
* docker compose file had personal url in it ([#742](https://github.com/stoatchat/stoatchat/issues/742)) ([0719985](https://github.com/stoatchat/stoatchat/commit/0719985ac5636590f91e6f9ec4b68f3eded70c13))
|
|
||||||
* don't strip ICC from exif ([#735](https://github.com/stoatchat/stoatchat/issues/735)) ([d76a711](https://github.com/stoatchat/stoatchat/commit/d76a71141f3e508f6308ba52fa28eaeb56fb3438))
|
|
||||||
* dont send notification in fcm ([#721](https://github.com/stoatchat/stoatchat/issues/721)) ([89171e9](https://github.com/stoatchat/stoatchat/commit/89171e9bd0f15711157e78c6eec0fe7b480de93a))
|
|
||||||
* encode filenames in redirects ([#737](https://github.com/stoatchat/stoatchat/issues/737)) ([9fd7128](https://github.com/stoatchat/stoatchat/commit/9fd7128f800badbd184baf943d4f799e601201e4))
|
|
||||||
* january ip redirects & domain resolver ([#738](https://github.com/stoatchat/stoatchat/issues/738)) ([356491e](https://github.com/stoatchat/stoatchat/commit/356491e934b274f9e895df883dd63ef0b3123510))
|
|
||||||
* update message length validation to remove upper limit ([#723](https://github.com/stoatchat/stoatchat/issues/723)) ([ed4fd5e](https://github.com/stoatchat/stoatchat/commit/ed4fd5ebfe6d0ea534a0898da4afdc1f4e2cd6c5))
|
|
||||||
* use correct response for NoEffect errors ([#732](https://github.com/stoatchat/stoatchat/issues/732)) ([5378cd2](https://github.com/stoatchat/stoatchat/commit/5378cd22b4c7d85f44c31a6af0dda00941b80d5c))
|
|
||||||
|
|
||||||
## [0.12.1](https://github.com/stoatchat/stoatchat/compare/v0.12.0...v0.12.1) (2026-04-10)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* add migration to update existing files to be animated ([#705](https://github.com/stoatchat/stoatchat/issues/705)) ([f2c056a](https://github.com/stoatchat/stoatchat/commit/f2c056a1515be493b195f3f5db5886c2ddf36700))
|
|
||||||
* don't send self dm notifications ([#706](https://github.com/stoatchat/stoatchat/issues/706)) ([f30b729](https://github.com/stoatchat/stoatchat/commit/f30b729ca90d0be6853c57ab4935694e5e59ae56))
|
|
||||||
* mise start + missing docker image ([#564](https://github.com/stoatchat/stoatchat/issues/564)) ([fb8fe16](https://github.com/stoatchat/stoatchat/commit/fb8fe1655776791421284a6a093e86f0320c258a))
|
|
||||||
* test failure due to wrong assertion ([#707](https://github.com/stoatchat/stoatchat/issues/707)) ([f81e329](https://github.com/stoatchat/stoatchat/commit/f81e3291bdd57af9ceedb2987b111acc7051d69c))
|
|
||||||
|
|
||||||
## [0.12.0](https://github.com/stoatchat/stoatchat/compare/v0.11.5...v0.12.0) (2026-03-28)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add bug report template for issue tracking ([#627](https://github.com/stoatchat/stoatchat/issues/627)) ([f777e28](https://github.com/stoatchat/stoatchat/commit/f777e2863c6ca50057c8b5d0a5be14915d287724))
|
|
||||||
* Add slowmode functionality to text channels ([#680](https://github.com/stoatchat/stoatchat/issues/680)) ([6107f24](https://github.com/stoatchat/stoatchat/commit/6107f242fd3ebaff71a15f9a16330ffbcb4f2d7b))
|
|
||||||
* Allow restricting server creation to specific users ([#685](https://github.com/stoatchat/stoatchat/issues/685)) ([edfa97d](https://github.com/stoatchat/stoatchat/commit/edfa97db108c9c81828547f98a1db5315cb5ba4a))
|
|
||||||
* compute thumbhash for images ([#596](https://github.com/stoatchat/stoatchat/issues/596)) ([c2d4369](https://github.com/stoatchat/stoatchat/commit/c2d4369e160f32d79bce0a0b0f14677f89de3669))
|
|
||||||
* Detect animation in image files for fetch_preview ([#574](https://github.com/stoatchat/stoatchat/issues/574)) ([3fa0abf](https://github.com/stoatchat/stoatchat/commit/3fa0abf47f5f42ddd8ee041fe4c44fbc5ba800c1))
|
|
||||||
* expose global and user limits in root API response ([#644](https://github.com/stoatchat/stoatchat/issues/644)) ([0b522eb](https://github.com/stoatchat/stoatchat/commit/0b522ebddc17f2e3f792ff5e2347793e9849fa23))
|
|
||||||
* implement time based message sweep on user ban ([#670](https://github.com/stoatchat/stoatchat/issues/670)) ([98c7b1b](https://github.com/stoatchat/stoatchat/commit/98c7b1b5a5b9fdac5c0ab83be10f0e23114dbfc9))
|
|
||||||
* load config from env vars ([#576](https://github.com/stoatchat/stoatchat/issues/576)) ([5191bd1](https://github.com/stoatchat/stoatchat/commit/5191bd16b2a905b8409838e34eb0baca96f08580))
|
|
||||||
* parse message push notification content and replace internal formatting ([#693](https://github.com/stoatchat/stoatchat/issues/693)) ([d1e72ce](https://github.com/stoatchat/stoatchat/commit/d1e72cee42c54e16f4e49af569897528b10a28ca))
|
|
||||||
* Transfer ownership ([#396](https://github.com/stoatchat/stoatchat/issues/396)) ([735d644](https://github.com/stoatchat/stoatchat/commit/735d644e043793cb86e74aab5b88bb4b8bc17ba2))
|
|
||||||
* update livekit ([#698](https://github.com/stoatchat/stoatchat/issues/698)) ([f181edc](https://github.com/stoatchat/stoatchat/commit/f181edc8f2ff3ce4b6d48938dfc73931ecfa2279))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* add flag for disabling events instead of commenting them out ([#695](https://github.com/stoatchat/stoatchat/issues/695)) ([a5cd08a](https://github.com/stoatchat/stoatchat/commit/a5cd08a655dece4269f3ac84fa2387ae356709a5))
|
|
||||||
* add masquerade permission to default direct message settings ([#665](https://github.com/stoatchat/stoatchat/issues/665)) ([ab52569](https://github.com/stoatchat/stoatchat/commit/ab525699bd6663333f0e9fed6d2455e482e6a09f))
|
|
||||||
* Check for appropriate permission for removing other users avatar ([#657](https://github.com/stoatchat/stoatchat/issues/657)) ([d56135e](https://github.com/stoatchat/stoatchat/commit/d56135e0cbc713884c9378832952f7ad490fa315))
|
|
||||||
* default video resolution is a non-existent size ([#601](https://github.com/stoatchat/stoatchat/issues/601)) ([0698e11](https://github.com/stoatchat/stoatchat/commit/0698e115e8d003d615e468c4fb9654e6bbc9107f)), closes [#588](https://github.com/stoatchat/stoatchat/issues/588)
|
|
||||||
* **docs:** Update GitHub links ([#647](https://github.com/stoatchat/stoatchat/issues/647)) ([b830631](https://github.com/stoatchat/stoatchat/commit/b830631bd25a546844b7bdd30386084bb365e4de))
|
|
||||||
* don't use a bitop for OR ([#676](https://github.com/stoatchat/stoatchat/issues/676)) ([5701b5c](https://github.com/stoatchat/stoatchat/commit/5701b5c18c513f796af365169ceaea372a22638c))
|
|
||||||
* Fix typo for p256dh in vapid notification flow ([#622](https://github.com/stoatchat/stoatchat/issues/622)) ([a80ad1c](https://github.com/stoatchat/stoatchat/commit/a80ad1cbe58b8af5e45751e51d94d93c1cea1c9f))
|
|
||||||
* improve generated openapi.json ([#584](https://github.com/stoatchat/stoatchat/issues/584)) ([52ed510](https://github.com/stoatchat/stoatchat/commit/52ed5100c2446e0b261085639e123e7e124cab2c))
|
|
||||||
* no node state set on channel creation ([#653](https://github.com/stoatchat/stoatchat/issues/653)) ([24d0d2b](https://github.com/stoatchat/stoatchat/commit/24d0d2b7266f6f8a692d0a52704acfecf517674c))
|
|
||||||
* only show first line on commit messages ([#696](https://github.com/stoatchat/stoatchat/issues/696)) ([91783b9](https://github.com/stoatchat/stoatchat/commit/91783b906697fc85305dee683f7c15dda55f0c50))
|
|
||||||
* pass &str to Reference ([#697](https://github.com/stoatchat/stoatchat/issues/697)) ([ccda6f5](https://github.com/stoatchat/stoatchat/commit/ccda6f5c53ee043705f7ff6b5f6c393f020781de))
|
|
||||||
* redis_url vs redis_uri in config ([#666](https://github.com/stoatchat/stoatchat/issues/666)) ([b0b728f](https://github.com/stoatchat/stoatchat/commit/b0b728fb0dbc9ee28360301de1c3ea501bbbff1d))
|
|
||||||
* replace some links and Revolt mentions to current Stoat ([#515](https://github.com/stoatchat/stoatchat/issues/515)) ([d629e89](https://github.com/stoatchat/stoatchat/commit/d629e89304be2f0011e189293b278f07d346aa7d))
|
|
||||||
* send push notifications for DM and group messages ([#660](https://github.com/stoatchat/stoatchat/issues/660)) ([52c0d2f](https://github.com/stoatchat/stoatchat/commit/52c0d2f266b76d8975bba2d5e75c62bb30149c45))
|
|
||||||
* store server id in redis and in room metadata to be able to delete voice state in all scenarios ([#656](https://github.com/stoatchat/stoatchat/issues/656)) ([49c6289](https://github.com/stoatchat/stoatchat/commit/49c628958070e4f0a5edc764d3b48158589219d9))
|
|
||||||
* uname is missing from crond ([#675](https://github.com/stoatchat/stoatchat/issues/675)) ([dc4438b](https://github.com/stoatchat/stoatchat/commit/dc4438bc3c7b2cad8d442b3cd438afb9ed566a5e))
|
|
||||||
|
|
||||||
## [0.11.5](https://github.com/stoatchat/stoatchat/compare/v0.11.4...v0.11.5) (2026-02-17)
|
|
||||||
|
|
||||||
|
|
||||||
### Reverts
|
|
||||||
|
|
||||||
* disable user update events ([#593](https://github.com/stoatchat/stoatchat/issues/593)) ([1c98ead](https://github.com/stoatchat/stoatchat/commit/1c98ead69579b4700be0b51c9020bb8402336cc6))
|
|
||||||
|
|
||||||
## [0.11.4](https://github.com/stoatchat/stoatchat/compare/v0.11.3...v0.11.4) (2026-02-16)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* add separate config option for redis events replica url ([#590](https://github.com/stoatchat/stoatchat/issues/590)) ([a75e4ea](https://github.com/stoatchat/stoatchat/commit/a75e4eabfc4b34aba7620c82ba77558a32d9e10a))
|
|
||||||
|
|
||||||
## [0.11.3](https://github.com/stoatchat/stoatchat/compare/v0.11.2...v0.11.3) (2026-02-13)
|
## [0.11.3](https://github.com/stoatchat/stoatchat/compare/v0.11.2...v0.11.3) (2026-02-13)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Generated
+1869
-2899
File diff suppressed because it is too large.
Load diff
+9
-163
@@ -1,5 +1,5 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "3"
|
resolver = "2"
|
||||||
|
|
||||||
members = [
|
members = [
|
||||||
"crates/delta",
|
"crates/delta",
|
||||||
@@ -20,130 +20,24 @@ lto = true
|
|||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
# Async
|
# Async
|
||||||
async-trait = "0.1.89"
|
async-trait = "0.1.89"
|
||||||
tokio = "1.49.0"
|
tokio = { version = "1.49.0", features = ["macros", "rt"] }
|
||||||
async-channel = "2.3.1"
|
|
||||||
futures = "0.3.32"
|
|
||||||
async-std = "1.8.0"
|
|
||||||
async-tungstenite = "0.17.0"
|
|
||||||
futures-locks = "0.7.1"
|
|
||||||
async-lock = "2.8.0"
|
|
||||||
async-recursion = "1.0.4"
|
|
||||||
|
|
||||||
# Error Handling
|
# Error Handling
|
||||||
anyhow = "1.0.100"
|
anyhow = "1.0.100"
|
||||||
thiserror = "2.0.18"
|
thiserror = "2.0.18"
|
||||||
sentry = "0.31.5"
|
|
||||||
sentry-anyhow = "0.38.1"
|
|
||||||
|
|
||||||
# Data Validation
|
# Other Utilities
|
||||||
regex = "1.12.3"
|
uuid = { version = "1.19.0", features = ["v4"] }
|
||||||
validator = "0.16"
|
|
||||||
|
|
||||||
# Data Types
|
|
||||||
uuid = "1.19.0"
|
|
||||||
ulid = "1.2.1"
|
|
||||||
nanoid = "0.4.0"
|
|
||||||
typenum = "1.17.0"
|
|
||||||
num_enum = "0.6.1"
|
|
||||||
bitfield = "0.13.2"
|
|
||||||
|
|
||||||
# Time
|
|
||||||
chrono = "0.4.15"
|
|
||||||
iso8601-timestamp = "0.2.10"
|
|
||||||
|
|
||||||
# Data Collections
|
|
||||||
lru = "0.16.3"
|
|
||||||
indexmap = "2.13.1"
|
|
||||||
dashmap = "5.2.0"
|
|
||||||
moka = "0.12.8"
|
|
||||||
lru_time_cache = "0.11.11"
|
|
||||||
deadqueue = "0.2.4"
|
|
||||||
|
|
||||||
# Web scraping
|
|
||||||
scraper = "0.20.0"
|
|
||||||
encoding_rs = "0.8.34"
|
|
||||||
|
|
||||||
# Mail
|
|
||||||
lettre = "0.10.0-alpha.4"
|
|
||||||
|
|
||||||
# HTTP Requests
|
|
||||||
reqwest = "0.13.2"
|
|
||||||
isahc = "1.7"
|
|
||||||
|
|
||||||
# Notifications
|
|
||||||
fcm_v1 = "0.3.0"
|
|
||||||
web-push = "0.10.0"
|
|
||||||
revolt_a2 = "0.10"
|
|
||||||
|
|
||||||
# Parsing
|
|
||||||
logos = "0.15"
|
|
||||||
|
|
||||||
# SVG rendering
|
|
||||||
usvg = "0.44.0"
|
|
||||||
resvg = "0.44.0"
|
|
||||||
tiny-skia = "0.11.4"
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
log = "0.4.29"
|
|
||||||
pretty_env_logger = "0.4.0"
|
|
||||||
|
|
||||||
# Redis
|
|
||||||
redis-kiss = "0.1.4"
|
|
||||||
fred = "8.0.1"
|
|
||||||
|
|
||||||
# Serialisation
|
|
||||||
bincode = "1.3.3"
|
|
||||||
serde_json = "1.0.79"
|
|
||||||
rmp-serde = "1.0.0"
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
|
||||||
strum_macros = "0.26.4"
|
|
||||||
|
|
||||||
# MongoDB
|
|
||||||
bson = { version = "2.1.0" }
|
|
||||||
mongodb = { version = "3.1.0" }
|
|
||||||
|
|
||||||
# S3
|
|
||||||
aws-config = "1.5.5"
|
|
||||||
aws-sdk-s3 = "1.46.0"
|
|
||||||
|
|
||||||
# Axum (HTTP server)
|
# Axum (HTTP server)
|
||||||
axum-macros = "0.4.1"
|
axum-macros = "0.4.1"
|
||||||
axum_typed_multipart = "0.12.1"
|
axum_typed_multipart = "0.12.1"
|
||||||
axum = "0.7.5"
|
axum = { version = "0.7.5", features = ["multipart"] }
|
||||||
axum-extra = "0.9"
|
tower-http = { version = "0.5.2", features = ["cors", "trace"] }
|
||||||
tower-http = "0.5.2"
|
|
||||||
|
|
||||||
# Rocket (HTTP server)
|
|
||||||
rocket = "0.5.1"
|
|
||||||
rocket_empty = "0.1.1"
|
|
||||||
revolt_rocket_okapi = "0.10.0"
|
|
||||||
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "072d90359b23e9b291df6b672c07c93de9c46011" }
|
|
||||||
rocket_authifier = "1.0.16"
|
|
||||||
rocket_prometheus = "0.10.0-rc.3"
|
|
||||||
|
|
||||||
# Spec Generation
|
|
||||||
utoipa = "4.2.3"
|
|
||||||
revolt_okapi = "0.9.1"
|
|
||||||
schemars = "0.8.8"
|
|
||||||
utoipa-scalar = "0.1.0"
|
|
||||||
|
|
||||||
# Image Processing
|
# Image Processing
|
||||||
jxl-oxide = "0.12.5"
|
jxl-oxide = { version = "0.12.5", features = ["image"] }
|
||||||
sha2 = "0.10.8"
|
image = "0.25.9"
|
||||||
kamadak-exif = "0.5.4"
|
|
||||||
webp = "0.3.0"
|
|
||||||
image = "0.25.2" # avif encode requires dav1d system library: features = ["avif-native"]
|
|
||||||
thumbhash = "0.1.0"
|
|
||||||
lcms2 = "6.1.1" # for color profile processing
|
|
||||||
|
|
||||||
# File processing
|
|
||||||
revolt_clamav-client = "0.1.5"
|
|
||||||
simdutf8 = "0.1.4"
|
|
||||||
|
|
||||||
# Content type processing
|
|
||||||
infer = "0.16.0"
|
|
||||||
ffprobe = "0.4.0"
|
|
||||||
imagesize = "0.13.0"
|
|
||||||
|
|
||||||
# OpenTelemetry
|
# OpenTelemetry
|
||||||
tracing = "0.1.44"
|
tracing = "0.1.44"
|
||||||
@@ -153,52 +47,4 @@ tracing-subscriber = { version = "0.3.22", features = [
|
|||||||
opentelemetry = { version = "0.31.0", features = ["logs"] }
|
opentelemetry = { version = "0.31.0", features = ["logs"] }
|
||||||
opentelemetry_sdk = { version = "0.31.0", features = ["logs"] }
|
opentelemetry_sdk = { version = "0.31.0", features = ["logs"] }
|
||||||
opentelemetry-otlp = { version = "0.31.0", features = ["logs"] }
|
opentelemetry-otlp = { version = "0.31.0", features = ["logs"] }
|
||||||
opentelemetry-appender-tracing = "0.31.1"
|
opentelemetry-appender-tracing = { version = "0.31.1" }
|
||||||
|
|
||||||
# Authifier
|
|
||||||
authifier = "1.0.16"
|
|
||||||
|
|
||||||
# RabbitMQ
|
|
||||||
amqprs = "1.7.0"
|
|
||||||
lapin = "4.7.1"
|
|
||||||
|
|
||||||
# Voice
|
|
||||||
livekit-api = "0.4.4"
|
|
||||||
livekit-protocol = "0.7.4"
|
|
||||||
livekit-runtime = "0.4.0"
|
|
||||||
|
|
||||||
# Other Utilities
|
|
||||||
once_cell = "1.9.0"
|
|
||||||
config = "0.13.3"
|
|
||||||
cached = "0.44.0"
|
|
||||||
rand = "0.8.5"
|
|
||||||
base64 = "0.21.3"
|
|
||||||
decancer = "3.3.3"
|
|
||||||
linkify = "0.8.1"
|
|
||||||
url-escape = "0.1.1"
|
|
||||||
revolt_optional_struct = "0.2.0"
|
|
||||||
unicode-segmentation = "1.10.1"
|
|
||||||
querystring = "1.1.0"
|
|
||||||
tempfile = "3.12.0"
|
|
||||||
aes-gcm = "0.10.3"
|
|
||||||
auto_ops = "0.3.0"
|
|
||||||
url = "2.2.2"
|
|
||||||
impl_ops = "0.1.1"
|
|
||||||
lazy_static = "1.5.0"
|
|
||||||
mime = "0.3.17"
|
|
||||||
futures-lite = "2.6.1"
|
|
||||||
|
|
||||||
# Build Dependencies
|
|
||||||
vergen = "7.5.0"
|
|
||||||
|
|
||||||
# Local packages
|
|
||||||
revolt-coalesced = { version = "0.13.5", path = "crates/core/coalesced" }
|
|
||||||
revolt-config = { version = "0.13.5", path = "crates/core/config" }
|
|
||||||
revolt-database = { version = "0.13.5", path = "crates/core/database" }
|
|
||||||
revolt-files = { version = "0.13.5", path = "crates/core/files" }
|
|
||||||
revolt-models = { version = "0.13.5", path = "crates/core/models" }
|
|
||||||
revolt-parser = { version = "0.13.5", path = "crates/core/parser" }
|
|
||||||
revolt-permissions = { version = "0.13.5", path = "crates/core/permissions" }
|
|
||||||
revolt-presence = { version = "0.13.5", path = "crates/core/presence" }
|
|
||||||
revolt-ratelimits = { version = "0.13.5", path = "crates/core/ratelimits" }
|
|
||||||
revolt-result = { version = "0.13.5", path = "crates/core/result" }
|
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
<h1>
|
<h1>
|
||||||
Stoat Backend
|
Stoat Backend
|
||||||
|
|
||||||
[](https://github.com/stoatchat/stoatchat/stargazers)
|
[](https://github.com/revoltchat/backend/stargazers)
|
||||||
[](https://github.com/stoatchat/stoatchat/network/members)
|
[](https://github.com/revoltchat/backend/network/members)
|
||||||
[](https://github.com/stoatchat/stoatchat/pulls)
|
[](https://github.com/revoltchat/backend/pulls)
|
||||||
[](https://github.com/stoatchat/stoatchat/issues)
|
[](https://github.com/revoltchat/backend/issues)
|
||||||
[](https://github.com/stoatchat/stoatchat/graphs/contributors)
|
[](https://github.com/revoltchat/backend/graphs/contributors)
|
||||||
[](https://github.com/stoatchat/stoatchat/blob/main/LICENSE)
|
[](https://github.com/revoltchat/backend/blob/main/LICENSE)
|
||||||
</h1>
|
</h1>
|
||||||
The services and libraries that power the Stoat service.<br/>
|
The services and libraries that power the Revolt service.<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
| Crate | Path | Description | |
|
| Crate | Path | Description | |
|
||||||
@@ -39,7 +39,7 @@ Rust 1.86.0 or higher.
|
|||||||
|
|
||||||
## Development Guide
|
## Development Guide
|
||||||
|
|
||||||
Before contributing, make yourself familiar with [our contribution guidelines](https://developers.stoat.chat/developing/contrib/) and the [technical documentation for this project](https://developers.stoat.chat/).
|
Before contributing, make yourself familiar with [our contribution guidelines](https://developers.revolt.chat/contrib.html) and the [technical documentation for this project](https://revoltchat.github.io/backend/).
|
||||||
|
|
||||||
Before getting started, you'll want to install:
|
Before getting started, you'll want to install:
|
||||||
|
|
||||||
@@ -70,20 +70,11 @@ As a heads-up, the development environment uses the following ports:
|
|||||||
Now you can clone and build the project:
|
Now you can clone and build the project:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/stoatchat/stoatchat stoat-backend
|
git clone https://github.com/revoltchat/backend revolt-backend
|
||||||
cd stoat-backend
|
cd revolt-backend
|
||||||
mise install
|
|
||||||
mise build
|
mise build
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!TIP]
|
|
||||||
> You can override `BUILDER` in your `.env` file to run cargo with mold if you installed it:
|
|
||||||
>
|
|
||||||
> ```bash
|
|
||||||
> # .env
|
|
||||||
> BUILDER = "mold --run cargo"
|
|
||||||
> ```
|
|
||||||
|
|
||||||
A default configuration `Revolt.toml` is present in this project that is suited for development.
|
A default configuration `Revolt.toml` is present in this project that is suited for development.
|
||||||
|
|
||||||
If you'd like to change anything, create a `Revolt.overrides.toml` file and specify relevant variables.
|
If you'd like to change anything, create a `Revolt.overrides.toml` file and specify relevant variables.
|
||||||
@@ -120,7 +111,7 @@ If you'd like to change anything, create a `Revolt.overrides.toml` file and spec
|
|||||||
> - "14672:15672"
|
> - "14672:15672"
|
||||||
> ```
|
> ```
|
||||||
>
|
>
|
||||||
> With the corresponding Revolt configuration:
|
> And corresponding Revolt configuration:
|
||||||
>
|
>
|
||||||
> ```toml
|
> ```toml
|
||||||
> # Revolt.overrides.toml
|
> # Revolt.overrides.toml
|
||||||
@@ -132,41 +123,53 @@ If you'd like to change anything, create a `Revolt.overrides.toml` file and spec
|
|||||||
> [rabbit]
|
> [rabbit]
|
||||||
> port = 14072
|
> port = 14072
|
||||||
> ```
|
> ```
|
||||||
>
|
|
||||||
> And mise configuration
|
|
||||||
>
|
|
||||||
> ```bash
|
|
||||||
> #.env
|
|
||||||
> DATABASE_PORT = "14017"
|
|
||||||
> RABBIT_PORT = "14072"
|
|
||||||
> REDIS_PORT = "14079"
|
|
||||||
> ```
|
|
||||||
|
|
||||||
Then continue:
|
Then continue:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp livekit.example.yml livekit.yml
|
# start other necessary services
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
mise start
|
# run everything together
|
||||||
|
./scripts/start.sh
|
||||||
|
# .. or individually
|
||||||
|
# run the API server
|
||||||
|
cargo run --bin revolt-delta
|
||||||
|
# run the events server
|
||||||
|
cargo run --bin revolt-bonfire
|
||||||
|
# run the file server
|
||||||
|
cargo run --bin revolt-autumn
|
||||||
|
# run the proxy server
|
||||||
|
cargo run --bin revolt-january
|
||||||
|
# run the tenor proxy
|
||||||
|
cargo run --bin revolt-gifbox
|
||||||
|
# run the push daemon (not usually needed in regular development)
|
||||||
|
cargo run --bin revolt-pushd
|
||||||
|
|
||||||
|
# hint:
|
||||||
|
# mold -run <cargo build, cargo run, etc...>
|
||||||
|
# mold -run ./scripts/start.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
You can start a web client by doing the following in another terminal:
|
You can start a web client by doing the following:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# if you do not have yarn yet and have a modern Node.js:
|
# if you do not have yarn yet and have a modern Node.js:
|
||||||
corepack enable
|
corepack enable
|
||||||
|
|
||||||
# clone the web client and run it:
|
# clone the web client and run it:
|
||||||
git clone --recursive https://github.com/stoatchat/for-web stoat-web
|
git clone --recursive https://github.com/revoltchat/revite
|
||||||
cd stoat-web
|
cd revite
|
||||||
# refer to stoat-web/README.md for startup, creating an account and loging in
|
yarn
|
||||||
|
yarn build:deps
|
||||||
|
echo "VITE_API_URL=http://local.revolt.chat:14702" > .env.local
|
||||||
|
yarn dev --port 14701
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Then go to http://local.revolt.chat:14701 to create an account/login.
|
||||||
|
|
||||||
When signing up, go to http://localhost:14080 to find confirmation/password reset emails.
|
When signing up, go to http://localhost:14080 to find confirmation/password reset emails.
|
||||||
|
|
||||||
To stop all services, hit (CTRL + c) in the terminal you ran `mise start` and run `mise docker:stop`
|
|
||||||
|
|
||||||
|
|
||||||
## Deployment Guide
|
## Deployment Guide
|
||||||
|
|
||||||
### Cutting new crate releases
|
### Cutting new crate releases
|
||||||
@@ -195,14 +198,14 @@ Tag and push a new release by running:
|
|||||||
just release
|
just release
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have bumped the crate versions, proceed to [GitHub releases](https://github.com/stoatchat/stoatchat/releases/new) to create a changelog.
|
If you have bumped the crate versions, proceed to [GitHub releases](https://github.com/revoltchat/backend/releases/new) to create a changelog.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
First, start the required services:
|
First, start the required services:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker compose up -d
|
docker compose -f docker-compose.db.yml up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
Now run tests for whichever database:
|
Now run tests for whichever database:
|
||||||
@@ -214,6 +217,6 @@ TEST_DB=MONGODB cargo nextest run
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The Stoat backend is generally licensed under the [GNU Affero General Public License v3.0](https://github.com/stoatchat/stoatchat/blob/main/LICENSE).
|
The Revolt backend is generally licensed under the [GNU Affero General Public License v3.0](https://github.com/revoltchat/backend/blob/master/LICENSE).
|
||||||
|
|
||||||
**Individual crates may supply their own licenses!**
|
**Individual crates may supply their own licenses!**
|
||||||
+1
-1
@@ -15,7 +15,7 @@ host = "127.0.0.1"
|
|||||||
[hosts]
|
[hosts]
|
||||||
# Web locations of various services
|
# Web locations of various services
|
||||||
# Defaults assume all services are reverse-proxied
|
# Defaults assume all services are reverse-proxied
|
||||||
# See https://github.com/stoatchat/self-hosted/blob/main/Caddyfile
|
# See https://github.com/revoltchat/self-hosted/blob/master/Caddyfile
|
||||||
#
|
#
|
||||||
# Remember to change these to https/wss where appropriate in production!
|
# Remember to change these to https/wss where appropriate in production!
|
||||||
app = "http://local.revolt.chat:14701"
|
app = "http://local.revolt.chat:14701"
|
||||||
|
|||||||
+3
-13
@@ -8,20 +8,10 @@ services:
|
|||||||
# MongoDB
|
# MongoDB
|
||||||
database:
|
database:
|
||||||
image: mongo
|
image: mongo
|
||||||
command: mongod --replSet rs0
|
|
||||||
ports:
|
ports:
|
||||||
- "27017:27017"
|
- "27017:27017"
|
||||||
volumes:
|
volumes:
|
||||||
- ./.data/db:/data/db
|
- ./.data/db:/data/db
|
||||||
extra_hosts:
|
|
||||||
- "host.docker.internal:host-gateway"
|
|
||||||
healthcheck:
|
|
||||||
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'127.0.0.1:27017'}]}) }" | mongosh --port 27017 --quiet
|
|
||||||
interval: 5s
|
|
||||||
timeout: 30s
|
|
||||||
start_period: 0s
|
|
||||||
start_interval: 1s
|
|
||||||
retries: 30
|
|
||||||
ulimits:
|
ulimits:
|
||||||
nofile:
|
nofile:
|
||||||
soft: 65536
|
soft: 65536
|
||||||
@@ -29,8 +19,8 @@ services:
|
|||||||
|
|
||||||
# MinIO
|
# MinIO
|
||||||
minio:
|
minio:
|
||||||
image: firstfinger/minio:latest
|
image: minio/minio
|
||||||
#command: server /data
|
command: server /data
|
||||||
environment:
|
environment:
|
||||||
MINIO_ROOT_USER: minioautumn
|
MINIO_ROOT_USER: minioautumn
|
||||||
MINIO_ROOT_PASSWORD: minioautumn
|
MINIO_ROOT_PASSWORD: minioautumn
|
||||||
@@ -80,7 +70,7 @@ services:
|
|||||||
MAILDEV_INCOMING_PASS: smtp
|
MAILDEV_INCOMING_PASS: smtp
|
||||||
|
|
||||||
livekit:
|
livekit:
|
||||||
image: ghcr.io/stoatchat/livekit-server:v1.9.13
|
image: ghcr.io/stoatchat/livekit-server:v1.9.9
|
||||||
command: --config /etc/livekit.yml
|
command: --config /etc/livekit.yml
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
+30
-26
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
@@ -9,38 +9,42 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# util
|
# util
|
||||||
log = { workspace = true }
|
log = "*"
|
||||||
sentry = { workspace = true }
|
sentry = "0.31.5"
|
||||||
lru = { workspace = true }
|
lru = "0.7.6"
|
||||||
ulid = { workspace = true }
|
ulid = "0.5.0"
|
||||||
once_cell = { workspace = true }
|
once_cell = "1.9.0"
|
||||||
redis-kiss = { workspace = true }
|
redis-kiss = "0.1.4"
|
||||||
lru_time_cache = { workspace = true }
|
lru_time_cache = "0.11.11"
|
||||||
async-channel = { workspace = true }
|
async-channel = "2.3.1"
|
||||||
|
|
||||||
# parsing
|
# parsing
|
||||||
querystring = { workspace = true }
|
querystring = "1.1.0"
|
||||||
regex = { workspace = true }
|
regex = "1.11.1"
|
||||||
|
|
||||||
# serde
|
# serde
|
||||||
bincode = { workspace = true }
|
bincode = "1.3.3"
|
||||||
serde_json = { workspace = true }
|
serde_json = "1.0.79"
|
||||||
rmp-serde = { workspace = true }
|
rmp-serde = "1.0.0"
|
||||||
serde = { workspace = true }
|
serde = "1.0.136"
|
||||||
|
|
||||||
# async
|
# async
|
||||||
futures = { workspace = true }
|
futures = "0.3.21"
|
||||||
async-tungstenite = { workspace = true, features = ["async-std-runtime"] }
|
async-tungstenite = { version = "0.17.0", features = ["async-std-runtime"] }
|
||||||
async-std = { workspace = true }
|
async-std = { version = "1.8.0", features = [
|
||||||
|
"tokio1",
|
||||||
|
"tokio02",
|
||||||
|
"attributes",
|
||||||
|
] }
|
||||||
|
|
||||||
# core
|
# core
|
||||||
authifier = { workspace = true }
|
authifier = { version = "1.0.16" }
|
||||||
revolt-result = { workspace = true }
|
revolt-result = { path = "../core/result" }
|
||||||
revolt-models = { workspace = true }
|
revolt-models = { path = "../core/models" }
|
||||||
revolt-config = { workspace = true }
|
revolt-config = { path = "../core/config" }
|
||||||
revolt-database = { workspace = true, features = ["voice"] }
|
revolt-database = { path = "../core/database", features = ["voice"] }
|
||||||
revolt-permissions = { workspace = true }
|
revolt-permissions = { path = "../core/permissions" }
|
||||||
revolt-presence = { workspace = true, features = ["redis-is-patched"] }
|
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
|
||||||
|
|
||||||
# redis
|
# redis
|
||||||
fred = { workspace = true, features = ["subscriber-client"] }
|
fred = { version = "8.0.1", features = ["subscriber-client"] }
|
||||||
@@ -4,7 +4,7 @@ use futures::future::join_all;
|
|||||||
use revolt_database::{
|
use revolt_database::{
|
||||||
events::client::{EventV1, ReadyPayloadFields},
|
events::client::{EventV1, ReadyPayloadFields},
|
||||||
util::permissions::DatabasePermissionQuery,
|
util::permissions::DatabasePermissionQuery,
|
||||||
voice::{get_channel_voice_state, UserVoiceChannel},
|
voice::get_channel_voice_state,
|
||||||
Channel, Database, Member, MemberCompositeKey, Presence, RelationshipStatus,
|
Channel, Database, Member, MemberCompositeKey, Presence, RelationshipStatus,
|
||||||
};
|
};
|
||||||
use revolt_models::v0;
|
use revolt_models::v0;
|
||||||
@@ -167,9 +167,7 @@ impl State {
|
|||||||
| Channel::TextChannel { voice: Some(_), .. }
|
| Channel::TextChannel { voice: Some(_), .. }
|
||||||
)
|
)
|
||||||
}) {
|
}) {
|
||||||
if let Ok(Some(voice_state)) =
|
if let Ok(Some(voice_state)) = get_channel_voice_state(channel).await {
|
||||||
get_channel_voice_state(&UserVoiceChannel::from_channel(channel)).await
|
|
||||||
{
|
|
||||||
if let Some(server) = channel.server() {
|
if let Some(server) = channel.server() {
|
||||||
let set = voice_state_server_members
|
let set = voice_state_server_members
|
||||||
.entry(server.to_string())
|
.entry(server.to_string())
|
||||||
@@ -401,32 +399,27 @@ impl State {
|
|||||||
|
|
||||||
/// Push presence change to the user and all associated server topics
|
/// Push presence change to the user and all associated server topics
|
||||||
pub async fn broadcast_presence_change(&self, target: bool) {
|
pub async fn broadcast_presence_change(&self, target: bool) {
|
||||||
let config = revolt_config::config().await;
|
// if if let Some(status) = &self.cache.users.get(&self.cache.user_id).unwrap().status {
|
||||||
if config.disable_events_dont_use {
|
// status.presence != Some(Presence::Invisible)
|
||||||
return;
|
// } else {
|
||||||
}
|
// true
|
||||||
|
// } {
|
||||||
|
// let event = EventV1::UserUpdate {
|
||||||
|
// id: self.cache.user_id.clone(),
|
||||||
|
// data: v0::PartialUser {
|
||||||
|
// online: Some(target),
|
||||||
|
// ..Default::default()
|
||||||
|
// },
|
||||||
|
// clear: vec![],
|
||||||
|
// event_id: Some(ulid::Ulid::new().to_string()),
|
||||||
|
// };
|
||||||
|
|
||||||
if if let Some(status) = &self.cache.users.get(&self.cache.user_id).unwrap().status {
|
// for server in self.cache.servers.keys() {
|
||||||
status.presence != Some(Presence::Invisible)
|
// event.clone().p(server.clone()).await;
|
||||||
} else {
|
// }
|
||||||
true
|
|
||||||
} {
|
|
||||||
let event = EventV1::UserUpdate {
|
|
||||||
id: self.cache.user_id.clone(),
|
|
||||||
data: v0::PartialUser {
|
|
||||||
online: Some(target),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
clear: vec![],
|
|
||||||
event_id: Some(ulid::Ulid::new().to_string()),
|
|
||||||
};
|
|
||||||
|
|
||||||
for server in self.cache.servers.keys() {
|
// event.p(self.cache.user_id.clone()).await;
|
||||||
event.clone().p(server.clone()).await;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
event.p(self.cache.user_id.clone()).await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle an incoming event for protocol version 1
|
/// Handle an incoming event for protocol version 1
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet}, num::NonZeroUsize, sync::Arc, time::Duration
|
collections::{HashMap, HashSet},
|
||||||
|
sync::Arc,
|
||||||
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use async_std::sync::{Mutex, RwLock};
|
use async_std::sync::{Mutex, RwLock};
|
||||||
@@ -55,7 +57,7 @@ impl Default for Cache {
|
|||||||
members: Default::default(),
|
members: Default::default(),
|
||||||
servers: Default::default(),
|
servers: Default::default(),
|
||||||
|
|
||||||
seen_events: LruCache::new(NonZeroUsize::new(20).unwrap()),
|
seen_events: LruCache::new(20),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use authifier::AuthifierEvent;
|
|||||||
use fred::{
|
use fred::{
|
||||||
error::RedisErrorKind,
|
error::RedisErrorKind,
|
||||||
interfaces::{ClientLike, EventInterface, PubsubInterface},
|
interfaces::{ClientLike, EventInterface, PubsubInterface},
|
||||||
types::{ReconnectPolicy, RedisConfig},
|
types::RedisConfig,
|
||||||
};
|
};
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::oneshot,
|
channel::oneshot,
|
||||||
@@ -218,16 +218,10 @@ async fn listener(
|
|||||||
kill_signal_r: async_channel::Receiver<()>,
|
kill_signal_r: async_channel::Receiver<()>,
|
||||||
write: &Mutex<WsWriter>,
|
write: &Mutex<WsWriter>,
|
||||||
) {
|
) {
|
||||||
let stoat_config = revolt_config::config().await;
|
let redis_config = RedisConfig::from_url(&REDIS_URI).unwrap();
|
||||||
let url = stoat_config
|
let subscriber = match report_internal_error!(
|
||||||
.database
|
fred::types::Builder::from_config(redis_config).build_subscriber_client()
|
||||||
.redis_pubsub
|
) {
|
||||||
.unwrap_or(REDIS_URI.to_string());
|
|
||||||
|
|
||||||
let redis_config = RedisConfig::from_url(&url).unwrap();
|
|
||||||
let mut builder = fred::types::Builder::from_config(redis_config);
|
|
||||||
builder.set_policy(ReconnectPolicy::new_exponential(8, 100, 30_000, 2));
|
|
||||||
let subscriber = match report_internal_error!(builder.build_subscriber_client()) {
|
|
||||||
Ok(subscriber) => subscriber,
|
Ok(subscriber) => subscriber,
|
||||||
Err(_) => return,
|
Err(_) => return,
|
||||||
};
|
};
|
||||||
@@ -236,21 +230,16 @@ async fn listener(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let Fred automatically re-subscribe to tracked channels on reconnect.
|
|
||||||
subscriber.manage_subscriptions();
|
|
||||||
|
|
||||||
// Handle Redis connection dropping
|
// Handle Redis connection dropping
|
||||||
let (clean_up_s, clean_up_r) = async_channel::bounded(1);
|
let (clean_up_s, clean_up_r) = async_channel::bounded(1);
|
||||||
let clean_up_s = Arc::new(Mutex::new(clean_up_s));
|
let clean_up_s = Arc::new(Mutex::new(clean_up_s));
|
||||||
subscriber.on_error(move |err| {
|
subscriber.on_error(move |err| {
|
||||||
warn!("Redis subscriber error: {:?}", err);
|
|
||||||
if let RedisErrorKind::Canceled = err.kind() {
|
if let RedisErrorKind::Canceled = err.kind() {
|
||||||
let clean_up_s = clean_up_s.clone();
|
let clean_up_s = clean_up_s.clone();
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
clean_up_s.lock().await.send(()).await.ok();
|
clean_up_s.lock().await.send(()).await.ok();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Transient errors (IO, timeout) are handled by the reconnect policy.
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
@@ -433,8 +422,6 @@ async fn worker(
|
|||||||
mut read: WsReader,
|
mut read: WsReader,
|
||||||
write: &Mutex<WsWriter>,
|
write: &Mutex<WsWriter>,
|
||||||
) {
|
) {
|
||||||
let revolt_config = revolt_config::config().await;
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let t1 = read.try_next().fuse();
|
let t1 = read.try_next().fuse();
|
||||||
let t2 = kill_signal_r.recv().fuse();
|
let t2 = kill_signal_r.recv().fuse();
|
||||||
@@ -470,38 +457,8 @@ async fn worker(
|
|||||||
};
|
};
|
||||||
|
|
||||||
match payload {
|
match payload {
|
||||||
ClientMessage::BeginTyping { channel } => {
|
ClientMessage::BeginTyping { .. } => {}
|
||||||
if revolt_config.disable_events_dont_use {
|
ClientMessage::EndTyping { .. } => {}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if !subscribed.read().await.contains(&channel) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
EventV1::ChannelStartTyping {
|
|
||||||
id: channel.clone(),
|
|
||||||
user: user_id.clone(),
|
|
||||||
}
|
|
||||||
.p(channel.clone())
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
ClientMessage::EndTyping { channel } => {
|
|
||||||
if revolt_config.disable_events_dont_use {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if !subscribed.read().await.contains(&channel) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
EventV1::ChannelStopTyping {
|
|
||||||
id: channel.clone(),
|
|
||||||
user: user_id.clone(),
|
|
||||||
}
|
|
||||||
.p(channel.clone())
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
ClientMessage::Subscribe { server_id } => {
|
ClientMessage::Subscribe { server_id } => {
|
||||||
let mut servers = active_servers.lock().await;
|
let mut servers = active_servers.lock().await;
|
||||||
let has_item = servers.contains_key(&server_id);
|
let has_item = servers.contains_key(&server_id);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-coalesced"
|
name = "revolt-coalesced"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>", "Zomatree <me@zomatree.live>"]
|
authors = ["Paul Makles <me@insrt.uk>", "Zomatree <me@zomatree.live>"]
|
||||||
@@ -15,12 +15,12 @@ cache = ["dep:lru"]
|
|||||||
default = ["tokio"]
|
default = ["tokio"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { workspace = true, features = ["sync"], optional = true }
|
tokio = { version = "1.47.0", features = ["sync"], optional = true }
|
||||||
indexmap = { workspace = true, optional = true }
|
indexmap = { version = "2.13.0", optional = true }
|
||||||
lru = { workspace = true, optional = true }
|
lru = { version = "0.16.3", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { workspace = true, features = [
|
tokio = { version = "1.47.0", features = [
|
||||||
"rt",
|
"rt",
|
||||||
"rt-multi-thread",
|
"rt-multi-thread",
|
||||||
"macros",
|
"macros",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-config"
|
name = "revolt-config"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -18,24 +18,24 @@ default = ["test", "sentry"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
config = { workspace = true }
|
config = "0.13.3"
|
||||||
cached = { workspace = true }
|
cached = "0.44.0"
|
||||||
once_cell = { workspace = true }
|
once_cell = "1.18.0"
|
||||||
|
|
||||||
# Serde
|
# Serde
|
||||||
serde = { workspace = true }
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
futures-locks = { workspace = true }
|
futures-locks = "0.7.1"
|
||||||
async-std = { workspace = true, features = ["attributes"], optional = true }
|
async-std = { version = "1.8.0", features = ["attributes"], optional = true }
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log = { workspace = true }
|
log = "0.4.14"
|
||||||
pretty_env_logger = { workspace = true }
|
pretty_env_logger = "0.4.0"
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
sentry = { workspace = true, optional = true }
|
sentry = { version = "0.31.5", optional = true }
|
||||||
sentry-anyhow = { workspace = true, optional = true }
|
sentry-anyhow = { version = "0.38.1", optional = true }
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { workspace = true, optional = true }
|
revolt-result = { version = "0.11.3", path = "../result", optional = true }
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
production = false
|
production = false
|
||||||
disable_events_dont_use = false
|
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
# MongoDB connection URL
|
# MongoDB connection URL
|
||||||
@@ -12,7 +11,7 @@ redis = "redis://redis/"
|
|||||||
[hosts]
|
[hosts]
|
||||||
# Web locations of various services
|
# Web locations of various services
|
||||||
# Defaults assume all services are reverse-proxied
|
# Defaults assume all services are reverse-proxied
|
||||||
# See https://github.com/stoatchat/self-hosted/blob/main/Caddyfile
|
# See https://github.com/revoltchat/self-hosted/blob/master/Caddyfile
|
||||||
#
|
#
|
||||||
# Remember to change these to https/wss where appropriate in production!
|
# Remember to change these to https/wss where appropriate in production!
|
||||||
app = "http://local.revolt.chat"
|
app = "http://local.revolt.chat"
|
||||||
@@ -30,16 +29,12 @@ host = "rabbit"
|
|||||||
port = 5672
|
port = 5672
|
||||||
username = "rabbituser"
|
username = "rabbituser"
|
||||||
password = "rabbitpass"
|
password = "rabbitpass"
|
||||||
default_exchange = "revolt.default"
|
|
||||||
|
|
||||||
[rabbit.queues]
|
|
||||||
acks = "internal.ack"
|
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[api.registration]
|
[api.registration]
|
||||||
# Whether an invite should be required for registration
|
# Whether an invite should be required for registration
|
||||||
# See https://github.com/stoatchat/self-hosted#making-your-instance-invite-only
|
# See https://github.com/revoltchat/self-hosted#making-your-instance-invite-only
|
||||||
invite_only = false
|
invite_only = false
|
||||||
|
|
||||||
[api.smtp]
|
[api.smtp]
|
||||||
@@ -82,8 +77,6 @@ call_ring_duration = 30
|
|||||||
[api.livekit.nodes]
|
[api.livekit.nodes]
|
||||||
|
|
||||||
[api.users]
|
[api.users]
|
||||||
# Minimum allowed length of usernames
|
|
||||||
min_username_length = 2
|
|
||||||
|
|
||||||
[pushd]
|
[pushd]
|
||||||
# this changes the names of the queues to not overlap
|
# this changes the names of the queues to not overlap
|
||||||
@@ -95,11 +88,6 @@ production = true
|
|||||||
# Increasing this will resolve mentions faster, but will consume more memory while resolving.
|
# Increasing this will resolve mentions faster, but will consume more memory while resolving.
|
||||||
mass_mention_chunk_size = 200
|
mass_mention_chunk_size = 200
|
||||||
|
|
||||||
# How long pushd will cache resolved names for rendered message notifications.
|
|
||||||
# Increasing this will result in lower database usage, but may result in a situation where a user/channel/role name changes
|
|
||||||
# and the notifications still resolve to the old name.
|
|
||||||
render_cache_time = 60
|
|
||||||
|
|
||||||
# none of these should need changing
|
# none of these should need changing
|
||||||
exchange = "revolt.notifications"
|
exchange = "revolt.notifications"
|
||||||
message_queue = "notifications.origin.message"
|
message_queue = "notifications.origin.message"
|
||||||
@@ -136,8 +124,6 @@ pkcs8 = ""
|
|||||||
key_id = ""
|
key_id = ""
|
||||||
team_id = ""
|
team_id = ""
|
||||||
|
|
||||||
[january]
|
|
||||||
blocked_domains = []
|
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
# Encryption key for stored files
|
# Encryption key for stored files
|
||||||
@@ -234,10 +220,6 @@ new_user_hours = 72
|
|||||||
# (should be greater than any one file upload limit)
|
# (should be greater than any one file upload limit)
|
||||||
body_limit_size = 20_000_000
|
body_limit_size = 20_000_000
|
||||||
|
|
||||||
# If any userids are entered here, only those users will be able to create servers.
|
|
||||||
# Leave empty to allow all users to create servers
|
|
||||||
restrict_server_creation = []
|
|
||||||
|
|
||||||
[features.limits.new_user]
|
[features.limits.new_user]
|
||||||
# Limits imposed on new users
|
# Limits imposed on new users
|
||||||
|
|
||||||
@@ -262,7 +244,7 @@ voice_quality = 16000
|
|||||||
# Whether the user can use video streams in voice calls
|
# Whether the user can use video streams in voice calls
|
||||||
video = true
|
video = true
|
||||||
|
|
||||||
# Maximum resolution (width, height) of video streams in voice calls
|
# Mamimum resolution (width, height) of video streams in voice calls
|
||||||
video_resolution = [1080, 720]
|
video_resolution = [1080, 720]
|
||||||
|
|
||||||
# Minimum and maximum aspect ratio of video streams in voice calls
|
# Minimum and maximum aspect ratio of video streams in voice calls
|
||||||
@@ -301,8 +283,8 @@ voice_quality = 16000
|
|||||||
# Whether the user can use video streams in voice calls
|
# Whether the user can use video streams in voice calls
|
||||||
video = true
|
video = true
|
||||||
|
|
||||||
# Maximum resolution (width, height) of video streams in voice calls
|
# Mamimum resolution (width, height) of video streams in voice calls
|
||||||
video_resolution = [1280, 720]
|
video_resolution = [1080, 720]
|
||||||
|
|
||||||
# Minimum and maximum aspect ratio of video streams in voice calls
|
# Minimum and maximum aspect ratio of video streams in voice calls
|
||||||
video_aspect_ratio = [0.3, 2.5]
|
video_aspect_ratio = [0.3, 2.5]
|
||||||
@@ -321,12 +303,6 @@ emojis = 500_000
|
|||||||
# default: 5
|
# default: 5
|
||||||
process_message_delay_limit = 5
|
process_message_delay_limit = 5
|
||||||
|
|
||||||
[features.legal_links]
|
|
||||||
# URLs for legal documents
|
|
||||||
terms_of_service = ""
|
|
||||||
privacy_policy = ""
|
|
||||||
guidelines = ""
|
|
||||||
|
|
||||||
[sentry]
|
[sentry]
|
||||||
# Configuration for Sentry error reporting
|
# Configuration for Sentry error reporting
|
||||||
api = ""
|
api = ""
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::{collections::HashMap, path::Path};
|
use std::{collections::HashMap, path::Path};
|
||||||
|
|
||||||
use cached::proc_macro::cached;
|
use cached::proc_macro::cached;
|
||||||
use config::{Config, Environment, File, FileFormat};
|
use config::{Config, File, FileFormat};
|
||||||
use futures_locks::RwLock;
|
use futures_locks::RwLock;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@@ -109,8 +109,6 @@ static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
|
|||||||
cwd = path.parent();
|
cwd = path.parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
builder = builder.add_source(Environment::with_prefix("REVOLT").separator("__"));
|
|
||||||
|
|
||||||
builder.build().unwrap()
|
builder.build().unwrap()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -119,12 +117,6 @@ static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
|
|||||||
pub struct Database {
|
pub struct Database {
|
||||||
pub mongodb: String,
|
pub mongodb: String,
|
||||||
pub redis: String,
|
pub redis: String,
|
||||||
pub redis_pubsub: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
|
||||||
pub struct RabbitQueues {
|
|
||||||
pub acks: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -133,8 +125,6 @@ pub struct Rabbit {
|
|||||||
pub port: u16,
|
pub port: u16,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
pub default_exchange: String,
|
|
||||||
pub queues: RabbitQueues,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -238,7 +228,6 @@ pub struct LiveKitNode {
|
|||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct ApiUsers {
|
pub struct ApiUsers {
|
||||||
pub early_adopter_cutoff: Option<u64>,
|
pub early_adopter_cutoff: Option<u64>,
|
||||||
pub min_username_length: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -256,7 +245,6 @@ pub struct Pushd {
|
|||||||
pub production: bool,
|
pub production: bool,
|
||||||
pub exchange: String,
|
pub exchange: String,
|
||||||
pub mass_mention_chunk_size: usize,
|
pub mass_mention_chunk_size: usize,
|
||||||
pub render_cache_time: usize,
|
|
||||||
|
|
||||||
// Queues
|
// Queues
|
||||||
pub message_queue: String,
|
pub message_queue: String,
|
||||||
@@ -309,11 +297,6 @@ impl Pushd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
|
||||||
pub struct January {
|
|
||||||
pub blocked_domains: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct FilesLimit {
|
pub struct FilesLimit {
|
||||||
pub min_file_size: usize,
|
pub min_file_size: usize,
|
||||||
@@ -358,8 +341,6 @@ pub struct GlobalLimits {
|
|||||||
pub new_user_hours: usize,
|
pub new_user_hours: usize,
|
||||||
|
|
||||||
pub body_limit_size: usize,
|
pub body_limit_size: usize,
|
||||||
|
|
||||||
pub restrict_server_creation: Vec<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -389,16 +370,6 @@ pub struct FeaturesLimitsCollection {
|
|||||||
pub roles: HashMap<String, FeaturesLimits>,
|
pub roles: HashMap<String, FeaturesLimits>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
|
||||||
pub struct LegalLinks {
|
|
||||||
/// Terms of Service URL
|
|
||||||
pub terms_of_service: String,
|
|
||||||
/// Privacy Policy URL
|
|
||||||
pub privacy_policy: String,
|
|
||||||
/// Guidelines URL
|
|
||||||
pub guidelines: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct FeaturesAdvanced {
|
pub struct FeaturesAdvanced {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -416,7 +387,6 @@ impl Default for FeaturesAdvanced {
|
|||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Features {
|
pub struct Features {
|
||||||
pub limits: FeaturesLimitsCollection,
|
pub limits: FeaturesLimitsCollection,
|
||||||
pub legal_links: LegalLinks,
|
|
||||||
pub webhooks_enabled: bool,
|
pub webhooks_enabled: bool,
|
||||||
pub mass_mentions_send_notifications: bool,
|
pub mass_mentions_send_notifications: bool,
|
||||||
pub mass_mentions_enabled: bool,
|
pub mass_mentions_enabled: bool,
|
||||||
@@ -444,12 +414,10 @@ pub struct Settings {
|
|||||||
pub hosts: Hosts,
|
pub hosts: Hosts,
|
||||||
pub api: Api,
|
pub api: Api,
|
||||||
pub pushd: Pushd,
|
pub pushd: Pushd,
|
||||||
pub january: January,
|
|
||||||
pub files: Files,
|
pub files: Files,
|
||||||
pub features: Features,
|
pub features: Features,
|
||||||
pub sentry: Sentry,
|
pub sentry: Sentry,
|
||||||
pub production: bool,
|
pub production: bool,
|
||||||
pub disable_events_dont_use: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
@@ -480,14 +448,12 @@ pub async fn config() -> Settings {
|
|||||||
let mut config = read().await.try_deserialize::<Settings>().unwrap();
|
let mut config = read().await.try_deserialize::<Settings>().unwrap();
|
||||||
|
|
||||||
// inject REDIS_URI for redis-kiss library
|
// inject REDIS_URI for redis-kiss library
|
||||||
if std::env::var("REDIS_URI").is_err() {
|
if std::env::var("REDIS_URL").is_err() {
|
||||||
std::env::set_var("REDIS_URI", config.database.redis.clone());
|
std::env::set_var("REDIS_URI", config.database.redis.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto-detect production nodes
|
// auto-detect production nodes
|
||||||
if config.hosts.api.contains("https")
|
if config.hosts.api.contains("https") && config.hosts.api.contains("revolt.chat") {
|
||||||
&& (config.hosts.api.contains("revolt.chat") || config.hosts.api.contains("stoat.chat"))
|
|
||||||
{
|
|
||||||
config.production = true;
|
config.production = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-database"
|
name = "revolt-database"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -32,72 +32,80 @@ default = ["mongodb", "async-std-runtime", "tasks"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { workspace = true, features = ["report-macros"] }
|
revolt-config = { version = "0.11.3", path = "../config", features = [
|
||||||
revolt-result = { workspace = true }
|
"report-macros",
|
||||||
revolt-models = { workspace = true, features = ["validator"] }
|
] }
|
||||||
revolt-presence = { workspace = true }
|
revolt-result = { version = "0.11.3", path = "../result" }
|
||||||
revolt-permissions = { workspace = true, features = ["serde", "bson"] }
|
revolt-models = { version = "0.11.3", path = "../models", features = [
|
||||||
revolt-parser = { workspace = true }
|
"validator",
|
||||||
revolt-coalesced = { workspace = true }
|
] }
|
||||||
|
revolt-presence = { version = "0.11.3", path = "../presence" }
|
||||||
|
revolt-permissions = { version = "0.11.3", path = "../permissions", features = [
|
||||||
|
"serde",
|
||||||
|
"bson",
|
||||||
|
] }
|
||||||
|
revolt-parser = { version = "0.11.3", path = "../parser" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
log = { workspace = true }
|
log = "0.4"
|
||||||
lru = { workspace = true }
|
lru = "0.11.0"
|
||||||
rand = { workspace = true }
|
rand = "0.8.5"
|
||||||
ulid = { workspace = true }
|
ulid = "1.0.0"
|
||||||
nanoid = { workspace = true }
|
nanoid = "0.4.0"
|
||||||
base64 = { workspace = true }
|
base64 = "0.21.3"
|
||||||
once_cell = { workspace = true }
|
once_cell = "1.17"
|
||||||
indexmap = { workspace = true }
|
indexmap = "1.9.1"
|
||||||
decancer = { workspace = true }
|
decancer = "1.6.2"
|
||||||
deadqueue = { workspace = true }
|
deadqueue = "0.2.4"
|
||||||
linkify = { workspace = true, optional = true }
|
linkify = { optional = true, version = "0.8.1" }
|
||||||
url-escape = { workspace = true, optional = true }
|
url-escape = { optional = true, version = "0.1.1" }
|
||||||
validator = { workspace = true, features = ["derive"] }
|
validator = { version = "0.16", features = ["derive"] }
|
||||||
isahc = { workspace = true, features = ["json"], optional = true }
|
isahc = { optional = true, version = "1.7", features = ["json"] }
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
serde_json = { workspace = true }
|
serde_json = "1"
|
||||||
revolt_optional_struct = { workspace = true }
|
revolt_optional_struct = "0.2.0"
|
||||||
serde = { workspace = true }
|
serde = { version = "1", features = ["derive"] }
|
||||||
iso8601-timestamp = { workspace = true, features = ["serde", "bson"] }
|
iso8601-timestamp = { version = "0.2.10", features = ["serde", "bson"] }
|
||||||
|
|
||||||
# Events
|
# Events
|
||||||
redis-kiss = { workspace = true }
|
redis-kiss = { version = "0.1.4" }
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
bson = { workspace = true, optional = true }
|
bson = { optional = true, version = "2.1.0" }
|
||||||
mongodb = { workspace = true, optional = true }
|
mongodb = { optional = true, version = "3.1.0" }
|
||||||
|
|
||||||
# Database Migration
|
# Database Migration
|
||||||
unicode-segmentation = { workspace = true }
|
unicode-segmentation = "1.10.1"
|
||||||
regex = { workspace = true }
|
regex = "1"
|
||||||
|
|
||||||
# Async Language Features
|
# Async Language Features
|
||||||
futures = { workspace = true }
|
futures = "0.3.19"
|
||||||
async-lock = { workspace = true }
|
async-lock = "2.8.0"
|
||||||
async-trait = { workspace = true }
|
async-trait = "0.1.51"
|
||||||
async-recursion = { workspace = true }
|
async-recursion = "1.0.4"
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
async-std = { workspace = true, features = ["attributes"], optional = true }
|
async-std = { version = "1.8.0", features = ["attributes"], optional = true }
|
||||||
|
|
||||||
# Axum Impl
|
# Axum Impl
|
||||||
axum = { workspace = true, optional = true }
|
axum = { version = "0.7.5", optional = true }
|
||||||
|
|
||||||
# Rocket Impl
|
# Rocket Impl
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { version = "0.8.8", optional = true }
|
||||||
rocket = { workspace = true, features = ["json"], optional = true }
|
rocket = { version = "0.5.1", default-features = false, features = [
|
||||||
revolt_okapi = { workspace = true, optional = true }
|
"json",
|
||||||
revolt_rocket_okapi = { workspace = true, optional = true }
|
], optional = true }
|
||||||
|
revolt_okapi = { version = "0.9.1", optional = true }
|
||||||
|
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
||||||
|
|
||||||
# Authifier
|
# Authifier
|
||||||
authifier = { workspace = true }
|
authifier = { version = "1.0.16" }
|
||||||
|
|
||||||
# RabbitMQ
|
# RabbitMQ
|
||||||
amqprs = { workspace = true }
|
amqprs = { version = "1.7.0" }
|
||||||
|
|
||||||
# Voice
|
# Voice
|
||||||
livekit-api = { workspace = true, features = ["rustls-tls-native-roots"], optional = true }
|
livekit-api = { version = "0.4.4", optional = true }
|
||||||
livekit-protocol = { workspace = true, optional = true }
|
livekit-protocol = { version = "0.4.0", optional = true }
|
||||||
livekit-runtime = { workspace = true, features = ["tokio"], optional = true }
|
livekit-runtime = { version = "0.3.1", features = ["tokio"], optional = true }
|
||||||
@@ -2,10 +2,7 @@ use std::collections::HashSet;
|
|||||||
|
|
||||||
use crate::events::rabbit::*;
|
use crate::events::rabbit::*;
|
||||||
use crate::User;
|
use crate::User;
|
||||||
use amqprs::channel::{
|
use amqprs::channel::{BasicPublishArguments, ExchangeDeclareArguments};
|
||||||
BasicPublishArguments, ExchangeDeclareArguments, ExchangeType, QueueBindArguments,
|
|
||||||
QueueDeclareArguments,
|
|
||||||
};
|
|
||||||
use amqprs::connection::OpenConnectionArguments;
|
use amqprs::connection::OpenConnectionArguments;
|
||||||
use amqprs::{channel::Channel, connection::Connection, error::Error as AMQPError};
|
use amqprs::{channel::Channel, connection::Connection, error::Error as AMQPError};
|
||||||
use amqprs::{BasicProperties, FieldTable};
|
use amqprs::{BasicProperties, FieldTable};
|
||||||
@@ -29,7 +26,7 @@ impl AMQP {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn new_auto() -> revolt_result::Result<AMQP> {
|
pub async fn new_auto() -> AMQP {
|
||||||
let config = revolt_config::config().await;
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
let connection = Connection::open(&OpenConnectionArguments::new(
|
let connection = Connection::open(&OpenConnectionArguments::new(
|
||||||
@@ -46,58 +43,16 @@ impl AMQP {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to open RabbitMQ channel");
|
.expect("Failed to open RabbitMQ channel");
|
||||||
|
|
||||||
let mut resp = AMQP::new(connection, channel);
|
channel
|
||||||
//resp.configure_channels().await?;
|
|
||||||
Ok(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn repoen_channel(&mut self) {
|
|
||||||
self.channel = self
|
|
||||||
.connection
|
|
||||||
.open_channel(None)
|
|
||||||
.await
|
|
||||||
.expect("Failed to open RabbitMQ channel");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn configure_channels(&mut self) -> revolt_result::Result<()> {
|
|
||||||
let config = revolt_config::config().await;
|
|
||||||
|
|
||||||
if !self.channel.is_open() {
|
|
||||||
self.repoen_channel().await;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.channel
|
|
||||||
.exchange_declare(
|
.exchange_declare(
|
||||||
ExchangeDeclareArguments::new(
|
ExchangeDeclareArguments::new(&config.pushd.exchange, "direct")
|
||||||
&config.rabbit.default_exchange,
|
.durable(true)
|
||||||
&ExchangeType::Topic.to_string(),
|
.finish(),
|
||||||
)
|
|
||||||
.durable(true)
|
|
||||||
.finish(),
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to declare exchange");
|
.expect("Failed to declare exchange");
|
||||||
|
|
||||||
// Configure acks channel & routing
|
AMQP::new(connection, channel)
|
||||||
self.channel
|
|
||||||
.queue_declare(
|
|
||||||
QueueDeclareArguments::new(&config.rabbit.queues.acks)
|
|
||||||
.durable(true)
|
|
||||||
.no_wait(true)
|
|
||||||
.finish(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.expect("Failed to bind queue");
|
|
||||||
|
|
||||||
self.channel
|
|
||||||
.queue_bind(QueueBindArguments::new(
|
|
||||||
&config.rabbit.queues.acks,
|
|
||||||
&config.rabbit.default_exchange,
|
|
||||||
&config.rabbit.queues.acks,
|
|
||||||
))
|
|
||||||
.await
|
|
||||||
.expect("Failed to bind channel");
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn friend_request_accepted(
|
pub async fn friend_request_accepted(
|
||||||
@@ -277,9 +232,7 @@ impl AMQP {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Sends an ack to pushd to update badges on iPhones.
|
pub async fn ack_message(
|
||||||
/// Not to be confused with the process_ack function, which handles sending all acks to crond for processing.
|
|
||||||
pub async fn ack_notification_message(
|
|
||||||
&self,
|
&self,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
channel_id: String,
|
channel_id: String,
|
||||||
@@ -363,41 +316,4 @@ impl AMQP {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Send an ack to crond for processing
|
|
||||||
pub async fn process_ack(
|
|
||||||
&self,
|
|
||||||
user_id: &str,
|
|
||||||
channel_id: Option<&str>,
|
|
||||||
server_id: Option<&str>,
|
|
||||||
) -> Result<(), AMQPError> {
|
|
||||||
let config = revolt_config::config().await;
|
|
||||||
|
|
||||||
let payload = AckEventPayload {
|
|
||||||
user_id: user_id.to_string(),
|
|
||||||
channel_id: channel_id.map(|value| value.to_string()),
|
|
||||||
server_id: server_id.map(|value| value.to_string()),
|
|
||||||
};
|
|
||||||
let payload = to_string(&payload).unwrap();
|
|
||||||
|
|
||||||
info!(
|
|
||||||
"Sending ack processor event on exchange {}, channel {}: {}",
|
|
||||||
config.rabbit.default_exchange, config.rabbit.queues.acks, payload
|
|
||||||
);
|
|
||||||
|
|
||||||
self.channel
|
|
||||||
.basic_publish(
|
|
||||||
BasicProperties::default()
|
|
||||||
.with_content_type("application/json")
|
|
||||||
.with_persistence(true)
|
|
||||||
//.with_headers(headers)
|
|
||||||
.finish(),
|
|
||||||
payload.into(),
|
|
||||||
BasicPublishArguments::new(
|
|
||||||
&config.rabbit.default_exchange,
|
|
||||||
&config.rabbit.queues.acks,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ use revolt_result::Error;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use revolt_models::v0::{
|
use revolt_models::v0::{
|
||||||
AppendMessage, Channel, ChannelUnread, ChannelVoiceState, Emoji, FieldsChannel, FieldsMember, FieldsMessage, FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message, PartialChannel, PartialEmoji, PartialMember, PartialMessage, PartialRole, PartialServer, PartialUser, PartialUserVoiceState, PartialWebhook, PolicyChange, RemovalIntention, Report, Server, User, UserSettings, UserVoiceState, Webhook
|
AppendMessage, Channel, ChannelUnread, ChannelVoiceState, Emoji, FieldsChannel, FieldsMember, FieldsMessage, FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message, PartialChannel, PartialMember, PartialMessage, PartialRole, PartialServer, PartialUser, PartialUserVoiceState, PartialWebhook, PolicyChange, RemovalIntention, Report, Server, User, UserSettings, UserVoiceState, Webhook
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Database;
|
use crate::Database;
|
||||||
@@ -219,12 +219,6 @@ pub enum EventV1 {
|
|||||||
/// New emoji
|
/// New emoji
|
||||||
EmojiCreate(Emoji),
|
EmojiCreate(Emoji),
|
||||||
|
|
||||||
/// Update existing emoji
|
|
||||||
EmojiUpdate {
|
|
||||||
id: String,
|
|
||||||
data: PartialEmoji,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Delete emoji
|
/// Delete emoji
|
||||||
EmojiDelete { id: String },
|
EmojiDelete { id: String },
|
||||||
|
|
||||||
|
|||||||
@@ -78,11 +78,3 @@ pub struct AckPayload {
|
|||||||
pub channel_id: String,
|
pub channel_id: String,
|
||||||
pub message_id: String,
|
pub message_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is not the same as the AckPayload above, as the state for this event is stored in redis to allow for state updates while the event is queued.
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
pub struct AckEventPayload {
|
|
||||||
pub user_id: String,
|
|
||||||
pub channel_id: Option<String>,
|
|
||||||
pub server_id: Option<String>,
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#![allow(deprecated)]
|
#![allow(deprecated)]
|
||||||
use std::{borrow::Cow, collections::HashMap};
|
use std::{borrow::Cow, collections::HashMap};
|
||||||
|
|
||||||
use redis_kiss::get_connection;
|
|
||||||
use revolt_config::config;
|
use revolt_config::config;
|
||||||
use revolt_models::v0::{self, MessageAuthor};
|
use revolt_models::v0::{self, MessageAuthor};
|
||||||
use revolt_permissions::OverrideField;
|
use revolt_permissions::OverrideField;
|
||||||
@@ -111,10 +110,6 @@ auto_derived!(
|
|||||||
/// Voice Information for when this channel is also a voice channel
|
/// Voice Information for when this channel is also a voice channel
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
voice: Option<VoiceInformation>,
|
voice: Option<VoiceInformation>,
|
||||||
|
|
||||||
/// The channel's slowmode delay in seconds
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
slowmode: Option<u64>,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,8 +146,6 @@ auto_derived!(
|
|||||||
pub last_message_id: Option<String>,
|
pub last_message_id: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub voice: Option<VoiceInformation>,
|
pub voice: Option<VoiceInformation>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub slowmode: Option<u64>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optional fields on channel object
|
/// Optional fields on channel object
|
||||||
@@ -213,7 +206,6 @@ impl Channel {
|
|||||||
role_permissions: HashMap::new(),
|
role_permissions: HashMap::new(),
|
||||||
nsfw: data.nsfw.unwrap_or(false),
|
nsfw: data.nsfw.unwrap_or(false),
|
||||||
voice: data.voice.map(|voice| voice.into()),
|
voice: data.voice.map(|voice| voice.into()),
|
||||||
slowmode: None,
|
|
||||||
},
|
},
|
||||||
v0::LegacyServerChannelType::Voice => Channel::TextChannel {
|
v0::LegacyServerChannelType::Voice => Channel::TextChannel {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
@@ -226,7 +218,6 @@ impl Channel {
|
|||||||
role_permissions: HashMap::new(),
|
role_permissions: HashMap::new(),
|
||||||
nsfw: data.nsfw.unwrap_or(false),
|
nsfw: data.nsfw.unwrap_or(false),
|
||||||
voice: Some(data.voice.unwrap_or_default().into()),
|
voice: Some(data.voice.unwrap_or_default().into()),
|
||||||
slowmode: None,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -644,7 +635,7 @@ impl Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Acknowledge a message
|
/// Acknowledge a message
|
||||||
pub async fn ack(&self, user: &str, message: &str, amqp: &AMQP) -> Result<()> {
|
pub async fn ack(&self, user: &str, message: &str) -> Result<()> {
|
||||||
EventV1::ChannelAck {
|
EventV1::ChannelAck {
|
||||||
id: self.id().to_string(),
|
id: self.id().to_string(),
|
||||||
user: user.to_string(),
|
user: user.to_string(),
|
||||||
@@ -653,7 +644,17 @@ impl Channel {
|
|||||||
.private(user.to_string())
|
.private(user.to_string())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
crate::util::acker::ack_channel(user, self.id(), message, amqp).await
|
#[cfg(feature = "tasks")]
|
||||||
|
crate::tasks::ack::queue_ack(
|
||||||
|
self.id().to_string(),
|
||||||
|
user.to_string(),
|
||||||
|
crate::tasks::ack::AckEvent::AckMessage {
|
||||||
|
id: message.to_string(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove user from a group
|
/// Remove user from a group
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use std::collections::HashSet;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use revolt_models::v0;
|
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
|
|
||||||
@@ -42,12 +41,6 @@ auto_derived!(
|
|||||||
Server { id: String },
|
Server { id: String },
|
||||||
Detached,
|
Detached,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Partial representation of an emoji
|
|
||||||
pub struct PartialEmoji {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub name: Option<String>,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
#[allow(clippy::disallowed_methods)]
|
#[allow(clippy::disallowed_methods)]
|
||||||
@@ -82,26 +75,6 @@ impl Emoji {
|
|||||||
db.detach_emoji(&self).await
|
db.detach_emoji(&self).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update an emoji
|
|
||||||
pub async fn update(&mut self, db: &Database, partial: PartialEmoji) -> Result<()> {
|
|
||||||
if let Some(name) = partial.name.clone() {
|
|
||||||
self.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.update_emoji(&self.id, &partial).await?;
|
|
||||||
|
|
||||||
EventV1::EmojiUpdate {
|
|
||||||
id: self.id.clone(),
|
|
||||||
data: v0::PartialEmoji {
|
|
||||||
name: partial.name.clone(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
.p(self.parent().to_string())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check whether we can use a given emoji
|
/// Check whether we can use a given emoji
|
||||||
pub async fn can_use(db: &Database, emoji: &str) -> Result<bool> {
|
pub async fn can_use(db: &Database, emoji: &str) -> Result<bool> {
|
||||||
if Ulid::from_str(emoji).is_ok() {
|
if Ulid::from_str(emoji).is_ok() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{Emoji, PartialEmoji};
|
use crate::Emoji;
|
||||||
|
|
||||||
#[cfg(feature = "mongodb")]
|
#[cfg(feature = "mongodb")]
|
||||||
mod mongodb;
|
mod mongodb;
|
||||||
@@ -20,9 +20,6 @@ pub trait AbstractEmojis: Sync + Send {
|
|||||||
/// Fetch emoji by their parent ids
|
/// Fetch emoji by their parent ids
|
||||||
async fn fetch_emoji_by_parent_ids(&self, parent_ids: &[String]) -> Result<Vec<Emoji>>;
|
async fn fetch_emoji_by_parent_ids(&self, parent_ids: &[String]) -> Result<Vec<Emoji>>;
|
||||||
|
|
||||||
/// Update emoji with new information
|
|
||||||
async fn update_emoji(&self, emoji_id: &str, partial: &PartialEmoji) -> Result<()>;
|
|
||||||
|
|
||||||
/// Detach an emoji by its id
|
/// Detach an emoji by its id
|
||||||
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()>;
|
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()>;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use bson::Document;
|
use bson::Document;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{Emoji, PartialEmoji};
|
use crate::Emoji;
|
||||||
use crate::MongoDb;
|
use crate::MongoDb;
|
||||||
|
|
||||||
use super::AbstractEmojis;
|
use super::AbstractEmojis;
|
||||||
@@ -46,11 +46,6 @@ impl AbstractEmojis for MongoDb {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update emoji with new information
|
|
||||||
async fn update_emoji(&self, emoji_id: &str, partial: &PartialEmoji) -> Result<()> {
|
|
||||||
query!(self, update_one_by_id, COL, emoji_id, partial, vec![], None).map(|_| ())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Detach an emoji by its id
|
/// Detach an emoji by its id
|
||||||
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
||||||
self.col::<Document>(COL)
|
self.col::<Document>(COL)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{Emoji, PartialEmoji};
|
use crate::Emoji;
|
||||||
use crate::EmojiParent;
|
use crate::EmojiParent;
|
||||||
use crate::ReferenceDb;
|
use crate::ReferenceDb;
|
||||||
|
|
||||||
@@ -54,19 +54,6 @@ impl AbstractEmojis for ReferenceDb {
|
|||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update emoji with new information
|
|
||||||
async fn update_emoji(&self, emoji_id: &str, partial: &PartialEmoji) -> Result<()> {
|
|
||||||
let mut emojis = self.emojis.lock().await;
|
|
||||||
if let Some(emoji) = emojis.get_mut(emoji_id) {
|
|
||||||
if let Some(name) = partial.name.clone() {
|
|
||||||
emoji.name = name;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(create_error!(NotFound))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Detach an emoji by its id
|
/// Detach an emoji by its id
|
||||||
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
||||||
let mut emojis = self.emojis.lock().await;
|
let mut emojis = self.emojis.lock().await;
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -45,8 +45,7 @@ auto_derived!(
|
|||||||
Image {
|
Image {
|
||||||
width: isize,
|
width: isize,
|
||||||
height: isize,
|
height: isize,
|
||||||
thumbhash: Option<Vec<u8>>,
|
// animated: bool // TODO: https://docs.rs/image/latest/image/trait.AnimationDecoder.html for APNG support
|
||||||
animated: Option<bool>,
|
|
||||||
},
|
},
|
||||||
/// File is a video with specific dimensions
|
/// File is a video with specific dimensions
|
||||||
Video { width: isize, height: isize },
|
Video { width: isize, height: isize },
|
||||||
|
|||||||
@@ -17,12 +17,6 @@ pub trait AbstractAttachmentHashes: Sync + Send {
|
|||||||
/// Update an attachment hash nonce value.
|
/// Update an attachment hash nonce value.
|
||||||
async fn set_attachment_hash_nonce(&self, hash: &str, nonce: &str) -> Result<()>;
|
async fn set_attachment_hash_nonce(&self, hash: &str, nonce: &str) -> Result<()>;
|
||||||
|
|
||||||
/// Updates the attachments animated metadata value.
|
|
||||||
///
|
|
||||||
/// The primary use for this is to update the metadata for existing uploaded files, this
|
|
||||||
/// can only be used for images.
|
|
||||||
async fn set_attachment_hash_animated(&self, hash: &str, animated: bool) -> Result<()>;
|
|
||||||
|
|
||||||
/// Delete attachment hash by id.
|
/// Delete attachment hash by id.
|
||||||
async fn delete_attachment_hash(&self, id: &str) -> Result<()>;
|
async fn delete_attachment_hash(&self, id: &str) -> Result<()>;
|
||||||
}
|
}
|
||||||
@@ -48,29 +48,6 @@ impl AbstractAttachmentHashes for MongoDb {
|
|||||||
.map_err(|_| create_database_error!("update_one", COL))
|
.map_err(|_| create_database_error!("update_one", COL))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the attachments animated metadata value.
|
|
||||||
///
|
|
||||||
/// The primary use for this is to update the metadata for existing uploaded files, this
|
|
||||||
/// can only be used for images.
|
|
||||||
async fn set_attachment_hash_animated(&self, hash: &str, animated: bool) -> Result<()> {
|
|
||||||
self.col::<FileHash>(COL)
|
|
||||||
.update_one(
|
|
||||||
doc! {
|
|
||||||
"_id": hash,
|
|
||||||
"metadata.type": "Image",
|
|
||||||
"metadata.animated": { "$exists": false },
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$set": {
|
|
||||||
"metadata.animated": animated
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|_| create_database_error!("update_one", COL))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Delete attachment hash by id.
|
/// Delete attachment hash by id.
|
||||||
async fn delete_attachment_hash(&self, id: &str) -> Result<()> {
|
async fn delete_attachment_hash(&self, id: &str) -> Result<()> {
|
||||||
query!(self, delete_one_by_id, COL, id).map(|_| ())
|
query!(self, delete_one_by_id, COL, id).map(|_| ())
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{FileHash, Metadata, ReferenceDb};
|
use crate::FileHash;
|
||||||
|
use crate::ReferenceDb;
|
||||||
|
|
||||||
use super::AbstractAttachmentHashes;
|
use super::AbstractAttachmentHashes;
|
||||||
|
|
||||||
@@ -38,29 +39,6 @@ impl AbstractAttachmentHashes for ReferenceDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the attachments animated metadata value.
|
|
||||||
///
|
|
||||||
/// The primary use for this is to update the metadata for existing uploaded files, this
|
|
||||||
/// can only be used for images.
|
|
||||||
async fn set_attachment_hash_animated(&self, hash: &str, animated: bool) -> Result<()> {
|
|
||||||
let mut hashes = self.file_hashes.lock().await;
|
|
||||||
if let Some(FileHash {
|
|
||||||
metadata:
|
|
||||||
Metadata::Image {
|
|
||||||
animated: Some(animated_metadata),
|
|
||||||
..
|
|
||||||
},
|
|
||||||
..
|
|
||||||
}) = hashes.get_mut(hash)
|
|
||||||
{
|
|
||||||
*animated_metadata = animated;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(create_error!(NotFound))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Delete attachment hash by id.
|
/// Delete attachment hash by id.
|
||||||
async fn delete_attachment_hash(&self, id: &str) -> Result<()> {
|
async fn delete_attachment_hash(&self, id: &str) -> Result<()> {
|
||||||
let mut file_hashes = self.file_hashes.lock().await;
|
let mut file_hashes = self.file_hashes.lock().await;
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ auto_derived!(
|
|||||||
LegacyGroupIcon,
|
LegacyGroupIcon,
|
||||||
ChannelIcon,
|
ChannelIcon,
|
||||||
ServerIcon,
|
ServerIcon,
|
||||||
RoleIcon,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about what the file was used for
|
/// Information about what the file was used for
|
||||||
@@ -240,23 +239,4 @@ impl File {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use a file for a role icon
|
|
||||||
pub async fn use_role_icon(
|
|
||||||
db: &Database,
|
|
||||||
id: &str,
|
|
||||||
parent: &str,
|
|
||||||
uploader_id: &str,
|
|
||||||
) -> Result<File> {
|
|
||||||
db.find_and_use_attachment(
|
|
||||||
id,
|
|
||||||
"icons",
|
|
||||||
FileUsedFor {
|
|
||||||
id: parent.to_owned(),
|
|
||||||
object_type: FileUsedForType::RoleIcon,
|
|
||||||
},
|
|
||||||
uploader_id.to_owned(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::{collections::HashSet, hash::RandomState};
|
||||||
|
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::{IndexMap, IndexSet};
|
||||||
use iso8601_timestamp::Timestamp;
|
use iso8601_timestamp::Timestamp;
|
||||||
use revolt_config::{config, FeaturesLimits};
|
use revolt_config::{config, FeaturesLimits};
|
||||||
@@ -7,8 +9,6 @@ use revolt_models::v0::{
|
|||||||
};
|
};
|
||||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission, PermissionValue};
|
use revolt_permissions::{calculate_channel_permissions, ChannelPermission, PermissionValue};
|
||||||
use revolt_result::{ErrorType, Result};
|
use revolt_result::{ErrorType, Result};
|
||||||
use std::time::SystemTime;
|
|
||||||
use std::{collections::HashSet, hash::RandomState};
|
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
|
|
||||||
@@ -388,7 +388,6 @@ impl Message {
|
|||||||
mut role_mentions,
|
mut role_mentions,
|
||||||
mut mentions_everyone,
|
mut mentions_everyone,
|
||||||
mut mentions_online,
|
mut mentions_online,
|
||||||
..
|
|
||||||
} = message_mentions;
|
} = message_mentions;
|
||||||
|
|
||||||
if allow_mass_mentions && server_id.is_some() && !role_mentions.is_empty() {
|
if allow_mass_mentions && server_id.is_some() && !role_mentions.is_empty() {
|
||||||
@@ -498,7 +497,7 @@ impl Message {
|
|||||||
user_mentions.retain(|m| recipients_hash.contains(m));
|
user_mentions.retain(|m| recipients_hash.contains(m));
|
||||||
role_mentions.clear();
|
role_mentions.clear();
|
||||||
}
|
}
|
||||||
Channel::TextChannel { ref server, .. } => {
|
Channel::TextChannel { ref server, .. }=> {
|
||||||
let mentions_vec = Vec::from_iter(user_mentions.iter().cloned());
|
let mentions_vec = Vec::from_iter(user_mentions.iter().cloned());
|
||||||
|
|
||||||
let valid_members = db.fetch_members(server.as_str(), &mentions_vec[..]).await;
|
let valid_members = db.fetch_members(server.as_str(), &mentions_vec[..]).await;
|
||||||
@@ -688,13 +687,8 @@ impl Message {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let is_dm_or_group = matches!(
|
|
||||||
channel,
|
|
||||||
Channel::DirectMessage { .. } | Channel::Group { .. }
|
|
||||||
);
|
|
||||||
|
|
||||||
if !self.has_suppressed_notifications()
|
if !self.has_suppressed_notifications()
|
||||||
&& (is_dm_or_group || self.mentions.is_some() || self.contains_mass_push_mention())
|
&& (self.mentions.is_some() || self.contains_mass_push_mention())
|
||||||
{
|
{
|
||||||
// send Push notifications
|
// send Push notifications
|
||||||
#[cfg(feature = "tasks")]
|
#[cfg(feature = "tasks")]
|
||||||
@@ -705,7 +699,7 @@ impl Message {
|
|||||||
Some(
|
Some(
|
||||||
PushNotification::from(
|
PushNotification::from(
|
||||||
self.clone().into_model(user, member),
|
self.clone().into_model(user, member),
|
||||||
Some(author.clone()),
|
Some(author),
|
||||||
channel.to_owned().into(),
|
channel.to_owned().into(),
|
||||||
)
|
)
|
||||||
.await,
|
.await,
|
||||||
@@ -713,11 +707,7 @@ impl Message {
|
|||||||
self.clone(),
|
self.clone(),
|
||||||
match channel {
|
match channel {
|
||||||
Channel::DirectMessage { recipients, .. }
|
Channel::DirectMessage { recipients, .. }
|
||||||
| Channel::Group { recipients, .. } => recipients
|
| Channel::Group { recipients, .. } => recipients.clone(),
|
||||||
.iter()
|
|
||||||
.filter(|uid| *uid != author.id())
|
|
||||||
.cloned()
|
|
||||||
.collect(),
|
|
||||||
Channel::TextChannel { .. } => {
|
Channel::TextChannel { .. } => {
|
||||||
self.mentions.clone().unwrap_or_default()
|
self.mentions.clone().unwrap_or_default()
|
||||||
}
|
}
|
||||||
@@ -1039,31 +1029,6 @@ impl Message {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bulk delete messages by an author since a given time
|
|
||||||
pub async fn bulk_delete_by_author_since(
|
|
||||||
db: &Database,
|
|
||||||
channels: &[String],
|
|
||||||
author: &str,
|
|
||||||
since: SystemTime,
|
|
||||||
) -> Result<()> {
|
|
||||||
let deleted_groups = db
|
|
||||||
.delete_messages_by_author_since(channels, author, since)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
for (channel_id, message_ids) in deleted_groups {
|
|
||||||
if !message_ids.is_empty() {
|
|
||||||
EventV1::BulkMessageDelete {
|
|
||||||
channel: channel_id.clone(),
|
|
||||||
ids: message_ids,
|
|
||||||
}
|
|
||||||
.p(channel_id)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove a reaction from a message
|
/// Remove a reaction from a message
|
||||||
pub async fn remove_reaction(&self, db: &Database, user: &str, emoji: &str) -> Result<()> {
|
pub async fn remove_reaction(&self, db: &Database, user: &str, emoji: &str) -> Result<()> {
|
||||||
// Check if it actually exists
|
// Check if it actually exists
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
use std::time::SystemTime;
|
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{AppendMessage, FieldsMessage, Message, MessageQuery, PartialMessage};
|
use crate::{AppendMessage, FieldsMessage, Message, MessageQuery, PartialMessage};
|
||||||
@@ -42,12 +40,4 @@ pub trait AbstractMessages: Sync + Send {
|
|||||||
|
|
||||||
/// Delete messages from a channel by their ids and corresponding channel id
|
/// Delete messages from a channel by their ids and corresponding channel id
|
||||||
async fn delete_messages(&self, channel: &str, ids: &[String]) -> Result<()>;
|
async fn delete_messages(&self, channel: &str, ids: &[String]) -> Result<()>;
|
||||||
|
|
||||||
/// Delete all messages from a specific author in a server from a certain ULID onwards
|
|
||||||
async fn delete_messages_by_author_since(
|
|
||||||
&self,
|
|
||||||
channels: &[String],
|
|
||||||
author: &str,
|
|
||||||
since: SystemTime
|
|
||||||
) -> Result<HashMap<String, Vec<String>>>;
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
use bson::{to_bson, Document};
|
use bson::{to_bson, Document};
|
||||||
use futures::try_join;
|
use futures::try_join;
|
||||||
use futures::StreamExt;
|
|
||||||
use mongodb::options::FindOptions;
|
use mongodb::options::FindOptions;
|
||||||
use revolt_models::v0::MessageSort;
|
use revolt_models::v0::MessageSort;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
use std::time::SystemTime;
|
|
||||||
use ulid::Ulid;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
AppendMessage, DocumentId, FieldsMessage, IntoDocumentPath, Message, MessageQuery,
|
AppendMessage, DocumentId, FieldsMessage, IntoDocumentPath, Message, MessageQuery,
|
||||||
@@ -310,112 +306,6 @@ impl AbstractMessages for MongoDb {
|
|||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| create_database_error!("delete_many", COL))
|
.map_err(|_| create_database_error!("delete_many", COL))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delete all messages from a specific author in a server from a certain ULID onwards
|
|
||||||
async fn delete_messages_by_author_since(
|
|
||||||
&self,
|
|
||||||
channels: &[String],
|
|
||||||
author: &str,
|
|
||||||
since: SystemTime,
|
|
||||||
) -> Result<HashMap<String, Vec<String>>> {
|
|
||||||
let threshold_ulid = Ulid::from_datetime(since).to_string();
|
|
||||||
|
|
||||||
let filter = doc! {
|
|
||||||
"author": author,
|
|
||||||
"channel": { "$in": channels },
|
|
||||||
"_id": { "$gte": &threshold_ulid }
|
|
||||||
};
|
|
||||||
|
|
||||||
let pipeline = vec![
|
|
||||||
doc! { "$match": filter.clone() },
|
|
||||||
doc! {
|
|
||||||
"$project": {
|
|
||||||
"channel": 1_i32,
|
|
||||||
"message_id": "$_id",
|
|
||||||
"attachment_ids": {
|
|
||||||
"$map": {
|
|
||||||
"input": { "$ifNull": ["$attachments", Vec::<bson::Bson>::new()] },
|
|
||||||
"as": "a",
|
|
||||||
"in": "$$a._id"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$group": {
|
|
||||||
"_id": "$channel",
|
|
||||||
"message_ids": { "$push": "$message_id" },
|
|
||||||
"attachment_ids_nested": { "$push": "$attachment_ids" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$project": {
|
|
||||||
"message_ids": 1_i32,
|
|
||||||
"attachment_ids": {
|
|
||||||
"$reduce": {
|
|
||||||
"input": "$attachment_ids_nested",
|
|
||||||
"initialValue": Vec::<bson::Bson>::new(),
|
|
||||||
"in": { "$setUnion": ["$$value", "$$this"] }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
struct AggregatedChannel {
|
|
||||||
#[serde(rename = "_id")]
|
|
||||||
channel: String,
|
|
||||||
message_ids: Vec<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
attachment_ids: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut cursor = self
|
|
||||||
.col::<Document>(COL)
|
|
||||||
.aggregate(pipeline)
|
|
||||||
.await
|
|
||||||
.map_err(|_| create_database_error!("aggregate", COL))?
|
|
||||||
.with_type::<AggregatedChannel>();
|
|
||||||
|
|
||||||
let mut deleted_messages: HashMap<String, Vec<String>> = HashMap::new();
|
|
||||||
let mut attachment_ids: HashSet<String> = HashSet::new();
|
|
||||||
|
|
||||||
while let Some(result) = cursor.next().await {
|
|
||||||
if let Ok(item) = result {
|
|
||||||
for id in item.attachment_ids {
|
|
||||||
attachment_ids.insert(id);
|
|
||||||
}
|
|
||||||
deleted_messages.insert(item.channel, item.message_ids);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark attachments as deleted before deleting messages
|
|
||||||
if !attachment_ids.is_empty() {
|
|
||||||
self.col::<Document>("attachments")
|
|
||||||
.update_many(
|
|
||||||
doc! {
|
|
||||||
"_id": {
|
|
||||||
"$in": attachment_ids.into_iter().collect::<Vec<String>>()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$set": {
|
|
||||||
"deleted": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|_| create_database_error!("update_many", "attachments"))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.col::<Document>(COL)
|
|
||||||
.delete_many(filter)
|
|
||||||
.await
|
|
||||||
.map_err(|_| create_database_error!("delete_many", COL))?;
|
|
||||||
|
|
||||||
Ok(deleted_messages)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDocumentPath for FieldsMessage {
|
impl IntoDocumentPath for FieldsMessage {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
use futures::future::try_join_all;
|
use futures::future::try_join_all;
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
use std::time::SystemTime;
|
|
||||||
use ulid::Ulid;
|
|
||||||
use crate::{AppendMessage, FieldsMessage, Message, MessageQuery, PartialMessage, ReferenceDb};
|
use crate::{AppendMessage, FieldsMessage, Message, MessageQuery, PartialMessage, ReferenceDb};
|
||||||
|
|
||||||
use super::AbstractMessages;
|
use super::AbstractMessages;
|
||||||
@@ -249,7 +247,7 @@ impl AbstractMessages for ReferenceDb {
|
|||||||
let mut messages = self.messages.lock().await;
|
let mut messages = self.messages.lock().await;
|
||||||
if let Some(message) = messages.get_mut(id) {
|
if let Some(message) = messages.get_mut(id) {
|
||||||
if let Some(users) = message.reactions.get_mut(emoji) {
|
if let Some(users) = message.reactions.get_mut(emoji) {
|
||||||
users.swap_remove(&user.to_string());
|
users.remove(&user.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -262,7 +260,7 @@ impl AbstractMessages for ReferenceDb {
|
|||||||
async fn clear_reaction(&self, id: &str, emoji: &str) -> Result<()> {
|
async fn clear_reaction(&self, id: &str, emoji: &str) -> Result<()> {
|
||||||
let mut messages = self.messages.lock().await;
|
let mut messages = self.messages.lock().await;
|
||||||
if let Some(message) = messages.get_mut(id) {
|
if let Some(message) = messages.get_mut(id) {
|
||||||
message.reactions.swap_remove(emoji);
|
message.reactions.remove(emoji);
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(create_error!(NotFound))
|
Err(create_error!(NotFound))
|
||||||
@@ -288,63 +286,4 @@ impl AbstractMessages for ReferenceDb {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delete all messages from a specific author in a list of channels from a certain ULID onwards
|
|
||||||
async fn delete_messages_by_author_since(
|
|
||||||
&self,
|
|
||||||
channels: &[String],
|
|
||||||
author: &str,
|
|
||||||
since: SystemTime
|
|
||||||
) -> Result<HashMap<String, Vec<String>>> {
|
|
||||||
let threshold_ulid = Ulid::from_datetime(since).to_string();
|
|
||||||
let mut deleted_messages: HashMap<String, Vec<String>> = HashMap::new();
|
|
||||||
let mut attachment_ids: Vec<String> = Vec::new();
|
|
||||||
|
|
||||||
let messages = self.messages.lock().await;
|
|
||||||
|
|
||||||
// First pass: collect attachment IDs and message IDs to delete
|
|
||||||
for (id, message) in messages.iter() {
|
|
||||||
let should_delete = message.author == author
|
|
||||||
&& channels.contains(&message.channel)
|
|
||||||
&& id.as_str() >= threshold_ulid.as_str();
|
|
||||||
|
|
||||||
if should_delete {
|
|
||||||
// Collect attachment IDs
|
|
||||||
if let Some(attachments) = &message.attachments {
|
|
||||||
for attachment in attachments {
|
|
||||||
attachment_ids.push(attachment.id.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deleted_messages
|
|
||||||
.entry(message.channel.clone())
|
|
||||||
.or_default()
|
|
||||||
.push(id.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
drop(messages);
|
|
||||||
|
|
||||||
// Mark attachments as deleted
|
|
||||||
if !attachment_ids.is_empty() {
|
|
||||||
let mut files = self.files.lock().await;
|
|
||||||
for attachment_id in attachment_ids {
|
|
||||||
if let Some(file) = files.get_mut(&attachment_id) {
|
|
||||||
file.deleted = Some(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the messages
|
|
||||||
self.messages
|
|
||||||
.lock()
|
|
||||||
.await
|
|
||||||
.retain(|id, message| {
|
|
||||||
let should_keep = !(message.author == author
|
|
||||||
&& channels.contains(&message.channel)
|
|
||||||
&& id.as_str() >= threshold_ulid.as_str());
|
|
||||||
should_keep
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(deleted_messages)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,7 @@ auto_derived_partial!(
|
|||||||
/// Whether the member is server-wide voice deafened
|
/// Whether the member is server-wide voice deafened
|
||||||
#[serde(skip_serializing_if = "is_true", default = "default_true")]
|
#[serde(skip_serializing_if = "is_true", default = "default_true")]
|
||||||
pub can_receive: bool,
|
pub can_receive: bool,
|
||||||
|
|
||||||
// This value only exists in the database, not the models.
|
// This value only exists in the database, not the models.
|
||||||
// If it is not-None, the database layer should return None to member fetching queries.
|
// If it is not-None, the database layer should return None to member fetching queries.
|
||||||
// pub pending_deletion_at: Option<Timestamp>
|
// pub pending_deletion_at: Option<Timestamp>
|
||||||
@@ -152,11 +153,7 @@ impl Member {
|
|||||||
|
|
||||||
#[cfg(feature = "voice")]
|
#[cfg(feature = "voice")]
|
||||||
for channel in &channels {
|
for channel in &channels {
|
||||||
if let Ok(Some(voice_state)) = crate::voice::get_channel_voice_state(
|
if let Ok(Some(voice_state)) = crate::voice::get_channel_voice_state(channel).await {
|
||||||
&crate::voice::UserVoiceChannel::from_channel(channel),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
voice_states.push(voice_state)
|
voice_states.push(voice_state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,7 +175,7 @@ impl Member {
|
|||||||
.map(|channel| channel.into())
|
.map(|channel| channel.into())
|
||||||
.collect(),
|
.collect(),
|
||||||
emojis: emojis.into_iter().map(|emoji| emoji.into()).collect(),
|
emojis: emojis.into_iter().map(|emoji| emoji.into()).collect(),
|
||||||
voice_states,
|
voice_states
|
||||||
}
|
}
|
||||||
.private(user.id.clone())
|
.private(user.id.clone())
|
||||||
.await;
|
.await;
|
||||||
@@ -228,14 +225,14 @@ impl Member {
|
|||||||
|
|
||||||
pub fn remove_field(&mut self, field: &FieldsMember) {
|
pub fn remove_field(&mut self, field: &FieldsMember) {
|
||||||
match field {
|
match field {
|
||||||
FieldsMember::JoinedAt => {}
|
FieldsMember::JoinedAt => {},
|
||||||
FieldsMember::Avatar => self.avatar = None,
|
FieldsMember::Avatar => self.avatar = None,
|
||||||
FieldsMember::Nickname => self.nickname = None,
|
FieldsMember::Nickname => self.nickname = None,
|
||||||
FieldsMember::Roles => self.roles.clear(),
|
FieldsMember::Roles => self.roles.clear(),
|
||||||
FieldsMember::Timeout => self.timeout = None,
|
FieldsMember::Timeout => self.timeout = None,
|
||||||
FieldsMember::CanReceive => self.can_receive = true,
|
FieldsMember::CanReceive => self.can_receive = true,
|
||||||
FieldsMember::CanPublish => self.can_publish = true,
|
FieldsMember::CanPublish => self.can_publish = true,
|
||||||
FieldsMember::VoiceChannel => {}
|
FieldsMember::VoiceChannel => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,6 +332,7 @@ mod tests {
|
|||||||
name: "Server".to_string(),
|
name: "Server".to_string(),
|
||||||
description: None,
|
description: None,
|
||||||
nsfw: None,
|
nsfw: None,
|
||||||
|
discord_template_id: None,
|
||||||
},
|
},
|
||||||
&owner,
|
&owner,
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -86,9 +86,6 @@ auto_derived_partial!(
|
|||||||
/// Ranking of this role
|
/// Ranking of this role
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub rank: i64,
|
pub rank: i64,
|
||||||
/// Custom icon attachment
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub icon: Option<File>,
|
|
||||||
},
|
},
|
||||||
"PartialRole"
|
"PartialRole"
|
||||||
);
|
);
|
||||||
@@ -132,7 +129,6 @@ auto_derived!(
|
|||||||
/// Optional fields on server object
|
/// Optional fields on server object
|
||||||
pub enum FieldsRole {
|
pub enum FieldsRole {
|
||||||
Colour,
|
Colour,
|
||||||
Icon,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -309,7 +305,6 @@ impl Role {
|
|||||||
colour: self.colour,
|
colour: self.colour,
|
||||||
hoist: Some(self.hoist),
|
hoist: Some(self.hoist),
|
||||||
rank: Some(self.rank),
|
rank: Some(self.rank),
|
||||||
icon: self.icon,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +318,6 @@ impl Role {
|
|||||||
colour: None,
|
colour: None,
|
||||||
hoist: false,
|
hoist: false,
|
||||||
permissions: Default::default(),
|
permissions: Default::default(),
|
||||||
icon: None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
db.insert_role(&server.id, &role).await?;
|
db.insert_role(&server.id, &role).await?;
|
||||||
@@ -373,7 +367,6 @@ impl Role {
|
|||||||
pub fn remove_field(&mut self, field: &FieldsRole) {
|
pub fn remove_field(&mut self, field: &FieldsRole) {
|
||||||
match field {
|
match field {
|
||||||
FieldsRole::Colour => self.colour = None,
|
FieldsRole::Colour => self.colour = None,
|
||||||
FieldsRole::Icon => self.icon = None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ impl AbstractServers for MongoDb {
|
|||||||
},
|
},
|
||||||
doc! {
|
doc! {
|
||||||
"$set": {
|
"$set": {
|
||||||
"roles.".to_owned() + role.id.as_str(): to_document(role)
|
"roles.".to_owned() + &role.id: to_document(role)
|
||||||
.map_err(|_| create_database_error!("to_document", "role"))?
|
.map_err(|_| create_database_error!("to_document", "role"))?
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -172,7 +172,6 @@ impl IntoDocumentPath for FieldsRole {
|
|||||||
fn as_path(&self) -> Option<&'static str> {
|
fn as_path(&self) -> Option<&'static str> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
FieldsRole::Colour => "colour",
|
FieldsRole::Colour => "colour",
|
||||||
FieldsRole::Icon => "icon",
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use futures::future::join_all;
|
|||||||
use iso8601_timestamp::Timestamp;
|
use iso8601_timestamp::Timestamp;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
use regex::{Regex, RegexBuilder};
|
|
||||||
use revolt_config::{config, FeaturesLimits};
|
use revolt_config::{config, FeaturesLimits};
|
||||||
use revolt_models::v0::{self, UserBadges, UserFlags};
|
use revolt_models::v0::{self, UserBadges, UserFlags};
|
||||||
use revolt_presence::filter_online;
|
use revolt_presence::filter_online;
|
||||||
@@ -164,13 +163,6 @@ pub static DISCRIMINATOR_SEARCH_SPACE: Lazy<HashSet<String>> = Lazy::new(|| {
|
|||||||
set.into_iter().collect()
|
set.into_iter().collect()
|
||||||
});
|
});
|
||||||
|
|
||||||
static BLOCKED_USERNAME_PATTERNS: Lazy<Regex> = Lazy::new(|| {
|
|
||||||
RegexBuilder::new("`{3}|(discord|rvlt|guilded|stt)\\.gg|(revolt|stoat)\\.chat|https?:\\/\\/")
|
|
||||||
.case_insensitive(true)
|
|
||||||
.build()
|
|
||||||
.unwrap()
|
|
||||||
});
|
|
||||||
|
|
||||||
#[allow(clippy::derivable_impls)]
|
#[allow(clippy::derivable_impls)]
|
||||||
impl Default for User {
|
impl Default for User {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -206,13 +198,11 @@ impl User {
|
|||||||
I: Into<Option<String>>,
|
I: Into<Option<String>>,
|
||||||
D: Into<Option<PartialUser>>,
|
D: Into<Option<PartialUser>>,
|
||||||
{
|
{
|
||||||
let new_username = User::sanitise_username(&username).await?;
|
let username = User::validate_username(username)?;
|
||||||
User::validate_username(&new_username)?;
|
|
||||||
|
|
||||||
let mut user = User {
|
let mut user = User {
|
||||||
id: account_id.into().unwrap_or_else(|| Ulid::new().to_string()),
|
id: account_id.into().unwrap_or_else(|| Ulid::new().to_string()),
|
||||||
discriminator: User::find_discriminator(db, &new_username, None).await?,
|
discriminator: User::find_discriminator(db, &username, None).await?,
|
||||||
username: new_username.clone(),
|
username,
|
||||||
last_acknowledged_policy_change: Timestamp::now_utc(),
|
last_acknowledged_policy_change: Timestamp::now_utc(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
@@ -288,40 +278,39 @@ impl User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate a username
|
/// Sanitise and validate a username can be used
|
||||||
///
|
pub fn validate_username(username: String) -> Result<String> {
|
||||||
/// This will check if the username is a blocked name or contains a blocked pattern.
|
// Copy the username for validation
|
||||||
fn validate_username(username: &str) -> Result<()> {
|
|
||||||
let username_lowercase = username.to_lowercase();
|
let username_lowercase = username.to_lowercase();
|
||||||
|
|
||||||
const BLOCKED_USERNAMES: &[&str] = &["admin", "revolt", "stoat"];
|
// Block homoglyphs
|
||||||
|
if decancer::cure(&username_lowercase).into_str() != username_lowercase {
|
||||||
if BLOCKED_USERNAMES.contains(&username_lowercase.as_str())
|
|
||||||
|| BLOCKED_USERNAME_PATTERNS.is_match(username)
|
|
||||||
{
|
|
||||||
return Err(create_error!(InvalidUsername));
|
return Err(create_error!(InvalidUsername));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
// Ensure the username itself isn't blocked
|
||||||
}
|
const BLOCKED_USERNAMES: &[&str] = &["admin", "revolt"];
|
||||||
|
|
||||||
/// Sanitise a username
|
for username in BLOCKED_USERNAMES {
|
||||||
///
|
if username_lowercase == *username {
|
||||||
/// This will clean up Unicode homoglyphs and pad to the min username length with underscores.
|
return Err(create_error!(InvalidUsername));
|
||||||
async fn sanitise_username(username: &str) -> Result<String> {
|
}
|
||||||
let options = decancer::Options::default().retain_capitalization();
|
}
|
||||||
let mut username = decancer::cure(username, options)
|
|
||||||
.map_err(|_| create_error!(InvalidUsername))?
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let config = revolt_config::config().await;
|
// Ensure none of the following substrings show up in the username
|
||||||
let username_length_diff = config
|
const BLOCKED_SUBSTRINGS: &[&str] = &[
|
||||||
.api
|
"```",
|
||||||
.users
|
"discord.gg",
|
||||||
.min_username_length
|
"rvlt.gg",
|
||||||
.saturating_sub(username.len());
|
"guilded.gg",
|
||||||
if username_length_diff > 0 {
|
"https://",
|
||||||
username.push_str(&"_".repeat(username_length_diff))
|
"http://",
|
||||||
|
];
|
||||||
|
|
||||||
|
for substr in BLOCKED_SUBSTRINGS {
|
||||||
|
if username_lowercase.contains(substr) {
|
||||||
|
return Err(create_error!(InvalidUsername));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(username)
|
Ok(username)
|
||||||
@@ -427,14 +416,12 @@ impl User {
|
|||||||
|
|
||||||
/// Update a user's username
|
/// Update a user's username
|
||||||
pub async fn update_username(&mut self, db: &Database, username: String) -> Result<()> {
|
pub async fn update_username(&mut self, db: &Database, username: String) -> Result<()> {
|
||||||
let new_username = User::sanitise_username(&username).await?;
|
let username = User::validate_username(username)?;
|
||||||
User::validate_username(&new_username)?;
|
if self.username.to_lowercase() == username.to_lowercase() {
|
||||||
|
|
||||||
if self.username.to_lowercase() == new_username.to_lowercase() {
|
|
||||||
self.update(
|
self.update(
|
||||||
db,
|
db,
|
||||||
PartialUser {
|
PartialUser {
|
||||||
username: Some(new_username),
|
username: Some(username),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
@@ -447,12 +434,12 @@ impl User {
|
|||||||
discriminator: Some(
|
discriminator: Some(
|
||||||
User::find_discriminator(
|
User::find_discriminator(
|
||||||
db,
|
db,
|
||||||
&new_username,
|
&username,
|
||||||
Some((self.discriminator.to_string(), self.id.clone())),
|
Some((self.discriminator.to_string(), self.id.clone())),
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
),
|
),
|
||||||
username: Some(new_username),
|
username: Some(username),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
@@ -666,14 +653,14 @@ impl User {
|
|||||||
self.apply_options(partial.clone());
|
self.apply_options(partial.clone());
|
||||||
db.update_user(&self.id, &partial, remove.clone()).await?;
|
db.update_user(&self.id, &partial, remove.clone()).await?;
|
||||||
|
|
||||||
EventV1::UserUpdate {
|
// EventV1::UserUpdate {
|
||||||
id: self.id.clone(),
|
// id: self.id.clone(),
|
||||||
data: partial.into(),
|
// data: partial.into(),
|
||||||
clear: remove.into_iter().map(|v| v.into()).collect(),
|
// clear: remove.into_iter().map(|v| v.into()).collect(),
|
||||||
event_id: Some(Ulid::new().to_string()),
|
// event_id: Some(Ulid::new().to_string()),
|
||||||
}
|
// }
|
||||||
.p_user(self.id.clone(), db)
|
// .p_user(self.id.clone(), db)
|
||||||
.await;
|
// .await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -838,109 +825,3 @@ impl User {
|
|||||||
badges
|
badges
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::User;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn username_validation_blocked_names() {
|
|
||||||
let username_admin = "Admin";
|
|
||||||
let username_revolt = "Revolt";
|
|
||||||
let username_stoat = "Stoat";
|
|
||||||
let username_allowed = "Allowed";
|
|
||||||
|
|
||||||
assert!(User::validate_username(username_admin).is_err());
|
|
||||||
assert!(User::validate_username(username_revolt).is_err());
|
|
||||||
assert!(User::validate_username(username_stoat).is_err());
|
|
||||||
assert!(User::validate_username(username_allowed).is_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn username_validation_blocked_patterns() {
|
|
||||||
let username_grave = "```_test";
|
|
||||||
let username_discord = "discord.gg_test";
|
|
||||||
let username_rvlt = "rvlt.gg_test";
|
|
||||||
let username_guilded = "guilded.gg_test";
|
|
||||||
let username_stt = "stt.gg_test";
|
|
||||||
let username_revolt = "revolt.chat_test";
|
|
||||||
let username_stoat = "stoat.chat_test";
|
|
||||||
let username_http = "http://_test";
|
|
||||||
let username_https = "https://_test";
|
|
||||||
|
|
||||||
assert!(User::validate_username(username_grave).is_err());
|
|
||||||
assert!(User::validate_username(username_discord).is_err());
|
|
||||||
assert!(User::validate_username(username_rvlt).is_err());
|
|
||||||
assert!(User::validate_username(username_guilded).is_err());
|
|
||||||
assert!(User::validate_username(username_stt).is_err());
|
|
||||||
assert!(User::validate_username(username_revolt).is_err());
|
|
||||||
assert!(User::validate_username(username_stoat).is_err());
|
|
||||||
assert!(User::validate_username(username_http).is_err());
|
|
||||||
assert!(User::validate_username(username_https).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_std::test]
|
|
||||||
async fn username_sanitisation_clean() {
|
|
||||||
let username_clean = "Test";
|
|
||||||
|
|
||||||
let username_clean_sanitised = User::sanitise_username(username_clean).await;
|
|
||||||
|
|
||||||
assert!(username_clean_sanitised.is_ok());
|
|
||||||
assert_eq!(username_clean, username_clean_sanitised.unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_std::test]
|
|
||||||
async fn username_sanitisation_homoglyphs() {
|
|
||||||
let username_homoglyphs = "𝔽𝕌Ňℕy";
|
|
||||||
|
|
||||||
let username_homoglyphs_sanitised =
|
|
||||||
User::sanitise_username(username_homoglyphs).await.unwrap();
|
|
||||||
|
|
||||||
assert_ne!(username_homoglyphs, username_homoglyphs_sanitised);
|
|
||||||
assert_eq!("funny", username_homoglyphs_sanitised);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_std::test]
|
|
||||||
async fn username_sanitisation_padding() {
|
|
||||||
let username_padding = "a";
|
|
||||||
|
|
||||||
let username = User::sanitise_username(username_padding).await.unwrap();
|
|
||||||
|
|
||||||
assert_eq!("a_", username);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_std::test]
|
|
||||||
async fn create_user() {
|
|
||||||
use revolt_result::Result;
|
|
||||||
|
|
||||||
database_test!(|db| async move {
|
|
||||||
let mut created_clean = User::create(&db, "Test".to_string(), None, None)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!("Test", created_clean.username);
|
|
||||||
|
|
||||||
created_clean
|
|
||||||
.update_username(&db, "Test2".to_string())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!("Test2", created_clean.username);
|
|
||||||
|
|
||||||
let created_invalid_result: Result<_> =
|
|
||||||
User::create(&db, "stoat.chat".to_string(), None, None).await;
|
|
||||||
|
|
||||||
assert!(created_invalid_result.is_err());
|
|
||||||
|
|
||||||
let mut updated_invalid = User::create(&db, "Test".to_string(), None, None)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let updated_invalid_update_result = updated_invalid
|
|
||||||
.update_username(&db, "http://test".to_string())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
assert!(updated_invalid_update_result.is_err());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -105,11 +105,7 @@ pub async fn handle_ack_event(
|
|||||||
|
|
||||||
if mentions_acked > 0 {
|
if mentions_acked > 0 {
|
||||||
if let Err(err) = amqp
|
if let Err(err) = amqp
|
||||||
.ack_notification_message(
|
.ack_message(user.to_string(), channel.to_string(), id.to_owned())
|
||||||
user.to_string(),
|
|
||||||
channel.to_string(),
|
|
||||||
id.to_owned(),
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
revolt_config::capture_error(&err);
|
revolt_config::capture_error(&err);
|
||||||
@@ -196,7 +192,9 @@ pub async fn handle_ack_event(
|
|||||||
.expect("Failed to fetch channel from db");
|
.expect("Failed to fetch channel from db");
|
||||||
|
|
||||||
if let TextChannel { server, .. } = channel {
|
if let TextChannel { server, .. } = channel {
|
||||||
if let Err(err) = amqp.mass_mention_message_sent(server, mass_mentions).await {
|
if let Err(err) =
|
||||||
|
amqp.mass_mention_message_sent(server, mass_mentions).await
|
||||||
|
{
|
||||||
revolt_config::capture_error(&err);
|
revolt_config::capture_error(&err);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
use redis_kiss::{get_connection, AsyncCommands};
|
|
||||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
|
||||||
use revolt_result::{Result, ToRevoltError};
|
|
||||||
|
|
||||||
use crate::{events::client::EventV1, Channel, Database, Server, User, AMQP};
|
|
||||||
|
|
||||||
pub async fn ack_channel(user: &str, channel: &str, message: &str, amqp: &AMQP) -> Result<()> {
|
|
||||||
let mut redis = get_connection()
|
|
||||||
.await
|
|
||||||
.map_err(|_| create_error!(InternalError))?;
|
|
||||||
|
|
||||||
let old: Option<String> = redis
|
|
||||||
.getset(format!("acker:{user}+{channel}"), message)
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
|
|
||||||
if old.is_none() || old.unwrap() == message {
|
|
||||||
amqp.process_ack(user, Some(channel), None)
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn ack_server(user: &User, server: &Server, db: &Database, amqp: &AMQP) -> Result<()> {
|
|
||||||
let mut redis = get_connection()
|
|
||||||
.await
|
|
||||||
.map_err(|_| create_error!(InternalError))?;
|
|
||||||
|
|
||||||
let channels = db.fetch_channels(&server.channels).await?;
|
|
||||||
let query = crate::util::permissions::DatabasePermissionQuery::new(db, user).server(server);
|
|
||||||
|
|
||||||
for channel in channels {
|
|
||||||
let channel_id = channel.id();
|
|
||||||
let mut q = query.clone().channel(&channel);
|
|
||||||
|
|
||||||
if calculate_channel_permissions(&mut q)
|
|
||||||
.await
|
|
||||||
.has_channel_permission(ChannelPermission::ViewChannel)
|
|
||||||
{
|
|
||||||
let channel_last_msg = match &channel {
|
|
||||||
Channel::TextChannel {
|
|
||||||
last_message_id, ..
|
|
||||||
} => last_message_id,
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
.clone();
|
|
||||||
|
|
||||||
if let Some(channel_last_msg) = channel_last_msg {
|
|
||||||
let old: Option<String> = redis
|
|
||||||
.getset(
|
|
||||||
format!("acker:{}+{}", user.id, channel_id),
|
|
||||||
&channel_last_msg,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
|
|
||||||
if old.is_none() || old.unwrap() == channel_last_msg {
|
|
||||||
amqp.process_ack(&user.id, Some(channel_id), Some(&server.id))
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
|
|
||||||
EventV1::ChannelAck {
|
|
||||||
id: channel_id.to_string(),
|
|
||||||
user: user.id.clone(),
|
|
||||||
message_id: channel_last_msg,
|
|
||||||
}
|
|
||||||
.private(user.id.clone())
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
@@ -190,7 +190,6 @@ impl From<crate::Channel> for Channel {
|
|||||||
role_permissions,
|
role_permissions,
|
||||||
nsfw,
|
nsfw,
|
||||||
voice,
|
voice,
|
||||||
slowmode,
|
|
||||||
} => Channel::TextChannel {
|
} => Channel::TextChannel {
|
||||||
id,
|
id,
|
||||||
server,
|
server,
|
||||||
@@ -202,7 +201,6 @@ impl From<crate::Channel> for Channel {
|
|||||||
role_permissions,
|
role_permissions,
|
||||||
nsfw,
|
nsfw,
|
||||||
voice: voice.map(|voice| voice.into()),
|
voice: voice.map(|voice| voice.into()),
|
||||||
slowmode,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,7 +254,6 @@ impl From<Channel> for crate::Channel {
|
|||||||
role_permissions,
|
role_permissions,
|
||||||
nsfw,
|
nsfw,
|
||||||
voice,
|
voice,
|
||||||
slowmode,
|
|
||||||
} => crate::Channel::TextChannel {
|
} => crate::Channel::TextChannel {
|
||||||
id,
|
id,
|
||||||
server,
|
server,
|
||||||
@@ -268,7 +265,6 @@ impl From<Channel> for crate::Channel {
|
|||||||
role_permissions,
|
role_permissions,
|
||||||
nsfw,
|
nsfw,
|
||||||
voice: voice.map(|voice| voice.into()),
|
voice: voice.map(|voice| voice.into()),
|
||||||
slowmode,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,8 +283,7 @@ impl From<crate::PartialChannel> for PartialChannel {
|
|||||||
role_permissions: value.role_permissions,
|
role_permissions: value.role_permissions,
|
||||||
default_permissions: value.default_permissions,
|
default_permissions: value.default_permissions,
|
||||||
last_message_id: value.last_message_id,
|
last_message_id: value.last_message_id,
|
||||||
voice: value.voice.map(|voice| voice.into()),
|
voice: value.voice.map(|voice| voice.into())
|
||||||
slowmode: value.slowmode,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,8 +301,7 @@ impl From<PartialChannel> for crate::PartialChannel {
|
|||||||
role_permissions: value.role_permissions,
|
role_permissions: value.role_permissions,
|
||||||
default_permissions: value.default_permissions,
|
default_permissions: value.default_permissions,
|
||||||
last_message_id: value.last_message_id,
|
last_message_id: value.last_message_id,
|
||||||
voice: value.voice.map(|voice| voice.into()),
|
voice: value.voice.map(|voice| voice.into())
|
||||||
slowmode: value.slowmode,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,16 +406,9 @@ impl From<crate::Metadata> for Metadata {
|
|||||||
match value {
|
match value {
|
||||||
crate::Metadata::File => Metadata::File,
|
crate::Metadata::File => Metadata::File,
|
||||||
crate::Metadata::Text => Metadata::Text,
|
crate::Metadata::Text => Metadata::Text,
|
||||||
crate::Metadata::Image {
|
crate::Metadata::Image { width, height } => Metadata::Image {
|
||||||
width,
|
|
||||||
height,
|
|
||||||
thumbhash,
|
|
||||||
animated,
|
|
||||||
} => Metadata::Image {
|
|
||||||
width: width as usize,
|
width: width as usize,
|
||||||
height: height as usize,
|
height: height as usize,
|
||||||
thumbhash,
|
|
||||||
animated,
|
|
||||||
},
|
},
|
||||||
crate::Metadata::Video { width, height } => Metadata::Video {
|
crate::Metadata::Video { width, height } => Metadata::Video {
|
||||||
width: width as usize,
|
width: width as usize,
|
||||||
@@ -437,16 +424,9 @@ impl From<Metadata> for crate::Metadata {
|
|||||||
match value {
|
match value {
|
||||||
Metadata::File => crate::Metadata::File,
|
Metadata::File => crate::Metadata::File,
|
||||||
Metadata::Text => crate::Metadata::Text,
|
Metadata::Text => crate::Metadata::Text,
|
||||||
Metadata::Image {
|
Metadata::Image { width, height } => crate::Metadata::Image {
|
||||||
width,
|
|
||||||
height,
|
|
||||||
thumbhash,
|
|
||||||
animated,
|
|
||||||
} => crate::Metadata::Image {
|
|
||||||
width: width as isize,
|
width: width as isize,
|
||||||
height: height as isize,
|
height: height as isize,
|
||||||
thumbhash,
|
|
||||||
animated,
|
|
||||||
},
|
},
|
||||||
Metadata::Video { width, height } => crate::Metadata::Video {
|
Metadata::Video { width, height } => crate::Metadata::Video {
|
||||||
width: width as isize,
|
width: width as isize,
|
||||||
@@ -535,9 +515,7 @@ impl From<crate::SystemMessage> for SystemMessage {
|
|||||||
crate::SystemMessage::UserRemove { id, by } => Self::UserRemove { id, by },
|
crate::SystemMessage::UserRemove { id, by } => Self::UserRemove { id, by },
|
||||||
crate::SystemMessage::MessagePinned { id, by } => Self::MessagePinned { id, by },
|
crate::SystemMessage::MessagePinned { id, by } => Self::MessagePinned { id, by },
|
||||||
crate::SystemMessage::MessageUnpinned { id, by } => Self::MessageUnpinned { id, by },
|
crate::SystemMessage::MessageUnpinned { id, by } => Self::MessageUnpinned { id, by },
|
||||||
crate::SystemMessage::CallStarted { by, finished_at } => {
|
crate::SystemMessage::CallStarted { by, finished_at } => Self::CallStarted { by, finished_at }
|
||||||
Self::CallStarted { by, finished_at }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -926,7 +904,6 @@ impl From<crate::Role> for Role {
|
|||||||
colour: value.colour,
|
colour: value.colour,
|
||||||
hoist: value.hoist,
|
hoist: value.hoist,
|
||||||
rank: value.rank,
|
rank: value.rank,
|
||||||
icon: value.icon.map(|f| f.into()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -940,7 +917,6 @@ impl From<Role> for crate::Role {
|
|||||||
colour: value.colour,
|
colour: value.colour,
|
||||||
hoist: value.hoist,
|
hoist: value.hoist,
|
||||||
rank: value.rank,
|
rank: value.rank,
|
||||||
icon: value.icon.map(|f| f.into()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -954,7 +930,6 @@ impl From<crate::PartialRole> for PartialRole {
|
|||||||
colour: value.colour,
|
colour: value.colour,
|
||||||
hoist: value.hoist,
|
hoist: value.hoist,
|
||||||
rank: value.rank,
|
rank: value.rank,
|
||||||
icon: value.icon.map(|f| f.into()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -968,7 +943,6 @@ impl From<PartialRole> for crate::PartialRole {
|
|||||||
colour: value.colour,
|
colour: value.colour,
|
||||||
hoist: value.hoist,
|
hoist: value.hoist,
|
||||||
rank: value.rank,
|
rank: value.rank,
|
||||||
icon: value.icon.map(|f| f.into()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -977,7 +951,6 @@ impl From<crate::FieldsRole> for FieldsRole {
|
|||||||
fn from(value: crate::FieldsRole) -> Self {
|
fn from(value: crate::FieldsRole) -> Self {
|
||||||
match value {
|
match value {
|
||||||
crate::FieldsRole::Colour => FieldsRole::Colour,
|
crate::FieldsRole::Colour => FieldsRole::Colour,
|
||||||
crate::FieldsRole::Icon => FieldsRole::Icon,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -986,7 +959,6 @@ impl From<FieldsRole> for crate::FieldsRole {
|
|||||||
fn from(value: FieldsRole) -> Self {
|
fn from(value: FieldsRole) -> Self {
|
||||||
match value {
|
match value {
|
||||||
FieldsRole::Colour => crate::FieldsRole::Colour,
|
FieldsRole::Colour => crate::FieldsRole::Colour,
|
||||||
FieldsRole::Icon => crate::FieldsRole::Icon,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1410,7 +1382,7 @@ impl From<FieldsMessage> for crate::FieldsMessage {
|
|||||||
impl From<VoiceInformation> for crate::VoiceInformation {
|
impl From<VoiceInformation> for crate::VoiceInformation {
|
||||||
fn from(value: VoiceInformation) -> Self {
|
fn from(value: VoiceInformation) -> Self {
|
||||||
crate::VoiceInformation {
|
crate::VoiceInformation {
|
||||||
max_users: value.max_users,
|
max_users: value.max_users
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1418,7 +1390,7 @@ impl From<VoiceInformation> for crate::VoiceInformation {
|
|||||||
impl From<crate::VoiceInformation> for VoiceInformation {
|
impl From<crate::VoiceInformation> for VoiceInformation {
|
||||||
fn from(value: crate::VoiceInformation) -> Self {
|
fn from(value: crate::VoiceInformation) -> Self {
|
||||||
VoiceInformation {
|
VoiceInformation {
|
||||||
max_users: value.max_users,
|
max_users: value.max_users
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
pub mod acker;
|
|
||||||
pub mod bridge;
|
pub mod bridge;
|
||||||
pub mod bulk_permissions;
|
pub mod bulk_permissions;
|
||||||
mod funcs;
|
mod funcs;
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::fmt::{Display, Write};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::client::EventV1,
|
events::client::EventV1,
|
||||||
models::{Channel, User},
|
models::{Channel, User},
|
||||||
@@ -8,11 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use iso8601_timestamp::{Duration, Timestamp};
|
use iso8601_timestamp::{Duration, Timestamp};
|
||||||
use livekit_protocol::ParticipantPermission;
|
use livekit_protocol::ParticipantPermission;
|
||||||
use redis_kiss::{
|
use redis_kiss::{get_connection as _get_connection, redis::Pipeline, AsyncCommands, Conn};
|
||||||
get_connection as _get_connection,
|
|
||||||
redis::{FromRedisValue, Pipeline, RedisError, RedisWrite, ToRedisArgs, Value},
|
|
||||||
AsyncCommands, Conn,
|
|
||||||
};
|
|
||||||
use revolt_config::FeaturesLimits;
|
use revolt_config::FeaturesLimits;
|
||||||
use revolt_models::v0::{self, PartialUserVoiceState, UserVoiceState};
|
use revolt_models::v0::{self, PartialUserVoiceState, UserVoiceState};
|
||||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission, PermissionValue};
|
use revolt_permissions::{calculate_channel_permissions, ChannelPermission, PermissionValue};
|
||||||
@@ -22,18 +16,16 @@ mod voice_client;
|
|||||||
pub use voice_client::VoiceClient;
|
pub use voice_client::VoiceClient;
|
||||||
|
|
||||||
async fn get_connection() -> Result<Conn> {
|
async fn get_connection() -> Result<Conn> {
|
||||||
_get_connection()
|
_get_connection().await.map_err(|_| create_error!(InternalError))
|
||||||
.await
|
|
||||||
.map_err(|_| create_error!(InternalError))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn raise_if_in_voice(user: &User, channel: &UserVoiceChannel) -> Result<()> {
|
pub async fn raise_if_in_voice(user: &User, channel_id: &str) -> Result<()> {
|
||||||
let mut conn = get_connection().await?;
|
let mut conn = get_connection().await?;
|
||||||
|
|
||||||
if user.bot.is_some() {
|
if user.bot.is_some() {
|
||||||
// bots can be in as many voice channels as it wants so we just check if its already connected to the one its trying to connect to
|
// bots can be in as many voice channels as it wants so we just check if its already connected to the one its trying to connect to
|
||||||
if conn
|
if conn
|
||||||
.sismember(format!("vc:{}", &user.id), channel)
|
.sismember(format!("vc:{}", &user.id), channel_id)
|
||||||
.await
|
.await
|
||||||
.to_internal_error()?
|
.to_internal_error()?
|
||||||
{
|
{
|
||||||
@@ -51,31 +43,23 @@ pub async fn raise_if_in_voice(user: &User, channel: &UserVoiceChannel) -> Resul
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_channel_node(channel_id: &str, node: &str) -> Result<()> {
|
pub async fn set_channel_node(channel: &str, node: &str) -> Result<()> {
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.set(format!("node:{channel_id}"), node)
|
.set(format!("node:{channel}"), node)
|
||||||
.await
|
.await
|
||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_channel_node(channel_id: &str) -> Result<Option<String>> {
|
pub async fn get_channel_node(channel: &str) -> Result<Option<String>> {
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.get(format!("node:{channel_id}"))
|
.get(format!("node:{channel}"))
|
||||||
.await
|
.await
|
||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_channel_node(channel_id: &str) -> Result<()> {
|
pub async fn get_user_voice_channels(user_id: &str) -> Result<Vec<String>> {
|
||||||
get_connection()
|
|
||||||
.await?
|
|
||||||
.del(format!("node:{channel_id}"))
|
|
||||||
.await
|
|
||||||
.to_internal_error()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_user_voice_channels(user_id: &str) -> Result<Vec<UserVoiceChannel>> {
|
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.smembers(format!("vc:{user_id}"))
|
.smembers(format!("vc:{user_id}"))
|
||||||
@@ -84,14 +68,14 @@ pub async fn get_user_voice_channels(user_id: &str) -> Result<Vec<UserVoiceChann
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_user_moved_from_voice(
|
pub async fn set_user_moved_from_voice(
|
||||||
old_channel_id: &str,
|
old_channel: &str,
|
||||||
new_channel: &UserVoiceChannel,
|
new_channel: &str,
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.set_ex(
|
.set_ex(
|
||||||
format!("moved_from:{user_id}:{old_channel_id}"),
|
format!("moved_from:{user_id}:{old_channel}"),
|
||||||
new_channel,
|
new_channel,
|
||||||
10,
|
10,
|
||||||
)
|
)
|
||||||
@@ -108,25 +92,18 @@ pub async fn get_user_moved_from_voice(channel_id: &str, user_id: &str) -> Resul
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_user_moved_to_voice(
|
pub async fn set_user_moved_to_voice(
|
||||||
new_channel_id: &str,
|
new_channel: &str,
|
||||||
old_channel: &UserVoiceChannel,
|
old_channel: &str,
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.set_ex(
|
.set_ex(format!("moved_to:{user_id}:{new_channel}"), old_channel, 10)
|
||||||
format!("moved_to:{user_id}:{new_channel_id}"),
|
|
||||||
old_channel,
|
|
||||||
10,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_user_moved_to_voice(
|
pub async fn get_user_moved_to_voice(channel_id: &str, user_id: &str) -> Result<Option<String>> {
|
||||||
channel_id: &str,
|
|
||||||
user_id: &str,
|
|
||||||
) -> Result<Option<UserVoiceChannel>> {
|
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.get_del(format!("moved_to:{user_id}:{channel_id}"))
|
.get_del(format!("moved_to:{user_id}:{channel_id}"))
|
||||||
@@ -134,10 +111,10 @@ pub async fn get_user_moved_to_voice(
|
|||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn is_in_voice_channel(user_id: &str, channel: &UserVoiceChannel) -> Result<bool> {
|
pub async fn is_in_voice_channel(user_id: &str, channel_id: &str) -> Result<bool> {
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.sismember(format!("vc:{user_id}"), channel)
|
.sismember(format!("vc:{user_id}"), channel_id)
|
||||||
.await
|
.await
|
||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
@@ -171,15 +148,12 @@ pub fn get_allowed_sources(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_voice_state(
|
pub async fn create_voice_state(
|
||||||
channel: &UserVoiceChannel,
|
channel_id: &str,
|
||||||
|
server_id: Option<&str>,
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
joined_at: Timestamp,
|
joined_at: Timestamp,
|
||||||
) -> Result<UserVoiceState> {
|
) -> Result<UserVoiceState> {
|
||||||
let unique_key = format!(
|
let unique_key = format!("{}:{}", &user_id, server_id.unwrap_or(channel_id));
|
||||||
"{}:{}",
|
|
||||||
&user_id,
|
|
||||||
channel.server_id.as_ref().unwrap_or(&channel.id)
|
|
||||||
);
|
|
||||||
|
|
||||||
let voice_state = UserVoiceState {
|
let voice_state = UserVoiceState {
|
||||||
joined_at,
|
joined_at,
|
||||||
@@ -191,9 +165,9 @@ pub async fn create_voice_state(
|
|||||||
};
|
};
|
||||||
|
|
||||||
Pipeline::new()
|
Pipeline::new()
|
||||||
.sadd(format!("vc_members:{}", &channel.id), user_id)
|
.sadd(format!("vc_members:{channel_id}"), user_id)
|
||||||
.sadd(format!("vc:{user_id}"), channel)
|
.sadd(format!("vc:{user_id}"), channel_id)
|
||||||
.set(&unique_key, &channel.id)
|
.set(&unique_key, channel_id)
|
||||||
.set(
|
.set(
|
||||||
format!("joined_at:{unique_key}"),
|
format!("joined_at:{unique_key}"),
|
||||||
joined_at
|
joined_at
|
||||||
@@ -220,16 +194,16 @@ pub async fn create_voice_state(
|
|||||||
Ok(voice_state)
|
Ok(voice_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_voice_state(channel: &UserVoiceChannel, user_id: &str) -> Result<()> {
|
pub async fn delete_voice_state(
|
||||||
let unique_key = format!(
|
channel_id: &str,
|
||||||
"{}:{}",
|
server_id: Option<&str>,
|
||||||
&user_id,
|
user_id: &str,
|
||||||
channel.server_id.as_ref().unwrap_or(&channel.id)
|
) -> Result<()> {
|
||||||
);
|
let unique_key = format!("{}:{}", &user_id, server_id.unwrap_or(channel_id));
|
||||||
|
|
||||||
Pipeline::new()
|
Pipeline::new()
|
||||||
.srem(format!("vc_members:{}", &channel.id), user_id)
|
.srem(format!("vc_members:{channel_id}"), user_id)
|
||||||
.srem(format!("vc:{user_id}"), channel)
|
.srem(format!("vc:{user_id}"), channel_id)
|
||||||
.del(&[
|
.del(&[
|
||||||
format!("joined_at:{unique_key}"),
|
format!("joined_at:{unique_key}"),
|
||||||
format!("is_publishing:{unique_key}"),
|
format!("is_publishing:{unique_key}"),
|
||||||
@@ -244,19 +218,19 @@ pub async fn delete_voice_state(channel: &UserVoiceChannel, user_id: &str) -> Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_channel_voice_state(
|
pub async fn delete_channel_voice_state(
|
||||||
channel: &UserVoiceChannel,
|
channel_id: &str,
|
||||||
|
server_id: Option<&str>,
|
||||||
user_ids: &[String],
|
user_ids: &[String],
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let parent_id = channel.server_id.as_ref().unwrap_or(&channel.id);
|
let parent_id = server_id.unwrap_or(channel_id);
|
||||||
|
|
||||||
let mut pipeline = Pipeline::new();
|
let mut pipeline = Pipeline::new();
|
||||||
pipeline.del(format!("vc_members:{}", &channel.id));
|
pipeline.del(format!("vc_members:{channel_id}"));
|
||||||
pipeline.del(format!("node:{}", &channel.id));
|
|
||||||
|
|
||||||
for user_id in user_ids {
|
for user_id in user_ids {
|
||||||
let unique_key = format!("{user_id}:{parent_id}");
|
let unique_key = format!("{user_id}:{parent_id}");
|
||||||
|
|
||||||
pipeline.srem(format!("vc:{user_id}"), channel).del(&[
|
pipeline.srem(format!("vc:{user_id}"), channel_id).del(&[
|
||||||
format!("joined_at:{unique_key}"),
|
format!("joined_at:{unique_key}"),
|
||||||
format!("is_publishing:{unique_key}"),
|
format!("is_publishing:{unique_key}"),
|
||||||
format!("is_receiving:{unique_key}"),
|
format!("is_receiving:{unique_key}"),
|
||||||
@@ -273,7 +247,8 @@ pub async fn delete_channel_voice_state(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_voice_state_tracks(
|
pub async fn update_voice_state_tracks(
|
||||||
channel: &UserVoiceChannel,
|
channel_id: &str,
|
||||||
|
server_id: Option<&str>,
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
added: bool,
|
added: bool,
|
||||||
track: i32,
|
track: i32,
|
||||||
@@ -298,21 +273,18 @@ pub async fn update_voice_state_tracks(
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
update_voice_state(channel, user_id, &partial).await?;
|
update_voice_state(channel_id, server_id, user_id, &partial).await?;
|
||||||
|
|
||||||
Ok(partial)
|
Ok(partial)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_voice_state(
|
pub async fn update_voice_state(
|
||||||
channel: &UserVoiceChannel,
|
channel_id: &str,
|
||||||
|
server_id: Option<&str>,
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
partial: &PartialUserVoiceState,
|
partial: &PartialUserVoiceState,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let unique_key = format!(
|
let unique_key = format!("{}:{}", &user_id, server_id.unwrap_or(channel_id));
|
||||||
"{}:{}",
|
|
||||||
&user_id,
|
|
||||||
channel.server_id.as_ref().unwrap_or(&channel.id)
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut pipeline = Pipeline::new();
|
let mut pipeline = Pipeline::new();
|
||||||
|
|
||||||
@@ -338,24 +310,21 @@ pub async fn update_voice_state(
|
|||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_voice_channel_members(channel: &UserVoiceChannel) -> Result<Option<Vec<String>>> {
|
pub async fn get_voice_channel_members(channel_id: &str) -> Result<Option<Vec<String>>> {
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.smembers::<_, Option<Vec<String>>>(format!("vc_members:{}", &channel.id))
|
.smembers::<_, Option<Vec<String>>>(format!("vc_members:{channel_id}"))
|
||||||
.await
|
.await
|
||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
.map(|opt| opt.and_then(|v| if v.is_empty() { None } else { Some(v) }))
|
.map(|opt| opt.and_then(|v| if v.is_empty() { None } else { Some(v) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_voice_state(
|
pub async fn get_voice_state(
|
||||||
channel: &UserVoiceChannel,
|
channel_id: &str,
|
||||||
|
server_id: Option<&str>,
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
) -> Result<Option<UserVoiceState>> {
|
) -> Result<Option<UserVoiceState>> {
|
||||||
let unique_key = format!(
|
let unique_key = format!("{}:{}", user_id, server_id.unwrap_or(channel_id));
|
||||||
"{}:{}",
|
|
||||||
&user_id,
|
|
||||||
channel.server_id.as_ref().unwrap_or(&channel.id)
|
|
||||||
);
|
|
||||||
|
|
||||||
let (joined_at, is_publishing, is_receiving, screensharing, camera) = get_connection()
|
let (joined_at, is_publishing, is_receiving, screensharing, camera) = get_connection()
|
||||||
.await?
|
.await?
|
||||||
@@ -396,21 +365,21 @@ pub async fn get_voice_state(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_channel_voice_state(
|
pub async fn get_channel_voice_state(channel: &Channel) -> Result<Option<v0::ChannelVoiceState>> {
|
||||||
channel: &UserVoiceChannel,
|
let members = get_voice_channel_members(channel.id()).await?;
|
||||||
) -> Result<Option<v0::ChannelVoiceState>> {
|
|
||||||
let members = get_voice_channel_members(channel).await?;
|
let server = channel.server();
|
||||||
|
|
||||||
if let Some(members) = members {
|
if let Some(members) = members {
|
||||||
let mut participants = Vec::with_capacity(members.len());
|
let mut participants = Vec::with_capacity(members.len());
|
||||||
|
|
||||||
for user_id in members {
|
for user_id in members {
|
||||||
if let Some(voice_state) = get_voice_state(channel, &user_id).await? {
|
if let Some(voice_state) = get_voice_state(channel.id(), server, &user_id).await? {
|
||||||
participants.push(voice_state);
|
participants.push(voice_state);
|
||||||
} else {
|
} else {
|
||||||
log::info!("Voice state not found but member in voice channel members, removing.");
|
log::info!("Voice state not found but member in voice channel members, removing.");
|
||||||
|
|
||||||
delete_voice_state(channel, &user_id).await?;
|
delete_voice_state(channel.id(), server, &user_id).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +387,7 @@ pub async fn get_channel_voice_state(
|
|||||||
participants.shrink_to_fit();
|
participants.shrink_to_fit();
|
||||||
|
|
||||||
Ok(Some(v0::ChannelVoiceState {
|
Ok(Some(v0::ChannelVoiceState {
|
||||||
id: channel.id.clone(),
|
id: channel.id().to_string(),
|
||||||
participants,
|
participants,
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
@@ -426,12 +395,12 @@ pub async fn get_channel_voice_state(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn move_user(user: &str, from_channel_id: &str, to_channel_id: &str) -> Result<()> {
|
pub async fn move_user(user: &str, from: &str, to: &str) -> Result<()> {
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
.smove(
|
.smove(
|
||||||
format!("vc_members:{from_channel_id}"),
|
format!("vc-members-{from}"),
|
||||||
format!("vc_members:{to_channel_id}"),
|
format!("vc-members-{to}"),
|
||||||
user,
|
user,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@@ -445,13 +414,11 @@ pub async fn sync_voice_permissions(
|
|||||||
server: Option<&Server>,
|
server: Option<&Server>,
|
||||||
role_id: Option<&str>,
|
role_id: Option<&str>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let user_voice_channel = UserVoiceChannel::from_channel(channel);
|
|
||||||
|
|
||||||
let Some(node) = get_channel_node(channel.id()).await? else {
|
let Some(node) = get_channel_node(channel.id()).await? else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
for user_id in get_voice_channel_members(&user_voice_channel)
|
for user_id in get_voice_channel_members(channel.id())
|
||||||
.await?
|
.await?
|
||||||
.iter()
|
.iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
@@ -491,9 +458,7 @@ pub async fn sync_user_voice_permissions(
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.is_none_or(|member| member.roles.iter().any(|r| r == role_id))
|
.is_none_or(|member| member.roles.iter().any(|r| r == role_id))
|
||||||
}) {
|
}) {
|
||||||
let user_voice_channel = UserVoiceChannel::from_channel(channel);
|
let Some(voice_state) = get_voice_state(channel_id, server_id, &user.id).await? else {
|
||||||
|
|
||||||
let Some(voice_state) = get_voice_state(&user_voice_channel, &user.id).await? else {
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -524,7 +489,7 @@ pub async fn sync_user_voice_permissions(
|
|||||||
update_event.screensharing = voice_state.screensharing.then_some(can_video);
|
update_event.screensharing = voice_state.screensharing.then_some(can_video);
|
||||||
update_event.is_publishing = voice_state.is_publishing.then_some(can_speak);
|
update_event.is_publishing = voice_state.is_publishing.then_some(can_speak);
|
||||||
|
|
||||||
update_voice_state(&user_voice_channel, &user.id, &update_event).await?;
|
update_voice_state(channel_id, server_id, &user.id, &update_event).await?;
|
||||||
|
|
||||||
voice_client
|
voice_client
|
||||||
.update_permissions(
|
.update_permissions(
|
||||||
@@ -602,95 +567,34 @@ pub async fn get_call_notification_recipients(
|
|||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn remove_user_from_voice_channels(
|
pub async fn remove_user_from_voice_channels(db: &Database, voice_client: &VoiceClient, user_id: &str) -> Result<()> {
|
||||||
voice_client: &VoiceClient,
|
for channel_id in get_user_voice_channels(user_id).await? {
|
||||||
user_id: &str,
|
remove_user_from_voice_channel(db, voice_client, &channel_id, user_id).await?;
|
||||||
) -> Result<()> {
|
|
||||||
for channel in get_user_voice_channels(user_id).await? {
|
|
||||||
remove_user_from_voice_channel(voice_client, &channel, user_id).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn remove_user_from_voice_channel(
|
|
||||||
voice_client: &VoiceClient,
|
|
||||||
channel: &UserVoiceChannel,
|
|
||||||
user_id: &str,
|
|
||||||
) -> Result<()> {
|
|
||||||
if let Some(node) = get_channel_node(&channel.id).await? {
|
|
||||||
let _ = voice_client.remove_user(&node, user_id, &channel.id).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete_voice_state(channel, user_id).await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn delete_voice_channel(
|
|
||||||
voice_client: &VoiceClient,
|
|
||||||
channel: &UserVoiceChannel,
|
|
||||||
) -> Result<()> {
|
|
||||||
if let Some(users) = get_voice_channel_members(channel).await? {
|
|
||||||
let node = get_channel_node(&channel.id).await?.unwrap();
|
|
||||||
voice_client.delete_room(&node, &channel.id).await?;
|
|
||||||
|
|
||||||
delete_channel_voice_state(channel, &users).await?;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
pub async fn remove_user_from_voice_channel(db: &Database, voice_client: &VoiceClient, channel_id: &str, user_id: &str) -> Result<()> {
|
||||||
pub struct RoomMetadata {
|
if let Some(node) = get_channel_node(channel_id).await? {
|
||||||
pub server: Option<String>,
|
let _ = voice_client.remove_user(&node, user_id, channel_id).await;
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
||||||
pub struct UserVoiceChannel {
|
|
||||||
pub id: String,
|
|
||||||
pub server_id: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl UserVoiceChannel {
|
|
||||||
pub fn from_string(input: String) -> Self {
|
|
||||||
let mut parts = input.splitn(2, '-');
|
|
||||||
|
|
||||||
Self {
|
|
||||||
id: parts.next().unwrap().to_string(),
|
|
||||||
server_id: parts.next().map(ToString::to_string),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_channel(channel: &Channel) -> Self {
|
let channel = Reference::from_unchecked(channel_id).as_channel(db).await?;
|
||||||
Self {
|
|
||||||
id: channel.id().to_string(),
|
delete_voice_state(channel_id, channel.server(), user_id).await?;
|
||||||
server_id: channel.server().map(ToString::to_string),
|
|
||||||
}
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for UserVoiceChannel {
|
pub async fn delete_voice_channel(voice_client: &VoiceClient, channel_id: &str, server_id: Option<&str>) -> Result<()> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
if let Some(users) = get_voice_channel_members(channel_id).await? {
|
||||||
f.write_str(&self.id)?;
|
let node = get_channel_node(channel_id).await?.unwrap();
|
||||||
|
|
||||||
if let Some(server_id) = &self.server_id {
|
voice_client.delete_room(&node, channel_id).await?;
|
||||||
f.write_char('-')?;
|
|
||||||
f.write_str(server_id)?
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
delete_channel_voice_state(channel_id, server_id, &users).await?;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
impl ToRedisArgs for UserVoiceChannel {
|
Ok(())
|
||||||
fn write_redis_args<W: ?Sized + RedisWrite>(&self, out: &mut W) {
|
|
||||||
out.write_arg_fmt(self);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromRedisValue for UserVoiceChannel {
|
|
||||||
fn from_redis_value(v: &Value) -> Result<Self, RedisError> {
|
|
||||||
String::from_redis_value(v).map(UserVoiceChannel::from_string)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
models::{Channel, User},
|
models::{Channel, User},
|
||||||
voice::RoomMetadata,
|
|
||||||
Database,
|
Database,
|
||||||
};
|
};
|
||||||
use livekit_api::{
|
use livekit_api::{
|
||||||
@@ -103,16 +102,11 @@ impl VoiceClient {
|
|||||||
pub async fn create_room(&self, node: &str, channel: &Channel) -> Result<Room> {
|
pub async fn create_room(&self, node: &str, channel: &Channel) -> Result<Room> {
|
||||||
let room = self.get_node(node)?;
|
let room = self.get_node(node)?;
|
||||||
|
|
||||||
let metadata = RoomMetadata {
|
|
||||||
server: channel.server().map(|id| id.to_string()),
|
|
||||||
};
|
|
||||||
|
|
||||||
room.client
|
room.client
|
||||||
.create_room(
|
.create_room(
|
||||||
channel.id(),
|
channel.id(),
|
||||||
CreateRoomOptions {
|
CreateRoomOptions {
|
||||||
empty_timeout: 5 * 60, // 5 minutes,
|
empty_timeout: 5 * 60, // 5 minutes,
|
||||||
metadata: serde_json::to_string(&metadata).to_internal_error()?,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ This email is intended for {{email}}
|
|||||||
|
|
||||||
This email has no association with Stoat or Revolt Platforms Ltd.
|
This email has no association with Stoat or Revolt Platforms Ltd.
|
||||||
Learn more about third party instances here:
|
Learn more about third party instances here:
|
||||||
https://developers.stoat.chat/faq/
|
https://developers.stoat.chat/faq.html
|
||||||
@@ -6,4 +6,4 @@ This email is intended for {{email}}
|
|||||||
|
|
||||||
This email has no association with Stoat or Revolt Platforms Ltd.
|
This email has no association with Stoat or Revolt Platforms Ltd.
|
||||||
Learn more about third party instances here:
|
Learn more about third party instances here:
|
||||||
https://developers.stoat.chat/faq/
|
https://developers.revolt.chat/faq.html
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">
|
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">
|
||||||
Further violations may result in a permanent ban depending on
|
Further violations may result in a permanent ban depending on
|
||||||
severity, please abide by the
|
severity, please abide by the
|
||||||
<a href="https://stoat.chat/legal/community-guidelines" style="color: #0d6efd;">Community Guidelines</a>.
|
<a href="https://revolt.chat/aup" style="color: #0d6efd;">Acceptable Usage Policy</a>.
|
||||||
</p>
|
</p>
|
||||||
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Your account has been suspended, for one or more reasons:
|
|||||||
|
|
||||||
You will be able to use your account again in {{duration}} days.
|
You will be able to use your account again in {{duration}} days.
|
||||||
|
|
||||||
Further violations may result in a permanent ban depending on severity, please abide by the Community Guidelines (https://stoat.chat/legal/community-guidelines).
|
Further violations may result in a permanent ban depending on severity, please abide by the Acceptable Usage Policy (https://revolt.chat/aup).
|
||||||
|
|
||||||
Ban evasion is prohibited and will be dealt with accordingly.
|
Ban evasion is prohibited and will be dealt with accordingly.
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ Your account has been suspended, for one or more reasons:
|
|||||||
|
|
||||||
This email is intended for {{email}}
|
This email is intended for {{email}}
|
||||||
|
|
||||||
This email has no association with Stoat or Revolt Platforms Ltd.
|
This email has no association with Revolt or Revolt Platforms Ltd.
|
||||||
Learn more about third party instances here:
|
Learn more about third party instances here:
|
||||||
https://developers.stoat.chat/faq/
|
https://developers.revolt.chat/faq.html
|
||||||
@@ -7,4 +7,4 @@ This email is intended for {{email}}
|
|||||||
|
|
||||||
This email has no association with Stoat or Revolt Platforms Ltd.
|
This email has no association with Stoat or Revolt Platforms Ltd.
|
||||||
Learn more about third party instances here:
|
Learn more about third party instances here:
|
||||||
https://developers.stoat.chat/faq/
|
https://developers.revolt.chat/faq.html
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
[package]
|
||||||
|
name = "revolt-discord"
|
||||||
|
version = "0.11.3"
|
||||||
|
edition = "2021"
|
||||||
|
license = "MIT"
|
||||||
|
authors = ["Zomatree <me@zomatree.live>"]
|
||||||
|
description = "Revolt Backend: Discord Compatibility"
|
||||||
|
repository = "https://github.com/stoatchat/stoatchat"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[features]
|
||||||
|
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
# Core
|
||||||
|
revolt-result = { version = "0.11.3", path = "../result" }
|
||||||
|
revolt-database = { version = "0.11.3", path = "../database" }
|
||||||
|
revolt-permissions = { version = "0.11.3", path = "../permissions" }
|
||||||
|
revolt-models = { version = "0.11.3", path = "../models" }
|
||||||
|
|
||||||
|
# Serialisation
|
||||||
|
serde_json = { version = "1" }
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|
||||||
|
# Http
|
||||||
|
reqwest = { version = "0.12", features = ["json"] }
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
pub mod types;
|
||||||
|
pub mod template;
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use revolt_models::v0;
|
||||||
|
use revolt_permissions::OverrideField;
|
||||||
|
|
||||||
|
use crate::types as discord;
|
||||||
|
use revolt_database::{
|
||||||
|
Category, Channel, Database, PartialChannel, PartialRole, PartialServer, Role, Server,
|
||||||
|
SystemMessageChannels,
|
||||||
|
};
|
||||||
|
use revolt_result::{Result, ToRevoltError};
|
||||||
|
|
||||||
|
pub async fn fetch_template(template_id: &str) -> Result<discord::GuildTemplate> {
|
||||||
|
reqwest::get(format!(
|
||||||
|
"https://discord.com/api/v10/guilds/templates/{template_id}"
|
||||||
|
))
|
||||||
|
.await
|
||||||
|
.to_internal_error()?
|
||||||
|
.json()
|
||||||
|
.await
|
||||||
|
.to_internal_error()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn import_template(
|
||||||
|
db: &Database,
|
||||||
|
server: &mut Server,
|
||||||
|
template: discord::GuildTemplate,
|
||||||
|
) -> Result<Vec<Channel>> {
|
||||||
|
let mut role_mapping = HashMap::new();
|
||||||
|
let mut channel_mapping = HashMap::new();
|
||||||
|
let mut categories = HashMap::new();
|
||||||
|
|
||||||
|
for discord_channel in &template.serialized_source_guild.channels {
|
||||||
|
if discord_channel.channel_type == discord::ChannelType::Category as u32 {
|
||||||
|
categories.insert(discord_channel.id, discord_channel.clone());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut role_positions = template.serialized_source_guild.roles
|
||||||
|
.iter()
|
||||||
|
.filter(|r| r.id != 0)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
role_positions.sort_by(|a, b| b.id.cmp(&a.id));
|
||||||
|
|
||||||
|
let role_positions = role_positions
|
||||||
|
.into_iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(i, r)| (r.id, i as i64))
|
||||||
|
.collect::<HashMap<_, _>>();
|
||||||
|
|
||||||
|
for discord_role in template.serialized_source_guild.roles.clone() {
|
||||||
|
if discord_role.id == 0 {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
role_mapping.insert(
|
||||||
|
discord_role.id,
|
||||||
|
convert_role(db, server, role_positions[&discord_role.id], discord_role).await?,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
for discord_channel in template.serialized_source_guild.channels.clone() {
|
||||||
|
if discord_channel.channel_type == discord::ChannelType::Category as u32 {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
channel_mapping.insert(
|
||||||
|
discord_channel.id,
|
||||||
|
convert_channel(db, server, &categories, &role_mapping, discord_channel).await?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
convert_server(db, server, &channel_mapping, template.serialized_source_guild).await?;
|
||||||
|
|
||||||
|
Ok(channel_mapping.into_values().collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn convert_role(db: &Database, server: &mut Server, rank: i64, role: discord::Role) -> Result<Role> {
|
||||||
|
let mut role_payload = Role::create(db, server, role.name).await?;
|
||||||
|
let mut partial = PartialRole {
|
||||||
|
rank: Some(rank),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
if role.hoist {
|
||||||
|
partial.hoist = Some(true)
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(colors) = role.colors {
|
||||||
|
if colors.primary_color != 0 {
|
||||||
|
partial.colour = Some(format!("#{:x}", colors.primary_color))
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if &role.permissions != "0" {
|
||||||
|
let allow = convert_permissions(&role.permissions);
|
||||||
|
partial.permissions = Some(OverrideField { a: allow, d: 0 });
|
||||||
|
};
|
||||||
|
|
||||||
|
role_payload
|
||||||
|
.update(db, &server.id, partial, Vec::new())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
server.roles.insert(role_payload.id.clone(), role_payload.clone());
|
||||||
|
|
||||||
|
Ok(role_payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
static PERMISSION_MAPPING: &[(i64, i64)] = &[];
|
||||||
|
|
||||||
|
pub fn convert_permissions(permissions: &str) -> i64 {
|
||||||
|
let value = permissions.parse::<i64>().unwrap();
|
||||||
|
let mut output = 0;
|
||||||
|
|
||||||
|
for (discord_perm, perm) in PERMISSION_MAPPING {
|
||||||
|
if (value & *discord_perm) == *discord_perm {
|
||||||
|
output |= *perm
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
output
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn convert_channel(
|
||||||
|
db: &Database,
|
||||||
|
server: &mut Server,
|
||||||
|
categories: &HashMap<u32, discord::Channel>,
|
||||||
|
role_mapping: &HashMap<u32, Role>,
|
||||||
|
channel: discord::Channel,
|
||||||
|
) -> Result<Channel> {
|
||||||
|
let mut channel_payload = Channel::create_server_channel(
|
||||||
|
db,
|
||||||
|
server,
|
||||||
|
v0::DataCreateServerChannel {
|
||||||
|
channel_type: v0::LegacyServerChannelType::Text,
|
||||||
|
name: channel.name,
|
||||||
|
description: channel.topic,
|
||||||
|
nsfw: channel.nsfw,
|
||||||
|
voice: if channel.channel_type == discord::ChannelType::Voice as u32
|
||||||
|
|| channel.channel_type == discord::ChannelType::StageVoice as u32
|
||||||
|
{
|
||||||
|
Some(v0::VoiceInformation {
|
||||||
|
max_users: channel.user_limit.map(|limit| limit as usize),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let mut partial = PartialChannel::default();
|
||||||
|
let mut role_permissions = HashMap::new();
|
||||||
|
|
||||||
|
if let Some(parent_id) = channel.parent_id {
|
||||||
|
let category = categories.get(&parent_id).unwrap();
|
||||||
|
|
||||||
|
for discord_overwrite in category.permission_overwrites.iter().flatten() {
|
||||||
|
if discord_overwrite.overwrite_type == discord::OverwriteType::Member as u32 {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
let overwrite = OverrideField {
|
||||||
|
a: convert_permissions(&discord_overwrite.allow),
|
||||||
|
d: convert_permissions(&discord_overwrite.deny),
|
||||||
|
};
|
||||||
|
|
||||||
|
if discord_overwrite.id == 0 {
|
||||||
|
partial.default_permissions = Some(overwrite)
|
||||||
|
} else {
|
||||||
|
role_permissions.insert(
|
||||||
|
role_mapping.get(&discord_overwrite.id).unwrap().id.clone(),
|
||||||
|
overwrite,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for discord_overwrite in channel.permission_overwrites.iter().flatten() {
|
||||||
|
if discord_overwrite.overwrite_type == discord::OverwriteType::Member as u32 {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
let overwrite = OverrideField {
|
||||||
|
a: convert_permissions(&discord_overwrite.allow),
|
||||||
|
d: convert_permissions(&discord_overwrite.deny),
|
||||||
|
};
|
||||||
|
|
||||||
|
if discord_overwrite.id == 0 {
|
||||||
|
if let Some(default_permissions) = &mut partial.default_permissions {
|
||||||
|
default_permissions.a |= overwrite.a;
|
||||||
|
default_permissions.d |= overwrite.d;
|
||||||
|
} else {
|
||||||
|
partial.default_permissions = Some(overwrite)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let id = &role_mapping.get(&discord_overwrite.id).unwrap().id;
|
||||||
|
|
||||||
|
if let Some(role_permission) = role_permissions.get_mut(id) {
|
||||||
|
role_permission.a |= overwrite.a;
|
||||||
|
role_permission.d |= overwrite.d;
|
||||||
|
} else {
|
||||||
|
role_permissions.insert(id.clone(), overwrite);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
partial.role_permissions = Some(role_permissions);
|
||||||
|
|
||||||
|
channel_payload.update(db, partial, Vec::new()).await?;
|
||||||
|
|
||||||
|
Ok(channel_payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn convert_server(
|
||||||
|
db: &Database,
|
||||||
|
server: &mut Server,
|
||||||
|
channel_mapping: &HashMap<u32, Channel>,
|
||||||
|
guild: discord::Guild,
|
||||||
|
) -> Result<()> {
|
||||||
|
let mut partial = PartialServer {
|
||||||
|
categories: Some(
|
||||||
|
guild
|
||||||
|
.channels
|
||||||
|
.iter()
|
||||||
|
.filter(|c| c.channel_type == discord::ChannelType::Category as u32)
|
||||||
|
.map(|category| {
|
||||||
|
let mut channels = guild
|
||||||
|
.channels
|
||||||
|
.iter()
|
||||||
|
.filter(|c| c.parent_id.as_ref() == Some(&category.id))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
channels.sort_by(|a, b| a.position.cmp(&b.position));
|
||||||
|
|
||||||
|
Category {
|
||||||
|
id: category.id.to_string(),
|
||||||
|
title: category.name.clone(),
|
||||||
|
channels: channels
|
||||||
|
.into_iter()
|
||||||
|
.map(|c| channel_mapping.get(&c.id).unwrap().id().to_string())
|
||||||
|
.collect(),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: banner
|
||||||
|
|
||||||
|
if let Some(system_channel_id) = &guild.system_channel_id {
|
||||||
|
let channel_id = channel_mapping
|
||||||
|
.get(system_channel_id)
|
||||||
|
.unwrap()
|
||||||
|
.id()
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
partial.system_messages = Some(SystemMessageChannels {
|
||||||
|
user_banned: Some(channel_id.clone()),
|
||||||
|
user_joined: Some(channel_id.clone()),
|
||||||
|
user_kicked: Some(channel_id.clone()),
|
||||||
|
user_left: Some(channel_id),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let default_role = guild.roles.iter().find(|r| r.id == 0).unwrap();
|
||||||
|
partial.default_permissions = Some(convert_permissions(&default_role.permissions));
|
||||||
|
|
||||||
|
server.update(db, partial, Vec::new()).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct GuildTemplate {
|
||||||
|
pub serialized_source_guild: Guild
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
|
pub struct Guild {
|
||||||
|
pub name: String,
|
||||||
|
pub banner: Option<String>,
|
||||||
|
pub roles: Vec<Role>,
|
||||||
|
pub channels: Vec<Channel>,
|
||||||
|
pub system_channel_id: Option<u32>,
|
||||||
|
pub description: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
|
pub struct Role {
|
||||||
|
pub id: u32,
|
||||||
|
pub name: String,
|
||||||
|
pub colors: Option<RoleColor>,
|
||||||
|
pub hoist: bool,
|
||||||
|
pub icon: Option<String>,
|
||||||
|
pub position: Option<u32>,
|
||||||
|
pub permissions: String,
|
||||||
|
pub mentionable: bool
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
|
pub struct RoleColor {
|
||||||
|
pub primary_color: u64,
|
||||||
|
pub secondary_color: Option<u64>,
|
||||||
|
pub tertiary_color: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
|
pub struct Channel {
|
||||||
|
pub id: u32,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub channel_type: u32,
|
||||||
|
pub position: u32,
|
||||||
|
pub permission_overwrites: Option<Vec<Overwrite>>,
|
||||||
|
pub name: String,
|
||||||
|
pub topic: Option<String>,
|
||||||
|
pub nsfw: Option<bool>,
|
||||||
|
pub user_limit: Option<u32>,
|
||||||
|
pub parent_id: Option<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
||||||
|
pub enum ChannelType {
|
||||||
|
Text = 0,
|
||||||
|
DM = 1,
|
||||||
|
Voice = 2,
|
||||||
|
Group = 3,
|
||||||
|
Category = 4,
|
||||||
|
Announcement = 5,
|
||||||
|
AnnouncementThread = 10,
|
||||||
|
PublicThread = 11,
|
||||||
|
PrivateThread = 12,
|
||||||
|
StageVoice = 13,
|
||||||
|
Directory = 14,
|
||||||
|
Forum = 15,
|
||||||
|
Media = 16,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
|
pub struct Overwrite {
|
||||||
|
pub id: u32,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub overwrite_type: u32,
|
||||||
|
pub allow: String,
|
||||||
|
pub deny: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||||
|
pub enum OverwriteType {
|
||||||
|
Role = 0,
|
||||||
|
Member = 1,
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-files"
|
name = "revolt-files"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -16,33 +16,33 @@ tracing = { workspace = true }
|
|||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
|
|
||||||
ffprobe = { workspace = true }
|
ffprobe = "0.4.0"
|
||||||
imagesize = { workspace = true }
|
imagesize = "0.13.0"
|
||||||
tempfile = { workspace = true }
|
tempfile = "3.12.0"
|
||||||
|
|
||||||
base64 = { workspace = true }
|
base64 = "0.22.1"
|
||||||
aes-gcm = { workspace = true }
|
aes-gcm = "0.10.3"
|
||||||
typenum = { workspace = true }
|
typenum = "1.17.0"
|
||||||
|
|
||||||
aws-config = { workspace = true }
|
aws-config = "1.5.5"
|
||||||
aws-sdk-s3 = { workspace = true, features = ["behavior-version-latest"] }
|
aws-sdk-s3 = { version = "1.46.0", features = ["behavior-version-latest"] }
|
||||||
|
|
||||||
revolt-config = { workspace = true, features = [
|
revolt-config = { version = "0.11.3", path = "../config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-result = { workspace = true }
|
revolt-result = { version = "0.11.3", path = "../result" }
|
||||||
|
|
||||||
# image processing
|
# image processing
|
||||||
jxl-oxide = { workspace = true, features = ["image"] }
|
jxl-oxide = { workspace = true }
|
||||||
image = { workspace = true }
|
image = { workspace = true }
|
||||||
|
|
||||||
# svg rendering
|
# svg rendering
|
||||||
usvg = { workspace = true }
|
usvg = "0.44.0"
|
||||||
resvg = { workspace = true }
|
resvg = "0.44.0"
|
||||||
tiny-skia = { workspace = true }
|
tiny-skia = "0.11.4"
|
||||||
|
|
||||||
# encoding
|
# encoding
|
||||||
webp = { workspace = true }
|
webp = "0.3.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
uuid = { workspace = true, features = ["v4"] }
|
uuid = { workspace = true }
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use image::{AnimationDecoder, DynamicImage, ImageBuffer, ImageReader};
|
use image::{DynamicImage, ImageBuffer, ImageReader};
|
||||||
use jxl_oxide::integration::JxlDecoder;
|
use jxl_oxide::integration::JxlDecoder;
|
||||||
use revolt_config::report_internal_error;
|
use revolt_config::report_internal_error;
|
||||||
use std::io::{BufRead, Read, Seek};
|
use std::io::{BufRead, Read, Seek};
|
||||||
@@ -35,31 +35,6 @@ impl MediaRepository for MediaImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_animated(&self, f: &NamedTempFile, mime: &str) -> Option<bool> {
|
|
||||||
match mime {
|
|
||||||
// Current behaviour is to assume GIFs are animated, this checks for at least 2 frames
|
|
||||||
"image/gif" => {
|
|
||||||
let file = std::fs::File::open(f.path()).ok()?;
|
|
||||||
let reader = std::io::BufReader::new(file);
|
|
||||||
let decoder = image::codecs::gif::GifDecoder::new(reader).ok()?;
|
|
||||||
Some(decoder.into_frames().take(2).count() > 1)
|
|
||||||
}
|
|
||||||
"image/png" => {
|
|
||||||
let file = std::fs::File::open(f.path()).ok()?;
|
|
||||||
let reader = std::io::BufReader::new(file);
|
|
||||||
let decoder = image::codecs::png::PngDecoder::new(reader).ok()?;
|
|
||||||
decoder.is_apng().ok()
|
|
||||||
}
|
|
||||||
"image/webp" => {
|
|
||||||
let file = std::fs::File::open(f.path()).ok()?;
|
|
||||||
let reader = std::io::BufReader::new(file);
|
|
||||||
let decoder = image::codecs::webp::WebPDecoder::new(reader).ok()?;
|
|
||||||
Some(decoder.has_animation())
|
|
||||||
}
|
|
||||||
_ => Some(false),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn image_size_vec(&self, v: &[u8], mime: &str) -> Option<(usize, usize)> {
|
fn image_size_vec(&self, v: &[u8], mime: &str) -> Option<(usize, usize)> {
|
||||||
match mime {
|
match mime {
|
||||||
"image/svg+xml" => {
|
"image/svg+xml" => {
|
||||||
@@ -196,9 +171,9 @@ impl MediaRepository for MediaImpl {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::io::Cursor;
|
||||||
|
|
||||||
use crate::{MediaImpl, MediaRepository};
|
use crate::{MediaImpl, MediaRepository};
|
||||||
use std::io::{Cursor, Write};
|
|
||||||
use tempfile::NamedTempFile;
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn asset_test_jpeg() {
|
async fn asset_test_jpeg() {
|
||||||
@@ -211,15 +186,6 @@ mod tests {
|
|||||||
media.create_thumbnail(image, "attachments");
|
media.create_thumbnail(image, "attachments");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn asset_test_jpeg_is_not_animated() {
|
|
||||||
let media = MediaImpl::from_config().await;
|
|
||||||
let mut f = NamedTempFile::new().unwrap();
|
|
||||||
f.write_all(include_bytes!("../../tests/assets/test.jpeg"))
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(media.is_animated(&f, "image/jpeg"), Some(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn asset_test_jpeg_extra_bytes() {
|
async fn asset_test_jpeg_extra_bytes() {
|
||||||
let media = MediaImpl::from_config().await;
|
let media = MediaImpl::from_config().await;
|
||||||
@@ -246,15 +212,6 @@ mod tests {
|
|||||||
media.create_thumbnail(image, "emojis");
|
media.create_thumbnail(image, "emojis");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn asset_test_png_is_not_animated() {
|
|
||||||
let media = MediaImpl::from_config().await;
|
|
||||||
let mut f = NamedTempFile::new().unwrap();
|
|
||||||
f.write_all(include_bytes!("../../tests/assets/test.png"))
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(media.is_animated(&f, "image/png"), Some(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn asset_test_png_extra_bytes() {
|
async fn asset_test_png_extra_bytes() {
|
||||||
let media = MediaImpl::from_config().await;
|
let media = MediaImpl::from_config().await;
|
||||||
@@ -302,15 +259,6 @@ mod tests {
|
|||||||
media.create_thumbnail(image, "attachments");
|
media.create_thumbnail(image, "attachments");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn asset_test_animated_png_is_animated() {
|
|
||||||
let media = MediaImpl::from_config().await;
|
|
||||||
let mut f = NamedTempFile::new().unwrap();
|
|
||||||
f.write_all(include_bytes!("../../tests/assets/anim-icos.apng"))
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(media.is_animated(&f, "image/png"), Some(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn asset_test_jxl() {
|
async fn asset_test_jxl() {
|
||||||
let media = MediaImpl::from_config().await;
|
let media = MediaImpl::from_config().await;
|
||||||
@@ -344,15 +292,6 @@ mod tests {
|
|||||||
media.create_thumbnail(image, "attachments");
|
media.create_thumbnail(image, "attachments");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn asset_test_webp_is_not_animated() {
|
|
||||||
let media = MediaImpl::from_config().await;
|
|
||||||
let mut f = NamedTempFile::new().unwrap();
|
|
||||||
f.write_all(include_bytes!("../../tests/assets/dice.webp"))
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(media.is_animated(&f, "image/webp"), Some(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn asset_test_animated_webp() {
|
async fn asset_test_animated_webp() {
|
||||||
let media = MediaImpl::from_config().await;
|
let media = MediaImpl::from_config().await;
|
||||||
@@ -364,15 +303,6 @@ mod tests {
|
|||||||
media.create_thumbnail(image, "attachments");
|
media.create_thumbnail(image, "attachments");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn asset_test_animated_webp_is_animated() {
|
|
||||||
let media = MediaImpl::from_config().await;
|
|
||||||
let mut f = NamedTempFile::new().unwrap();
|
|
||||||
f.write_all(include_bytes!("../../tests/assets/anim-icos.webp"))
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(media.is_animated(&f, "image/webp"), Some(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn asset_test_animated_gif() {
|
async fn asset_test_animated_gif() {
|
||||||
let media = MediaImpl::from_config().await;
|
let media = MediaImpl::from_config().await;
|
||||||
@@ -383,13 +313,4 @@ mod tests {
|
|||||||
let image = media.decode_image(&mut reader, "image/gif").unwrap();
|
let image = media.decode_image(&mut reader, "image/gif").unwrap();
|
||||||
media.create_thumbnail(image, "attachments");
|
media.create_thumbnail(image, "attachments");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn asset_test_animated_gif_is_animated() {
|
|
||||||
let media = MediaImpl::from_config().await;
|
|
||||||
let mut f = NamedTempFile::new().unwrap();
|
|
||||||
f.write_all(include_bytes!("../../tests/assets/anim-icos.gif"))
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(media.is_animated(&f, "image/gif"), Some(true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -91,34 +91,6 @@ pub fn image_size_vec(v: &[u8], mime: &str) -> Option<(usize, usize)> {
|
|||||||
media.image_size_vec(v, mime)
|
media.image_size_vec(v, mime)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether an image file contains animation data
|
|
||||||
pub fn is_animated(f: &NamedTempFile, mime: &str) -> Option<bool> {
|
|
||||||
let media = MediaImpl::new(Files {
|
|
||||||
blocked_mime_types: Default::default(),
|
|
||||||
clamd_host: Default::default(),
|
|
||||||
encryption_key: Default::default(),
|
|
||||||
limit: FilesLimit {
|
|
||||||
max_mega_pixels: 0,
|
|
||||||
max_pixel_side: 0,
|
|
||||||
min_file_size: 0,
|
|
||||||
min_resolution: [0, 0],
|
|
||||||
},
|
|
||||||
preview: Default::default(),
|
|
||||||
s3: FilesS3 {
|
|
||||||
access_key_id: Default::default(),
|
|
||||||
default_bucket: Default::default(),
|
|
||||||
endpoint: Default::default(),
|
|
||||||
path_style_buckets: Default::default(),
|
|
||||||
region: Default::default(),
|
|
||||||
secret_access_key: Default::default(),
|
|
||||||
},
|
|
||||||
scan_mime_types: Default::default(),
|
|
||||||
webp_quality: Default::default(),
|
|
||||||
});
|
|
||||||
|
|
||||||
media.is_animated(f, mime)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Determine size of video at temp file
|
/// Determine size of video at temp file
|
||||||
pub fn video_size(f: &NamedTempFile) -> Option<(i64, i64)> {
|
pub fn video_size(f: &NamedTempFile) -> Option<(i64, i64)> {
|
||||||
let media = MediaImpl::new(Files {
|
let media = MediaImpl::new(Files {
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ use thiserror::Error;
|
|||||||
|
|
||||||
pub trait MediaRepository: Send + Sync + 'static {
|
pub trait MediaRepository: Send + Sync + 'static {
|
||||||
fn image_size(&self, f: &NamedTempFile) -> Option<(usize, usize)>;
|
fn image_size(&self, f: &NamedTempFile) -> Option<(usize, usize)>;
|
||||||
|
|
||||||
fn is_animated(&self, f: &NamedTempFile, mime: &str) -> Option<bool>;
|
|
||||||
|
|
||||||
fn image_size_vec(&self, v: &[u8], mime: &str) -> Option<(usize, usize)>;
|
fn image_size_vec(&self, v: &[u8], mime: &str) -> Option<(usize, usize)>;
|
||||||
|
|
||||||
fn decode_image<R: Read + BufRead + Seek>(
|
fn decode_image<R: Read + BufRead + Seek>(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-models"
|
name = "revolt-models"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -21,26 +21,26 @@ default = ["serde", "partials", "rocket"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { workspace = true }
|
revolt-config = { version = "0.11.3", path = "../config" }
|
||||||
revolt-permissions = { workspace = true }
|
revolt-permissions = { version = "0.11.3", path = "../permissions" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
regex = { workspace = true }
|
regex = "1.11"
|
||||||
indexmap = { workspace = true }
|
indexmap = "1.9.3"
|
||||||
once_cell = { workspace = true }
|
once_cell = "1.17.1"
|
||||||
num_enum = { workspace = true }
|
num_enum = "0.6.1"
|
||||||
|
|
||||||
# Rocket
|
# Rocket
|
||||||
rocket = { workspace = true, optional = true }
|
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false }
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
revolt_optional_struct = { workspace = true, optional = true }
|
revolt_optional_struct = { version = "0.2.0", optional = true }
|
||||||
serde = { workspace = true, optional = true }
|
serde = { version = "1", features = ["derive"], optional = true }
|
||||||
iso8601-timestamp = { workspace = true, features = ["schema", "bson"] }
|
iso8601-timestamp = { version = "0.2.11", features = ["schema", "bson"] }
|
||||||
|
|
||||||
# Spec Generation
|
# Spec Generation
|
||||||
schemars = { workspace = true, features = ["indexmap2"], optional = true }
|
schemars = { version = "0.8.8", optional = true, features = ["indexmap1"] }
|
||||||
utoipa = { workspace = true, optional = true }
|
utoipa = { version = "4.2.3", optional = true }
|
||||||
|
|
||||||
# Validation
|
# Validation
|
||||||
validator = { workspace = true, features = ["derive"], optional = true }
|
validator = { version = "0.16.0", optional = true, features = ["derive"] }
|
||||||
@@ -112,10 +112,6 @@ auto_derived!(
|
|||||||
/// Voice Information for when this channel is also a voice channel
|
/// Voice Information for when this channel is also a voice channel
|
||||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
voice: Option<VoiceInformation>,
|
voice: Option<VoiceInformation>,
|
||||||
|
|
||||||
/// The channel's slowmode delay in seconds
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
slowmode: Option<u64>,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +150,6 @@ auto_derived!(
|
|||||||
pub last_message_id: Option<String>,
|
pub last_message_id: Option<String>,
|
||||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub voice: Option<VoiceInformation>,
|
pub voice: Option<VoiceInformation>,
|
||||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
|
||||||
pub slowmode: Option<u64>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optional fields on channel object
|
/// Optional fields on channel object
|
||||||
@@ -195,10 +189,6 @@ auto_derived!(
|
|||||||
/// Voice Information for voice channels
|
/// Voice Information for voice channels
|
||||||
pub voice: Option<VoiceInformation>,
|
pub voice: Option<VoiceInformation>,
|
||||||
|
|
||||||
/// The channel's slow mode delay in seconds, up to 6 hours
|
|
||||||
#[cfg_attr(feature = "validator", validate(range(min = 0, max = 21600)))]
|
|
||||||
pub slowmode: Option<u64>,
|
|
||||||
|
|
||||||
/// Fields to remove from channel
|
/// Fields to remove from channel
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Vec<FieldsChannel>,
|
pub remove: Vec<FieldsChannel>,
|
||||||
|
|||||||
@@ -54,22 +54,4 @@ auto_derived!(
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub nsfw: bool,
|
pub nsfw: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Partial emoji representation
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct PartialEmoji {
|
|
||||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
|
||||||
pub name: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Edit emoji information
|
|
||||||
#[cfg_attr(feature = "validator", derive(Validate))]
|
|
||||||
pub struct DataEditEmoji {
|
|
||||||
/// Emoji name
|
|
||||||
#[cfg_attr(
|
|
||||||
feature = "validator",
|
|
||||||
validate(length(min = 1, max = 32), regex = "RE_EMOJI")
|
|
||||||
)]
|
|
||||||
pub name: Option<String>,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
@@ -46,13 +46,8 @@ auto_derived!(
|
|||||||
File,
|
File,
|
||||||
/// File contains textual data and should be displayed as such
|
/// File contains textual data and should be displayed as such
|
||||||
Text,
|
Text,
|
||||||
/// File is an image with specific dimensions, and may be animated
|
/// File is an image with specific dimensions
|
||||||
Image {
|
Image { width: usize, height: usize },
|
||||||
width: usize,
|
|
||||||
height: usize,
|
|
||||||
thumbhash: Option<Vec<u8>>,
|
|
||||||
animated: Option<bool>,
|
|
||||||
},
|
|
||||||
/// File is a video with specific dimensions
|
/// File is a video with specific dimensions
|
||||||
Video { width: usize, height: usize },
|
Video { width: usize, height: usize },
|
||||||
/// File is audio
|
/// File is audio
|
||||||
|
|||||||
@@ -133,10 +133,7 @@ auto_derived!(
|
|||||||
#[serde(rename = "message_unpinned")]
|
#[serde(rename = "message_unpinned")]
|
||||||
MessageUnpinned { id: String, by: String },
|
MessageUnpinned { id: String, by: String },
|
||||||
#[serde(rename = "call_started")]
|
#[serde(rename = "call_started")]
|
||||||
CallStarted {
|
CallStarted { by: String, finished_at: Option<Timestamp> },
|
||||||
by: String,
|
|
||||||
finished_at: Option<Timestamp>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Name and / or avatar override information
|
/// Name and / or avatar override information
|
||||||
@@ -204,9 +201,6 @@ auto_derived!(
|
|||||||
pub image: Option<String>,
|
pub image: Option<String>,
|
||||||
/// Message content or system message information
|
/// Message content or system message information
|
||||||
pub body: String,
|
pub body: String,
|
||||||
/// The raw body, if the body has been rendered
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub raw_body: Option<String>,
|
|
||||||
/// Unique tag, usually the channel ID
|
/// Unique tag, usually the channel ID
|
||||||
pub tag: String,
|
pub tag: String,
|
||||||
/// Timestamp at which this notification was created
|
/// Timestamp at which this notification was created
|
||||||
@@ -261,7 +255,7 @@ auto_derived!(
|
|||||||
pub nonce: Option<String>,
|
pub nonce: Option<String>,
|
||||||
|
|
||||||
/// Message content to send
|
/// Message content to send
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 0)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 2000)))]
|
||||||
pub content: Option<String>,
|
pub content: Option<String>,
|
||||||
/// Attachments to include in message
|
/// Attachments to include in message
|
||||||
pub attachments: Option<Vec<String>>,
|
pub attachments: Option<Vec<String>>,
|
||||||
@@ -345,7 +339,7 @@ auto_derived!(
|
|||||||
#[cfg_attr(feature = "validator", derive(Validate))]
|
#[cfg_attr(feature = "validator", derive(Validate))]
|
||||||
pub struct DataEditMessage {
|
pub struct DataEditMessage {
|
||||||
/// New message content
|
/// New message content
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 2000)))]
|
||||||
pub content: Option<String>,
|
pub content: Option<String>,
|
||||||
/// Embeds to include in the message
|
/// Embeds to include in the message
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 10)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 10)))]
|
||||||
@@ -391,7 +385,6 @@ auto_derived!(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// Message Author Abstraction
|
/// Message Author Abstraction
|
||||||
#[derive(Clone)]
|
|
||||||
pub enum MessageAuthor<'a> {
|
pub enum MessageAuthor<'a> {
|
||||||
User(&'a User),
|
User(&'a User),
|
||||||
Webhook(&'a Webhook),
|
Webhook(&'a Webhook),
|
||||||
@@ -515,7 +508,6 @@ impl PushNotification {
|
|||||||
icon,
|
icon,
|
||||||
image,
|
image,
|
||||||
body,
|
body,
|
||||||
raw_body: None,
|
|
||||||
tag: channel.id().to_string(),
|
tag: channel.id().to_string(),
|
||||||
timestamp,
|
timestamp,
|
||||||
url: format!("{}/channel/{}/{}", config.hosts.app, channel.id(), msg.id),
|
url: format!("{}/channel/{}/{}", config.hosts.app, channel.id(), msg.id),
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ auto_derived!(
|
|||||||
/// Ban reason
|
/// Ban reason
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 1024)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 1024)))]
|
||||||
pub reason: Option<String>,
|
pub reason: Option<String>,
|
||||||
/// Messages to delete in seconds
|
|
||||||
#[cfg_attr(feature = "validator", validate(range(min = 0, max = 604800)))]
|
|
||||||
pub delete_message_seconds: Option<i64>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Just enough information to list a ban
|
/// Just enough information to list a ban
|
||||||
|
|||||||
@@ -106,9 +106,6 @@ auto_derived_partial!(
|
|||||||
/// Ranking of this role
|
/// Ranking of this role
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub rank: i64,
|
pub rank: i64,
|
||||||
/// Role icon
|
|
||||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
|
||||||
pub icon: Option<File>,
|
|
||||||
},
|
},
|
||||||
"PartialRole"
|
"PartialRole"
|
||||||
);
|
);
|
||||||
@@ -126,7 +123,6 @@ auto_derived!(
|
|||||||
/// Optional fields on server object
|
/// Optional fields on server object
|
||||||
pub enum FieldsRole {
|
pub enum FieldsRole {
|
||||||
Colour,
|
Colour,
|
||||||
Icon,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Channel category
|
/// Channel category
|
||||||
@@ -171,6 +167,9 @@ auto_derived!(
|
|||||||
/// Whether this server is age-restricted
|
/// Whether this server is age-restricted
|
||||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub nsfw: Option<bool>,
|
pub nsfw: Option<bool>,
|
||||||
|
/// Discord guild template to import from
|
||||||
|
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
|
pub discord_template_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about new role to create
|
/// Information about new role to create
|
||||||
@@ -256,9 +255,6 @@ auto_derived!(
|
|||||||
/// Must be enabled in order to show up on [Revolt Discover](https://rvlt.gg).
|
/// Must be enabled in order to show up on [Revolt Discover](https://rvlt.gg).
|
||||||
pub analytics: Option<bool>,
|
pub analytics: Option<bool>,
|
||||||
|
|
||||||
/// User id of the new owner
|
|
||||||
pub owner: Option<String>,
|
|
||||||
|
|
||||||
/// Fields to remove from server object
|
/// Fields to remove from server object
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Vec<FieldsServer>,
|
pub remove: Vec<FieldsServer>,
|
||||||
@@ -282,11 +278,6 @@ auto_derived!(
|
|||||||
///
|
///
|
||||||
/// **Removed** - no effect, use the edit server role positions route
|
/// **Removed** - no effect, use the edit server role positions route
|
||||||
pub rank: Option<i64>,
|
pub rank: Option<i64>,
|
||||||
/// Role icon
|
|
||||||
///
|
|
||||||
/// Provide an Autumn attachment Id.
|
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 128)))]
|
|
||||||
pub icon: Option<String>,
|
|
||||||
/// Fields to remove from role object
|
/// Fields to remove from role object
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Vec<FieldsRole>,
|
pub remove: Vec<FieldsRole>,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-parser"
|
name = "revolt-parser"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
||||||
@@ -8,4 +8,4 @@ description = "Revolt Backend: Message Parser"
|
|||||||
repository = "https://github.com/stoatchat/stoatchat"
|
repository = "https://github.com/stoatchat/stoatchat"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
logos = { workspace = true }
|
logos = { version = "0.15" }
|
||||||
+42
-125
@@ -16,29 +16,23 @@ pub enum MessageToken<'a> {
|
|||||||
UserMention(&'a str),
|
UserMention(&'a str),
|
||||||
#[regex("<%(?&id)>", |lex| &lex.slice()[2..lex.slice().len() - 1],)]
|
#[regex("<%(?&id)>", |lex| &lex.slice()[2..lex.slice().len() - 1],)]
|
||||||
RoleMention(&'a str),
|
RoleMention(&'a str),
|
||||||
#[regex("<#(?&id)>", |lex| &lex.slice()[2..lex.slice().len() - 1],)]
|
|
||||||
ChannelMention(&'a str),
|
|
||||||
#[regex(":(?&id):", |lex| &lex.slice()[1..lex.slice().len() - 1],)]
|
|
||||||
Emoji(&'a str),
|
|
||||||
#[token("@everyone")]
|
#[token("@everyone")]
|
||||||
MentionEveryone,
|
MentionEveryone,
|
||||||
#[token("@online")]
|
#[token("@online")]
|
||||||
MentionOnline,
|
MentionOnline
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
pub struct MessageResults {
|
pub struct MessageResults {
|
||||||
pub user_mentions: HashSet<String>,
|
pub user_mentions: HashSet<String>,
|
||||||
pub role_mentions: HashSet<String>,
|
pub role_mentions: HashSet<String>,
|
||||||
pub channel_mentions: HashSet<String>,
|
|
||||||
pub emojis: HashSet<String>,
|
|
||||||
pub mentions_everyone: bool,
|
pub mentions_everyone: bool,
|
||||||
pub mentions_online: bool,
|
pub mentions_online: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MessageParserIterator<'a, I> {
|
struct MessageParserIterator<'a, I> {
|
||||||
inner: I,
|
inner: I,
|
||||||
temp: VecDeque<MessageToken<'a>>,
|
temp: VecDeque<MessageToken<'a>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, I: Iterator<Item = MessageToken<'a>>> Iterator for MessageParserIterator<'a, I> {
|
impl<'a, I: Iterator<Item = MessageToken<'a>>> Iterator for MessageParserIterator<'a, I> {
|
||||||
@@ -61,11 +55,11 @@ impl<'a, I: Iterator<Item = MessageToken<'a>>> Iterator for MessageParserIterato
|
|||||||
if next_token == Some(MessageToken::CodeblockMarker(ty)) {
|
if next_token == Some(MessageToken::CodeblockMarker(ty)) {
|
||||||
self.temp.clear();
|
self.temp.clear();
|
||||||
self.temp.push_back(MessageToken::CodeblockMarker(ty));
|
self.temp.push_back(MessageToken::CodeblockMarker(ty));
|
||||||
break next_token;
|
break next_token
|
||||||
} else if let Some(token) = next_token {
|
} else if let Some(token) = next_token {
|
||||||
self.temp.push_back(token);
|
self.temp.push_back(token);
|
||||||
} else {
|
} else {
|
||||||
break Some(MessageToken::CodeblockMarker(ty));
|
break Some(MessageToken::CodeblockMarker(ty))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -75,10 +69,10 @@ impl<'a, I: Iterator<Item = MessageToken<'a>>> Iterator for MessageParserIterato
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_message_iter(text: &str) -> impl Iterator<Item = MessageToken<'_>> + '_ {
|
pub fn parse_message_iter(text: &str) -> impl Iterator<Item = MessageToken> + '_ {
|
||||||
MessageParserIterator {
|
MessageParserIterator {
|
||||||
inner: MessageToken::lexer(text).flatten(),
|
inner: MessageToken::lexer(text).flatten(),
|
||||||
temp: VecDeque::new(),
|
temp: VecDeque::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,23 +82,13 @@ pub fn parse_message(text: &str) -> MessageResults {
|
|||||||
for token in parse_message_iter(text) {
|
for token in parse_message_iter(text) {
|
||||||
match token {
|
match token {
|
||||||
MessageToken::Escape => {}
|
MessageToken::Escape => {}
|
||||||
MessageToken::CodeblockMarker(_) => {}
|
MessageToken::CodeblockMarker(_) => {},
|
||||||
MessageToken::UserMention(id) => {
|
MessageToken::UserMention(id) => { results.user_mentions.insert(id.to_string()); },
|
||||||
results.user_mentions.insert(id.to_string());
|
MessageToken::RoleMention(id) => { results.role_mentions.insert(id.to_string()); },
|
||||||
}
|
|
||||||
MessageToken::RoleMention(id) => {
|
|
||||||
results.role_mentions.insert(id.to_string());
|
|
||||||
}
|
|
||||||
MessageToken::ChannelMention(id) => {
|
|
||||||
results.channel_mentions.insert(id.to_string());
|
|
||||||
}
|
|
||||||
MessageToken::Emoji(id) => {
|
|
||||||
results.emojis.insert(id.to_string());
|
|
||||||
}
|
|
||||||
MessageToken::MentionEveryone => results.mentions_everyone = true,
|
MessageToken::MentionEveryone => results.mentions_everyone = true,
|
||||||
MessageToken::MentionOnline => results.mentions_online = true,
|
MessageToken::MentionOnline => results.mentions_online = true,
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
@@ -125,10 +109,7 @@ mod tests {
|
|||||||
let output = parse_message_iter("Hello <@01FD58YK5W7QRV5H3D64KTQYX3>.").collect::<Vec<_>>();
|
let output = parse_message_iter("Hello <@01FD58YK5W7QRV5H3D64KTQYX3>.").collect::<Vec<_>>();
|
||||||
|
|
||||||
assert_eq!(output.len(), 1);
|
assert_eq!(output.len(), 1);
|
||||||
assert_eq!(
|
assert_eq!(output[0], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
output[0],
|
|
||||||
MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -136,10 +117,7 @@ mod tests {
|
|||||||
let output = parse_message_iter("Hello <%01FD58YK5W7QRV5H3D64KTQYX3>.").collect::<Vec<_>>();
|
let output = parse_message_iter("Hello <%01FD58YK5W7QRV5H3D64KTQYX3>.").collect::<Vec<_>>();
|
||||||
|
|
||||||
assert_eq!(output.len(), 1);
|
assert_eq!(output.len(), 1);
|
||||||
assert_eq!(
|
assert_eq!(output[0], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
output[0],
|
|
||||||
MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -160,57 +138,29 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_everything() {
|
fn test_everything() {
|
||||||
let output = parse_message_iter("Hello <@01FD58YK5W7QRV5H3D64KTQYX3>, <%01FD58YK5W7QRV5H3D64KTQYX3>, <#01FD58YK5W7QRV5H3D64KTQYX3> @everyone and @online. :01FD58YK5W7QRV5H3D64KTQYX3:").collect::<Vec<_>>();
|
let output = parse_message_iter("Hello <@01FD58YK5W7QRV5H3D64KTQYX3>, <%01FD58YK5W7QRV5H3D64KTQYX3>, @everyone and @online.").collect::<Vec<_>>();
|
||||||
|
|
||||||
assert_eq!(output.len(), 6);
|
assert_eq!(output.len(), 4);
|
||||||
assert_eq!(
|
assert_eq!(output[0], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
output[0],
|
assert_eq!(output[1], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
assert_eq!(output[2], MessageToken::MentionEveryone);
|
||||||
);
|
assert_eq!(output[3], MessageToken::MentionOnline);
|
||||||
assert_eq!(
|
|
||||||
output[1],
|
|
||||||
MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
output[2],
|
|
||||||
MessageToken::ChannelMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
assert_eq!(output[3], MessageToken::MentionEveryone);
|
|
||||||
assert_eq!(output[4], MessageToken::MentionOnline);
|
|
||||||
assert_eq!(output[5], MessageToken::Emoji("01FD58YK5W7QRV5H3D64KTQYX3"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_everything_no_spaces() {
|
fn test_everything_no_spaces() {
|
||||||
let output = parse_message_iter(
|
let output = parse_message_iter("<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online").collect::<Vec<_>>();
|
||||||
"<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3><#01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online:01FD58YK5W7QRV5H3D64KTQYX3:",
|
|
||||||
)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
assert_eq!(output.len(), 6);
|
assert_eq!(output.len(), 4);
|
||||||
assert_eq!(
|
assert_eq!(output[0], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
output[0],
|
assert_eq!(output[1], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
assert_eq!(output[2], MessageToken::MentionEveryone);
|
||||||
);
|
assert_eq!(output[3], MessageToken::MentionOnline);
|
||||||
assert_eq!(
|
|
||||||
output[1],
|
|
||||||
MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
output[2],
|
|
||||||
MessageToken::ChannelMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
assert_eq!(output[3], MessageToken::MentionEveryone);
|
|
||||||
assert_eq!(output[4], MessageToken::MentionOnline);
|
|
||||||
assert_eq!(output[5], MessageToken::Emoji("01FD58YK5W7QRV5H3D64KTQYX3"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_codeblock_no_mentions() {
|
fn test_codeblock_no_mentions() {
|
||||||
let output = parse_message_iter(
|
let output = parse_message_iter("```\n<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online\n```").collect::<Vec<_>>();
|
||||||
"```\n<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3><#01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online:01FD58YK5W7QRV5H3D64KTQYX3:\n```",
|
|
||||||
)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
assert_eq!(output.len(), 2);
|
assert_eq!(output.len(), 2);
|
||||||
assert_eq!(output[0], MessageToken::CodeblockMarker(3));
|
assert_eq!(output[0], MessageToken::CodeblockMarker(3));
|
||||||
@@ -219,36 +169,19 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uncontained_codeblock_should_mention() {
|
fn test_uncontained_codeblock_should_mention() {
|
||||||
let output = parse_message_iter(
|
let output = parse_message_iter("```\n<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online").collect::<Vec<_>>();
|
||||||
"```\n<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3><#01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online:01FD58YK5W7QRV5H3D64KTQYX3:",
|
|
||||||
)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
assert_eq!(output.len(), 7);
|
assert_eq!(output.len(), 5);
|
||||||
assert_eq!(output[0], MessageToken::CodeblockMarker(3));
|
assert_eq!(output[0], MessageToken::CodeblockMarker(3));
|
||||||
assert_eq!(
|
assert_eq!(output[1], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
output[1],
|
assert_eq!(output[2], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
assert_eq!(output[3], MessageToken::MentionEveryone);
|
||||||
);
|
assert_eq!(output[4], MessageToken::MentionOnline);
|
||||||
assert_eq!(
|
|
||||||
output[2],
|
|
||||||
MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
output[3],
|
|
||||||
MessageToken::ChannelMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
assert_eq!(output[4], MessageToken::MentionEveryone);
|
|
||||||
assert_eq!(output[5], MessageToken::MentionOnline);
|
|
||||||
assert_eq!(output[6], MessageToken::Emoji("01FD58YK5W7QRV5H3D64KTQYX3"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_inline_codeblock_no_mentions() {
|
fn test_inline_codeblock_no_mentions() {
|
||||||
let output = parse_message_iter(
|
let output = parse_message_iter("`<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online`").collect::<Vec<_>>();
|
||||||
"`<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3><#01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online:01FD58YK5W7QRV5H3D64KTQYX3:`",
|
|
||||||
)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
assert_eq!(output.len(), 2);
|
assert_eq!(output.len(), 2);
|
||||||
assert_eq!(output[0], MessageToken::CodeblockMarker(1));
|
assert_eq!(output[0], MessageToken::CodeblockMarker(1));
|
||||||
@@ -257,33 +190,19 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uncontained_inline_codeblock_should_mention() {
|
fn test_uncontained_inline_codeblock_should_mention() {
|
||||||
let output = parse_message_iter(
|
let output = parse_message_iter("`<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online").collect::<Vec<_>>();
|
||||||
"`<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3><#01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online:01FD58YK5W7QRV5H3D64KTQYX3:",
|
|
||||||
)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
assert_eq!(output.len(), 7);
|
assert_eq!(output.len(), 5);
|
||||||
assert_eq!(output[0], MessageToken::CodeblockMarker(1));
|
assert_eq!(output[0], MessageToken::CodeblockMarker(1));
|
||||||
assert_eq!(
|
assert_eq!(output[1], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
output[1],
|
assert_eq!(output[2], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3"));
|
||||||
MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
assert_eq!(output[3], MessageToken::MentionEveryone);
|
||||||
);
|
assert_eq!(output[4], MessageToken::MentionOnline);
|
||||||
assert_eq!(
|
|
||||||
output[2],
|
|
||||||
MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
output[3],
|
|
||||||
MessageToken::ChannelMention("01FD58YK5W7QRV5H3D64KTQYX3")
|
|
||||||
);
|
|
||||||
assert_eq!(output[4], MessageToken::MentionEveryone);
|
|
||||||
assert_eq!(output[5], MessageToken::MentionOnline);
|
|
||||||
assert_eq!(output[6], MessageToken::Emoji("01FD58YK5W7QRV5H3D64KTQYX3"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_codeblock_with_language_no_mentions() {
|
fn test_codeblock_with_language_no_mentions() {
|
||||||
let output = parse_message_iter("```rust\n<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3><#01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online:01FD58YK5W7QRV5H3D64KTQYX3:```").collect::<Vec<_>>();
|
let output = parse_message_iter("```rust\n<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online```").collect::<Vec<_>>();
|
||||||
|
|
||||||
assert_eq!(output.len(), 2);
|
assert_eq!(output.len(), 2);
|
||||||
assert_eq!(output[0], MessageToken::CodeblockMarker(3));
|
assert_eq!(output[0], MessageToken::CodeblockMarker(3));
|
||||||
@@ -301,8 +220,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_double_inline_codeblock_with_backticks_inside() {
|
fn test_double_inline_codeblock_with_backticks_inside() {
|
||||||
let output =
|
let output = parse_message_iter("``this `should` not `ping` @everyone``").collect::<Vec<_>>();
|
||||||
parse_message_iter("``this `should` not `ping` @everyone``").collect::<Vec<_>>();
|
|
||||||
|
|
||||||
assert_eq!(output.len(), 2);
|
assert_eq!(output.len(), 2);
|
||||||
assert_eq!(output[0], MessageToken::CodeblockMarker(2));
|
assert_eq!(output[0], MessageToken::CodeblockMarker(2));
|
||||||
@@ -320,8 +238,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_escaped_codeblock() {
|
fn test_escaped_codeblock() {
|
||||||
let output =
|
let output = parse_message_iter("i am ~~not~~ pinging \\`@everyone` ok.").collect::<Vec<_>>();
|
||||||
parse_message_iter("i am ~~not~~ pinging \\`@everyone` ok.").collect::<Vec<_>>();
|
|
||||||
|
|
||||||
assert_eq!(output.len(), 3);
|
assert_eq!(output.len(), 3);
|
||||||
assert_eq!(output[0], MessageToken::Escape);
|
assert_eq!(output[0], MessageToken::Escape);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-permissions"
|
name = "revolt-permissions"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -18,23 +18,23 @@ try-from-primitive = ["dep:num_enum"]
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# Async
|
# Async
|
||||||
async-std = { workspace = true, features = ["attributes"] }
|
async-std = { version = "1.8.0", features = ["attributes"] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { workspace = true }
|
revolt-result = { version = "0.11.3", path = "../result" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
auto_ops = { workspace = true }
|
auto_ops = "0.3.0"
|
||||||
once_cell = { workspace = true }
|
once_cell = "1.17"
|
||||||
num_enum = { workspace = true, optional = true }
|
num_enum = { version = "0.6.1", optional = true }
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
async-trait = { workspace = true }
|
async-trait = "0.1.51"
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
serde = { workspace = true, optional = true }
|
serde = { version = "1", features = ["derive"], optional = true }
|
||||||
bson = { workspace = true, optional = true }
|
bson = { version = "2.1.0", optional = true }
|
||||||
|
|
||||||
# Spec Generation
|
# Spec Generation
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { version = "0.8.8", optional = true }
|
||||||
@@ -75,8 +75,6 @@ pub enum ChannelPermission {
|
|||||||
Masquerade = 1 << 28,
|
Masquerade = 1 << 28,
|
||||||
/// React to messages with emojis
|
/// React to messages with emojis
|
||||||
React = 1 << 29,
|
React = 1 << 29,
|
||||||
/// Bypass slowmode
|
|
||||||
BypassSlowmode = 1 << 39,
|
|
||||||
|
|
||||||
// * Voice permissions
|
// * Voice permissions
|
||||||
/// Connect to a voice channel
|
/// Connect to a voice channel
|
||||||
@@ -101,7 +99,7 @@ pub enum ChannelPermission {
|
|||||||
MentionRoles = 1 << 38,
|
MentionRoles = 1 << 38,
|
||||||
|
|
||||||
// * Misc. permissions
|
// * Misc. permissions
|
||||||
// % Bits 39 to 52: free area
|
// % Bits 38 to 52: free area
|
||||||
// % Bits 53 to 64: do not use
|
// % Bits 53 to 64: do not use
|
||||||
|
|
||||||
// * Grant all permissions
|
// * Grant all permissions
|
||||||
@@ -143,7 +141,7 @@ pub static DEFAULT_PERMISSION: Lazy<u64> = Lazy::new(|| {
|
|||||||
pub static DEFAULT_PERMISSION_SAVED_MESSAGES: u64 = ChannelPermission::GrantAllSafe as u64;
|
pub static DEFAULT_PERMISSION_SAVED_MESSAGES: u64 = ChannelPermission::GrantAllSafe as u64;
|
||||||
|
|
||||||
pub static DEFAULT_PERMISSION_DIRECT_MESSAGE: Lazy<u64> = Lazy::new(|| {
|
pub static DEFAULT_PERMISSION_DIRECT_MESSAGE: Lazy<u64> = Lazy::new(|| {
|
||||||
DEFAULT_PERMISSION.add(ChannelPermission::ManageChannel + ChannelPermission::React + ChannelPermission::Masquerade)
|
DEFAULT_PERMISSION.add(ChannelPermission::ManageChannel + ChannelPermission::React)
|
||||||
});
|
});
|
||||||
|
|
||||||
pub static DEFAULT_PERMISSION_SERVER: Lazy<u64> = Lazy::new(|| {
|
pub static DEFAULT_PERMISSION_SERVER: Lazy<u64> = Lazy::new(|| {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-presence"
|
name = "revolt-presence"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -14,16 +14,16 @@ redis-is-patched = []
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# Async
|
# Async
|
||||||
async-std = { workspace = true, features = ["attributes"] }
|
async-std = { version = "1.8.0", features = ["attributes"] }
|
||||||
|
|
||||||
# Config for loading Redis URI
|
# Config for loading Redis URI
|
||||||
revolt-config = { workspace = true }
|
revolt-config = { version = "0.11.3", path = "../config" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
log = { workspace = true }
|
log = "0.4.17"
|
||||||
rand = { workspace = true }
|
rand = "0.8.5"
|
||||||
once_cell = { workspace = true }
|
once_cell = "1.17.1"
|
||||||
|
|
||||||
# Redis
|
# Redis
|
||||||
redis-kiss = { workspace = true }
|
redis-kiss = "0.1.4"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-ratelimits"
|
name = "revolt-ratelimits"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
||||||
@@ -18,17 +18,17 @@ axum = ["dep:axum", "revolt-database/axum-impl"]
|
|||||||
default = ["rocket", "axum"]
|
default = ["rocket", "axum"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
revolt-database = { workspace = true }
|
revolt-database = { version = "0.11.3", path = "../database" }
|
||||||
revolt-result = { workspace = true }
|
revolt-result = { version = "0.11.3", path = "../result" }
|
||||||
revolt-config = { workspace = true }
|
revolt-config = { version = "0.11.3", path = "../config" }
|
||||||
|
|
||||||
rocket = { workspace = true, optional = true }
|
rocket = { version = "0.5.1", optional = true }
|
||||||
revolt_rocket_okapi = { workspace = true, optional = true }
|
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
||||||
|
|
||||||
axum = { workspace = true, optional = true, features = ["macros"] }
|
axum = { version = "0.7.5", optional = true, features = ["macros"] }
|
||||||
|
|
||||||
serde = { workspace = true }
|
serde = { version = "1", features = ["derive"] }
|
||||||
authifier = { workspace = true }
|
authifier = { version = "1.0.16" }
|
||||||
dashmap = { workspace = true }
|
dashmap = "5.2.0"
|
||||||
async-trait = { workspace = true }
|
async-trait = "0.1.81"
|
||||||
log = { workspace = true }
|
log = "0.4"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-result"
|
name = "revolt-result"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -22,21 +22,21 @@ default = ["serde", "sentry"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Serialisation
|
# Serialisation
|
||||||
serde_json = { workspace = true, optional = true }
|
serde_json = { version = "1", optional = true }
|
||||||
serde = { workspace = true, optional = true }
|
serde = { version = "1", features = ["derive"], optional = true }
|
||||||
|
|
||||||
# Spec Generation
|
# Spec Generation
|
||||||
schemars = { workspace = true, optional = true }
|
schemars = { version = "0.8.8", optional = true }
|
||||||
utoipa = { workspace = true, optional = true }
|
utoipa = { version = "4.2.3", optional = true }
|
||||||
|
|
||||||
# Rocket
|
# Rocket
|
||||||
rocket = { workspace = true, optional = true }
|
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false }
|
||||||
revolt_rocket_okapi = { workspace = true, optional = true }
|
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
||||||
revolt_okapi = { workspace = true, optional = true }
|
revolt_okapi = { version = "0.9.1", optional = true }
|
||||||
|
|
||||||
# utilities
|
# utilities
|
||||||
log = { workspace = true }
|
log = "0.4"
|
||||||
# Axum
|
# Axum
|
||||||
axum = { workspace = true, optional = true }
|
axum = { version = "0.7.5", optional = true }
|
||||||
|
|
||||||
sentry = { workspace = true, optional = true }
|
sentry = { version = "0.31.5", optional = true }
|
||||||
@@ -24,7 +24,6 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::UnknownChannel => StatusCode::NOT_FOUND,
|
ErrorType::UnknownChannel => StatusCode::NOT_FOUND,
|
||||||
ErrorType::UnknownMessage => StatusCode::NOT_FOUND,
|
ErrorType::UnknownMessage => StatusCode::NOT_FOUND,
|
||||||
ErrorType::UnknownAttachment => StatusCode::BAD_REQUEST,
|
ErrorType::UnknownAttachment => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::CannotDeleteMessage => StatusCode::FORBIDDEN,
|
|
||||||
ErrorType::CannotEditMessage => StatusCode::FORBIDDEN,
|
ErrorType::CannotEditMessage => StatusCode::FORBIDDEN,
|
||||||
ErrorType::CannotJoinCall => StatusCode::BAD_REQUEST,
|
ErrorType::CannotJoinCall => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::TooManyAttachments { .. } => StatusCode::BAD_REQUEST,
|
ErrorType::TooManyAttachments { .. } => StatusCode::BAD_REQUEST,
|
||||||
@@ -37,9 +36,7 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::NotInGroup => StatusCode::NOT_FOUND,
|
ErrorType::NotInGroup => StatusCode::NOT_FOUND,
|
||||||
ErrorType::AlreadyPinned => StatusCode::BAD_REQUEST,
|
ErrorType::AlreadyPinned => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::NotPinned => StatusCode::BAD_REQUEST,
|
ErrorType::NotPinned => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::InSlowmode { retry_after: _ } => StatusCode::TOO_MANY_REQUESTS,
|
|
||||||
|
|
||||||
ErrorType::CantCreateServers => StatusCode::FORBIDDEN,
|
|
||||||
ErrorType::UnknownServer => StatusCode::NOT_FOUND,
|
ErrorType::UnknownServer => StatusCode::NOT_FOUND,
|
||||||
ErrorType::InvalidRole => StatusCode::NOT_FOUND,
|
ErrorType::InvalidRole => StatusCode::NOT_FOUND,
|
||||||
ErrorType::Banned => StatusCode::FORBIDDEN,
|
ErrorType::Banned => StatusCode::FORBIDDEN,
|
||||||
@@ -77,7 +74,7 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::DuplicateNonce => StatusCode::CONFLICT,
|
ErrorType::DuplicateNonce => StatusCode::CONFLICT,
|
||||||
ErrorType::VosoUnavailable => StatusCode::BAD_REQUEST,
|
ErrorType::VosoUnavailable => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::NotFound => StatusCode::NOT_FOUND,
|
ErrorType::NotFound => StatusCode::NOT_FOUND,
|
||||||
ErrorType::NoEffect => StatusCode::BAD_REQUEST,
|
ErrorType::NoEffect => StatusCode::OK,
|
||||||
ErrorType::FailedValidation { .. } => StatusCode::BAD_REQUEST,
|
ErrorType::FailedValidation { .. } => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::LiveKitUnavailable => StatusCode::BAD_REQUEST,
|
ErrorType::LiveKitUnavailable => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::NotConnected => StatusCode::BAD_REQUEST,
|
ErrorType::NotConnected => StatusCode::BAD_REQUEST,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::fmt::Display;
|
|
||||||
use std::panic::Location;
|
use std::panic::Location;
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@@ -78,7 +78,6 @@ pub enum ErrorType {
|
|||||||
UnknownChannel,
|
UnknownChannel,
|
||||||
UnknownAttachment,
|
UnknownAttachment,
|
||||||
UnknownMessage,
|
UnknownMessage,
|
||||||
CannotDeleteMessage,
|
|
||||||
CannotEditMessage,
|
CannotEditMessage,
|
||||||
CannotJoinCall,
|
CannotJoinCall,
|
||||||
TooManyAttachments {
|
TooManyAttachments {
|
||||||
@@ -103,12 +102,8 @@ pub enum ErrorType {
|
|||||||
NotInGroup,
|
NotInGroup,
|
||||||
AlreadyPinned,
|
AlreadyPinned,
|
||||||
NotPinned,
|
NotPinned,
|
||||||
InSlowmode {
|
|
||||||
retry_after: u64,
|
|
||||||
},
|
|
||||||
|
|
||||||
// ? Server related errors
|
// ? Server related errors
|
||||||
CantCreateServers,
|
|
||||||
UnknownServer,
|
UnknownServer,
|
||||||
InvalidRole,
|
InvalidRole,
|
||||||
Banned,
|
Banned,
|
||||||
@@ -237,16 +232,17 @@ impl<T, E: std::fmt::Debug + std::error::Error> ToRevoltError<T> for Result<T, E
|
|||||||
fn to_internal_error(self) -> Result<T, Error> {
|
fn to_internal_error(self) -> Result<T, Error> {
|
||||||
let loc = Location::caller();
|
let loc = Location::caller();
|
||||||
|
|
||||||
self.map_err(|e| {
|
self
|
||||||
log::error!("{e:?}");
|
.map_err(|e| {
|
||||||
#[cfg(feature = "sentry")]
|
log::error!("{e:?}");
|
||||||
sentry::capture_error(&e);
|
#[cfg(feature = "sentry")]
|
||||||
|
sentry::capture_error(&e);
|
||||||
|
|
||||||
Error {
|
Error {
|
||||||
error_type: ErrorType::InternalError,
|
error_type: ErrorType::InternalError,
|
||||||
location: format!("{}:{}:{}", loc.file(), loc.line(), loc.column()),
|
location: format!("{}:{}:{}", loc.file(), loc.line(), loc.column())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,9 +251,11 @@ impl<T> ToRevoltError<T> for Option<T> {
|
|||||||
fn to_internal_error(self) -> Result<T, Error> {
|
fn to_internal_error(self) -> Result<T, Error> {
|
||||||
let loc = Location::caller();
|
let loc = Location::caller();
|
||||||
|
|
||||||
self.ok_or_else(|| Error {
|
self.ok_or_else(|| {
|
||||||
error_type: ErrorType::InternalError,
|
Error {
|
||||||
location: format!("{}:{}:{}", loc.file(), loc.line(), loc.column()),
|
error_type: ErrorType::InternalError,
|
||||||
|
location: format!("{}:{}:{}", loc.file(), loc.line(), loc.column())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ impl<'r> Responder<'r, 'static> for Error {
|
|||||||
ErrorType::UnknownChannel => Status::NotFound,
|
ErrorType::UnknownChannel => Status::NotFound,
|
||||||
ErrorType::UnknownMessage => Status::NotFound,
|
ErrorType::UnknownMessage => Status::NotFound,
|
||||||
ErrorType::UnknownAttachment => Status::BadRequest,
|
ErrorType::UnknownAttachment => Status::BadRequest,
|
||||||
ErrorType::CannotDeleteMessage => Status::Forbidden,
|
|
||||||
ErrorType::CannotEditMessage => Status::Forbidden,
|
ErrorType::CannotEditMessage => Status::Forbidden,
|
||||||
ErrorType::CannotJoinCall => Status::BadRequest,
|
ErrorType::CannotJoinCall => Status::BadRequest,
|
||||||
ErrorType::TooManyAttachments { .. } => Status::BadRequest,
|
ErrorType::TooManyAttachments { .. } => Status::BadRequest,
|
||||||
@@ -43,10 +42,8 @@ impl<'r> Responder<'r, 'static> for Error {
|
|||||||
ErrorType::NotInGroup => Status::NotFound,
|
ErrorType::NotInGroup => Status::NotFound,
|
||||||
ErrorType::AlreadyPinned => Status::BadRequest,
|
ErrorType::AlreadyPinned => Status::BadRequest,
|
||||||
ErrorType::NotPinned => Status::BadRequest,
|
ErrorType::NotPinned => Status::BadRequest,
|
||||||
ErrorType::InSlowmode { retry_after: _ } => Status::TooManyRequests,
|
|
||||||
ErrorType::InvalidFlagValue => Status::BadRequest,
|
ErrorType::InvalidFlagValue => Status::BadRequest,
|
||||||
|
|
||||||
ErrorType::CantCreateServers => Status::Forbidden,
|
|
||||||
ErrorType::UnknownServer => Status::NotFound,
|
ErrorType::UnknownServer => Status::NotFound,
|
||||||
ErrorType::InvalidRole => Status::NotFound,
|
ErrorType::InvalidRole => Status::NotFound,
|
||||||
ErrorType::Banned => Status::Forbidden,
|
ErrorType::Banned => Status::Forbidden,
|
||||||
@@ -83,7 +80,7 @@ impl<'r> Responder<'r, 'static> for Error {
|
|||||||
ErrorType::NotAuthenticated => Status::Unauthorized,
|
ErrorType::NotAuthenticated => Status::Unauthorized,
|
||||||
ErrorType::DuplicateNonce => Status::Conflict,
|
ErrorType::DuplicateNonce => Status::Conflict,
|
||||||
ErrorType::NotFound => Status::NotFound,
|
ErrorType::NotFound => Status::NotFound,
|
||||||
ErrorType::NoEffect => Status::BadRequest,
|
ErrorType::NoEffect => Status::Ok,
|
||||||
ErrorType::FailedValidation { .. } => Status::BadRequest,
|
ErrorType::FailedValidation { .. } => Status::BadRequest,
|
||||||
ErrorType::LiveKitUnavailable => Status::BadRequest,
|
ErrorType::LiveKitUnavailable => Status::BadRequest,
|
||||||
ErrorType::NotAVoiceChannel => Status::BadRequest,
|
ErrorType::NotAVoiceChannel => Status::BadRequest,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-crond"
|
name = "revolt-crond"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -11,27 +11,13 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
log = { workspace = true }
|
log = "0.4"
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
tokio = { workspace = true }
|
tokio = { version = "1" }
|
||||||
|
|
||||||
# Redis
|
|
||||||
redis-kiss = { workspace = true }
|
|
||||||
|
|
||||||
# RabbitMQ
|
|
||||||
lapin = { workspace = true }
|
|
||||||
futures-lite = { workspace = true }
|
|
||||||
|
|
||||||
# Processing
|
|
||||||
serde_json = { workspace = true }
|
|
||||||
revolt_optional_struct = { workspace = true }
|
|
||||||
serde = { workspace = true }
|
|
||||||
iso8601-timestamp = { workspace = true, features = ["serde", "bson"] }
|
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-database = { workspace = true }
|
revolt-database = { version = "0.11.3", path = "../../core/database" }
|
||||||
revolt-result = { workspace = true }
|
revolt-result = { version = "0.11.3", path = "../../core/result" }
|
||||||
revolt-config = { workspace = true }
|
revolt-config = { version = "0.11.3", path = "../../core/config" }
|
||||||
revolt-files = { workspace = true }
|
revolt-files = { version = "0.11.3", path = "../../core/files" }
|
||||||
revolt-permissions = { workspace = true }
|
|
||||||
@@ -5,7 +5,6 @@ FROM debian:12 AS debian
|
|||||||
# Bundle Stage
|
# Bundle Stage
|
||||||
FROM gcr.io/distroless/cc-debian12:nonroot
|
FROM gcr.io/distroless/cc-debian12:nonroot
|
||||||
COPY --from=builder /home/rust/src/target/release/revolt-crond ./
|
COPY --from=builder /home/rust/src/target/release/revolt-crond ./
|
||||||
COPY --from=debian /usr/bin/uname /usr/bin/uname
|
|
||||||
|
|
||||||
USER nonroot
|
USER nonroot
|
||||||
CMD ["./revolt-crond"]
|
CMD ["./revolt-crond"]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use revolt_config::configure;
|
use revolt_config::configure;
|
||||||
use revolt_database::DatabaseInfo;
|
use revolt_database::DatabaseInfo;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
use tasks::{acks, file_deletion, prune_dangling_files, prune_members};
|
use tasks::{file_deletion, prune_dangling_files, prune_members};
|
||||||
use tokio::try_join;
|
use tokio::try_join;
|
||||||
|
|
||||||
pub mod tasks;
|
pub mod tasks;
|
||||||
@@ -14,8 +14,7 @@ async fn main() -> Result<()> {
|
|||||||
try_join!(
|
try_join!(
|
||||||
file_deletion::task(db.clone()),
|
file_deletion::task(db.clone()),
|
||||||
prune_dangling_files::task(db.clone()),
|
prune_dangling_files::task(db.clone()),
|
||||||
prune_members::task(db.clone()),
|
prune_members::task(db.clone())
|
||||||
acks::task(db.clone())
|
|
||||||
)
|
)
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
use futures_lite::stream::StreamExt;
|
|
||||||
use lapin::{
|
|
||||||
options::*,
|
|
||||||
types::FieldTable,
|
|
||||||
uri::{AMQPAuthority, AMQPQueryString, AMQPUri, AMQPUserInfo},
|
|
||||||
ConnectionBuilder, ConnectionProperties,
|
|
||||||
};
|
|
||||||
use log::info;
|
|
||||||
use redis_kiss::{get_connection, AsyncCommands, Conn as RedisConnection};
|
|
||||||
use revolt_config::config;
|
|
||||||
use revolt_database::{events::rabbit::AckEventPayload, Database};
|
|
||||||
use revolt_result::{Result, ToRevoltError};
|
|
||||||
use serde_json;
|
|
||||||
|
|
||||||
pub async fn task(db: Database) -> Result<()> {
|
|
||||||
let config = config().await;
|
|
||||||
|
|
||||||
let mut redis = get_connection()
|
|
||||||
.await
|
|
||||||
.expect("Failed to get redis connection");
|
|
||||||
|
|
||||||
let uri = AMQPUri {
|
|
||||||
scheme: lapin::uri::AMQPScheme::AMQP,
|
|
||||||
authority: AMQPAuthority {
|
|
||||||
userinfo: AMQPUserInfo {
|
|
||||||
username: config.rabbit.username,
|
|
||||||
password: config.rabbit.password,
|
|
||||||
},
|
|
||||||
host: config.rabbit.host,
|
|
||||||
port: config.rabbit.port,
|
|
||||||
},
|
|
||||||
vhost: "/".to_string(),
|
|
||||||
query: AMQPQueryString::default(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let connection = ConnectionBuilder::new()
|
|
||||||
.expect("Builder")
|
|
||||||
.with_uri(uri)
|
|
||||||
.with_properties(ConnectionProperties::default())
|
|
||||||
.connect()
|
|
||||||
.await
|
|
||||||
.expect("Failed to connect to rabbitmq");
|
|
||||||
|
|
||||||
let reader_channel = connection
|
|
||||||
.create_channel()
|
|
||||||
.await
|
|
||||||
.expect("Failed to create channel");
|
|
||||||
|
|
||||||
let mut consumer = reader_channel
|
|
||||||
.basic_consume(
|
|
||||||
config.rabbit.queues.acks.into(),
|
|
||||||
"crond-ack-consumer".into(),
|
|
||||||
BasicConsumeOptions::default(),
|
|
||||||
FieldTable::default(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.expect("Failed to create consumer");
|
|
||||||
|
|
||||||
while let Some(delivery) = consumer.next().await {
|
|
||||||
if let Ok(delivery) = delivery {
|
|
||||||
let payload: std::result::Result<AckEventPayload, _> =
|
|
||||||
serde_json::from_slice(&delivery.data);
|
|
||||||
if let Ok(payload) = payload {
|
|
||||||
info!("{:?}", payload);
|
|
||||||
if let Err(e) = process_channel_ack(
|
|
||||||
&db,
|
|
||||||
payload.user_id,
|
|
||||||
payload.channel_id.unwrap(),
|
|
||||||
&mut redis,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
revolt_config::capture_error(&e);
|
|
||||||
_ = delivery.reject(BasicRejectOptions { requeue: false }).await;
|
|
||||||
} else {
|
|
||||||
_ = delivery.ack(BasicAckOptions { multiple: false }).await;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
revolt_config::capture_message(
|
|
||||||
format!("Failed to decode ack data: {:?}", delivery.data).as_str(),
|
|
||||||
revolt_config::Level::Error,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(clippy::disallowed_methods)]
|
|
||||||
async fn process_channel_ack(
|
|
||||||
db: &Database,
|
|
||||||
user: String,
|
|
||||||
channel: String,
|
|
||||||
redis: &mut RedisConnection,
|
|
||||||
) -> Result<()> {
|
|
||||||
let message_id: Option<String> = redis
|
|
||||||
.get_del(format!("acker:{user}+{channel}"))
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
|
|
||||||
if let Some(message_id) = message_id {
|
|
||||||
// This will be uncommented eventually, but we need to sort out the transition to lapin first. For now we'll simply disable the badge update logic.
|
|
||||||
// We also drop a db request as a bonus.
|
|
||||||
|
|
||||||
//let unread = db.fetch_unread(&user, &channel).await?;
|
|
||||||
let _updated = db.acknowledge_message(&channel, &user, &message_id).await?;
|
|
||||||
info!("Set new state for ack: {}:{}:{}", channel, user, message_id);
|
|
||||||
|
|
||||||
// if let (Some(before), Some(after)) = (unread, updated) {
|
|
||||||
// let before_mentions = before.mentions.unwrap_or_default().len();
|
|
||||||
// let after_mentions = after.mentions.unwrap_or_default().len();
|
|
||||||
|
|
||||||
// let mentions_acked = before_mentions - after_mentions;
|
|
||||||
|
|
||||||
// if mentions_acked > 0 {
|
|
||||||
// if let Err(err) = amqp
|
|
||||||
// .ack_message(user.to_string(), channel.to_string(), payload.message_id)
|
|
||||||
// .await
|
|
||||||
// {
|
|
||||||
// revolt_config::capture_error(&err);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(message_id.to_internal_error().expect_err("no err"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,24 +11,22 @@ pub async fn task(db: Database) -> Result<()> {
|
|||||||
let files = db.fetch_deleted_attachments().await?;
|
let files = db.fetch_deleted_attachments().await?;
|
||||||
|
|
||||||
for file in files {
|
for file in files {
|
||||||
if let Some(hash) = &file.hash {
|
let count = db
|
||||||
let count = db
|
.count_file_hash_references(file.hash.as_ref().expect("no `hash` present"))
|
||||||
.count_file_hash_references(hash)
|
.await?;
|
||||||
|
|
||||||
|
// No other files reference this file on disk anymore
|
||||||
|
if count <= 1 {
|
||||||
|
let file_hash = db
|
||||||
|
.fetch_attachment_hash(file.hash.as_ref().expect("no `hash` present"))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// No other files reference this file on disk anymore
|
// Delete from S3
|
||||||
if count <= 1 {
|
delete_from_s3(&file_hash.bucket_id, &file_hash.path).await?;
|
||||||
let file_hash = db
|
|
||||||
.fetch_attachment_hash(hash)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
// Delete from S3
|
// Delete the hash
|
||||||
delete_from_s3(&file_hash.bucket_id, &file_hash.path).await?;
|
db.delete_attachment_hash(&file_hash.id).await?;
|
||||||
|
info!("Deleted file hash {}", file_hash.id);
|
||||||
// Delete the hash
|
|
||||||
db.delete_attachment_hash(&file_hash.id).await?;
|
|
||||||
info!("Deleted file hash {}", file_hash.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the file
|
// Delete the file
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
pub mod acks;
|
|
||||||
pub mod file_deletion;
|
pub mod file_deletion;
|
||||||
pub mod prune_dangling_files;
|
pub mod prune_dangling_files;
|
||||||
pub mod prune_members;
|
pub mod prune_members;
|
||||||
@@ -1,40 +1,43 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-pushd"
|
name = "revolt-pushd"
|
||||||
version = "0.13.5"
|
version = "0.11.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
revolt-result = { workspace = true }
|
revolt-result = { version = "0.11.3", path = "../../core/result" }
|
||||||
revolt-config = { workspace = true, features = ["report-macros", "anyhow"] }
|
revolt-config = { version = "0.11.3", path = "../../core/config", features = [
|
||||||
revolt-database = { workspace = true }
|
"report-macros",
|
||||||
revolt-models = { workspace = true, features = ["validator"] }
|
"anyhow",
|
||||||
revolt-presence = { workspace = true, features = ["redis-is-patched"] }
|
] }
|
||||||
revolt-parser = { workspace = true }
|
revolt-database = { version = "0.11.3", path = "../../core/database" }
|
||||||
|
revolt-models = { version = "0.11.3", path = "../../core/models", features = [
|
||||||
|
"validator",
|
||||||
|
] }
|
||||||
|
revolt-presence = { version = "0.11.3", path = "../../core/presence", features = [
|
||||||
|
"redis-is-patched",
|
||||||
|
] }
|
||||||
|
|
||||||
anyhow = { workspace = true }
|
anyhow = { version = "1.0.98" }
|
||||||
|
|
||||||
amqprs = { workspace = true }
|
amqprs = { version = "1.7.0" }
|
||||||
fcm_v1 = { workspace = true }
|
fcm_v1 = "0.3.0"
|
||||||
web-push = { workspace = true }
|
web-push = "0.10.0"
|
||||||
isahc = { workspace = true, features = ["json"], optional = true }
|
isahc = { optional = true, version = "1.7", features = ["json"] }
|
||||||
revolt_a2 = { workspace = true, features = ["ring"] }
|
revolt_a2 = { version = "0.10", default-features = false, features = ["ring"] }
|
||||||
redis-kiss = { workspace = true }
|
tokio = "1.39.2"
|
||||||
tokio = { workspace = true }
|
async-trait = "0.1.81"
|
||||||
async-trait = { workspace = true }
|
ulid = "1.0.0"
|
||||||
ulid = { workspace = true }
|
|
||||||
|
|
||||||
authifier = { workspace = true }
|
authifier = "1.0.16"
|
||||||
|
|
||||||
log = { workspace = true }
|
log = "0.4.11"
|
||||||
pretty_env_logger = { workspace = true }
|
pretty_env_logger = "0.4.0"
|
||||||
|
|
||||||
regex = { workspace = true }
|
|
||||||
|
|
||||||
#serialization
|
#serialization
|
||||||
serde_json = { workspace = true }
|
serde_json = "1"
|
||||||
revolt_optional_struct = { workspace = true }
|
revolt_optional_struct = "0.2.0"
|
||||||
serde = { workspace = true }
|
serde = { version = "1", features = ["derive"] }
|
||||||
iso8601-timestamp = { workspace = true, features = ["serde", "bson"] }
|
iso8601-timestamp = { version = "0.2.10", features = ["serde", "bson"] }
|
||||||
base64 = { workspace = true }
|
base64 = "0.22.1"
|
||||||
@@ -128,7 +128,7 @@ impl DmCallConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ impl FRAcceptedConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ impl FRReceivedConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ impl GenericConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::{
|
|||||||
hash::RandomState,
|
hash::RandomState,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{consumers::inbound::internal::*, utils};
|
use crate::consumers::inbound::internal::*;
|
||||||
use amqprs::{
|
use amqprs::{
|
||||||
channel::{BasicPublishArguments, Channel},
|
channel::{BasicPublishArguments, Channel},
|
||||||
connection::Connection,
|
connection::Connection,
|
||||||
@@ -17,7 +17,6 @@ use revolt_database::{
|
|||||||
MessageFlagsValue,
|
MessageFlagsValue,
|
||||||
};
|
};
|
||||||
use revolt_models::v0::{MessageFlags, PushNotification};
|
use revolt_models::v0::{MessageFlags, PushNotification};
|
||||||
use revolt_result::ToRevoltError;
|
|
||||||
|
|
||||||
pub struct MassMessageConsumer {
|
pub struct MassMessageConsumer {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -105,7 +104,7 @@ impl MassMessageConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
@@ -130,17 +129,7 @@ impl MassMessageConsumer {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let config = revolt_config::config().await;
|
let config = revolt_config::config().await;
|
||||||
let content = String::from_utf8(content)?;
|
let content = String::from_utf8(content)?;
|
||||||
let mut payload: MassMessageSentPayload = serde_json::from_str(content.as_str())?;
|
let payload: MassMessageSentPayload = serde_json::from_str(content.as_str())?;
|
||||||
|
|
||||||
for push in payload.notifications.iter_mut() {
|
|
||||||
if let Ok(body) = utils::render_notification_content(push, &self.db)
|
|
||||||
.await
|
|
||||||
.to_internal_error()
|
|
||||||
{
|
|
||||||
push.raw_body = Some(push.body.clone());
|
|
||||||
push.body = body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("Received mass message event");
|
debug!("Received mass message event");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{consumers::inbound::internal::*, utils};
|
use crate::consumers::inbound::internal::*;
|
||||||
use amqprs::{
|
use amqprs::{
|
||||||
channel::{BasicPublishArguments, Channel},
|
channel::{BasicPublishArguments, Channel},
|
||||||
connection::Connection,
|
connection::Connection,
|
||||||
@@ -11,7 +11,6 @@ use anyhow::Result;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use revolt_database::{events::rabbit::*, Database};
|
use revolt_database::{events::rabbit::*, Database};
|
||||||
use revolt_result::ToRevoltError;
|
|
||||||
|
|
||||||
pub struct MessageConsumer {
|
pub struct MessageConsumer {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -65,15 +64,7 @@ impl MessageConsumer {
|
|||||||
content: Vec<u8>,
|
content: Vec<u8>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let content = String::from_utf8(content)?;
|
let content = String::from_utf8(content)?;
|
||||||
let mut payload: MessageSentPayload = serde_json::from_str(content.as_str())?;
|
let payload: MessageSentPayload = serde_json::from_str(content.as_str())?;
|
||||||
|
|
||||||
if let Ok(body) = utils::render_notification_content(&payload.notification, &self.db)
|
|
||||||
.await
|
|
||||||
.to_internal_error()
|
|
||||||
{
|
|
||||||
payload.notification.raw_body = Some(payload.notification.body);
|
|
||||||
payload.notification.body = body;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("Received message event on origin");
|
debug!("Received message event on origin");
|
||||||
|
|
||||||
@@ -116,7 +107,7 @@ impl MessageConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ use amqprs::{channel::Channel as AmqpChannel, consumer::AsyncConsumer, BasicProp
|
|||||||
use anyhow::{anyhow, bail, Result};
|
use anyhow::{anyhow, bail, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use fcm_v1::{
|
use fcm_v1::{
|
||||||
|
android::{AndroidConfig, AndroidMessagePriority},
|
||||||
auth::{Authenticator, ServiceAccountKey},
|
auth::{Authenticator, ServiceAccountKey},
|
||||||
message::Message,
|
message::{Message, Notification},
|
||||||
Client, Error as FcmError,
|
Client, Error as FcmError,
|
||||||
};
|
};
|
||||||
use revolt_config::config;
|
use revolt_config::config;
|
||||||
@@ -14,102 +15,6 @@ use revolt_database::{events::rabbit::*, Database};
|
|||||||
use revolt_models::v0::{Channel, PushNotification};
|
use revolt_models::v0::{Channel, PushNotification};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
/// Custom notification data
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
|
||||||
pub enum NotificationData {
|
|
||||||
FRReceived {
|
|
||||||
id: String,
|
|
||||||
username: String,
|
|
||||||
},
|
|
||||||
FRAccepted {
|
|
||||||
id: String,
|
|
||||||
username: String,
|
|
||||||
},
|
|
||||||
Generic {
|
|
||||||
title: String,
|
|
||||||
body: String,
|
|
||||||
image: Option<String>,
|
|
||||||
},
|
|
||||||
Message {
|
|
||||||
title: String,
|
|
||||||
body: String,
|
|
||||||
image: String,
|
|
||||||
tag: String,
|
|
||||||
},
|
|
||||||
DmCallStartEnd {
|
|
||||||
initiator_id: String,
|
|
||||||
channel_id: String,
|
|
||||||
started_at: String,
|
|
||||||
ended: bool,
|
|
||||||
duration: usize,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NotificationData {
|
|
||||||
pub fn get_type(&self) -> &str {
|
|
||||||
match self {
|
|
||||||
NotificationData::FRReceived { .. } => "push.fr.receive",
|
|
||||||
NotificationData::FRAccepted { .. } => "push.fr.accept",
|
|
||||||
NotificationData::Generic { .. } => "push.generic",
|
|
||||||
NotificationData::Message { .. } => "push.message",
|
|
||||||
NotificationData::DmCallStartEnd { .. } => "push.dm.call",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn into_payload(self) -> HashMap<String, Value> {
|
|
||||||
let mut data = HashMap::new();
|
|
||||||
data.insert(
|
|
||||||
"type".to_string(),
|
|
||||||
Value::String(self.get_type().to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
match self {
|
|
||||||
NotificationData::FRReceived { id, username } => {
|
|
||||||
data.insert("id".to_string(), Value::String(id));
|
|
||||||
data.insert("username".to_string(), Value::String(username));
|
|
||||||
}
|
|
||||||
NotificationData::FRAccepted { id, username } => {
|
|
||||||
data.insert("id".to_string(), Value::String(id));
|
|
||||||
data.insert("username".to_string(), Value::String(username));
|
|
||||||
}
|
|
||||||
NotificationData::Generic { title, body, image } => {
|
|
||||||
data.insert("title".to_string(), Value::String(title));
|
|
||||||
data.insert("body".to_string(), Value::String(body));
|
|
||||||
|
|
||||||
if let Some(image) = image {
|
|
||||||
data.insert("image".to_string(), Value::String(image));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NotificationData::Message {
|
|
||||||
title,
|
|
||||||
body,
|
|
||||||
image,
|
|
||||||
tag,
|
|
||||||
} => {
|
|
||||||
data.insert("title".to_string(), Value::String(title));
|
|
||||||
data.insert("body".to_string(), Value::String(body));
|
|
||||||
data.insert("image".to_string(), Value::String(image));
|
|
||||||
data.insert("tag".to_string(), Value::String(tag));
|
|
||||||
}
|
|
||||||
NotificationData::DmCallStartEnd {
|
|
||||||
initiator_id,
|
|
||||||
channel_id,
|
|
||||||
started_at,
|
|
||||||
ended,
|
|
||||||
duration,
|
|
||||||
} => {
|
|
||||||
data.insert("initiator_id".to_string(), Value::String(initiator_id));
|
|
||||||
data.insert("channel_id".to_string(), Value::String(channel_id));
|
|
||||||
data.insert("started_at".to_string(), Value::String(started_at));
|
|
||||||
data.insert("ended".to_string(), Value::Bool(ended));
|
|
||||||
data.insert("duration".to_string(), Value::Number(duration.into()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct FcmOutboundConsumer {
|
pub struct FcmOutboundConsumer {
|
||||||
db: Database,
|
db: Database,
|
||||||
client: Client,
|
client: Client,
|
||||||
@@ -188,14 +93,17 @@ impl FcmOutboundConsumer {
|
|||||||
.clone()
|
.clone()
|
||||||
.ok_or_else(|| anyhow!("missing name"))?;
|
.ok_or_else(|| anyhow!("missing name"))?;
|
||||||
|
|
||||||
let data = NotificationData::FRReceived {
|
let mut data = HashMap::new();
|
||||||
id: alert.from_user.id,
|
data.insert(
|
||||||
username: name,
|
"type".to_string(),
|
||||||
};
|
Value::String("push.fr.receive".to_string()),
|
||||||
|
);
|
||||||
|
data.insert("id".to_string(), Value::String(alert.from_user.id));
|
||||||
|
data.insert("username".to_string(), Value::String(name));
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
data: Some(data.into_payload()),
|
data: Some(data),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -213,29 +121,30 @@ impl FcmOutboundConsumer {
|
|||||||
.clone()
|
.clone()
|
||||||
.ok_or_else(|| anyhow!("missing name"))?;
|
.ok_or_else(|| anyhow!("missing name"))?;
|
||||||
|
|
||||||
let data = NotificationData::FRAccepted {
|
let mut data: HashMap<String, Value> = HashMap::new();
|
||||||
id: alert.accepted_user.id,
|
data.insert(
|
||||||
username: name,
|
"type".to_string(),
|
||||||
};
|
Value::String("push.fr.accept".to_string()),
|
||||||
|
);
|
||||||
|
data.insert("id".to_string(), Value::String(alert.accepted_user.id));
|
||||||
|
data.insert("username".to_string(), Value::String(name));
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
data: Some(data.into_payload()),
|
data: Some(data),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
resp = self.client.send(&msg).await;
|
resp = self.client.send(&msg).await;
|
||||||
}
|
}
|
||||||
PayloadKind::Generic(alert) => {
|
PayloadKind::Generic(alert) => {
|
||||||
let data = NotificationData::Generic {
|
|
||||||
title: alert.title,
|
|
||||||
body: alert.body,
|
|
||||||
image: alert.icon,
|
|
||||||
};
|
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
data: Some(data.into_payload()),
|
notification: Some(Notification {
|
||||||
|
title: Some(alert.title),
|
||||||
|
body: Some(alert.body),
|
||||||
|
image: alert.icon,
|
||||||
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -243,16 +152,19 @@ impl FcmOutboundConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PayloadKind::MessageNotification(alert) => {
|
PayloadKind::MessageNotification(alert) => {
|
||||||
let data = NotificationData::Message {
|
let title = self.format_title(&alert);
|
||||||
title: self.format_title(&alert),
|
|
||||||
body: alert.body,
|
|
||||||
image: alert.icon,
|
|
||||||
tag: alert.tag,
|
|
||||||
};
|
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
data: Some(data.into_payload()),
|
notification: Some(Notification {
|
||||||
|
title: Some(title),
|
||||||
|
body: Some(alert.body),
|
||||||
|
image: Some(alert.icon),
|
||||||
|
}),
|
||||||
|
android: Some(AndroidConfig {
|
||||||
|
collapse_key: Some(alert.tag),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -260,17 +172,30 @@ impl FcmOutboundConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PayloadKind::DmCallStartEnd(alert) => {
|
PayloadKind::DmCallStartEnd(alert) => {
|
||||||
let data = NotificationData::DmCallStartEnd {
|
let mut data: HashMap<String, Value> = HashMap::new();
|
||||||
initiator_id: alert.initiator_id,
|
data.insert(
|
||||||
channel_id: alert.channel_id,
|
"initiator_id".to_string(),
|
||||||
started_at: alert.started_at.unwrap_or_else(|| "".to_string()),
|
Value::String(alert.initiator_id),
|
||||||
ended: alert.ended,
|
);
|
||||||
duration: config().await.api.livekit.call_ring_duration,
|
data.insert("channel_id".to_string(), Value::String(alert.channel_id));
|
||||||
};
|
data.insert(
|
||||||
|
"started_at".to_string(),
|
||||||
|
Value::String(alert.started_at.unwrap_or_else(|| "".to_string())),
|
||||||
|
);
|
||||||
|
data.insert("ended".to_string(), Value::Bool(alert.ended));
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
data: Some(data.into_payload()),
|
notification: None,
|
||||||
|
data: Some(data),
|
||||||
|
android: Some(AndroidConfig {
|
||||||
|
priority: Some(AndroidMessagePriority::High),
|
||||||
|
ttl: Some(format!(
|
||||||
|
"{}s",
|
||||||
|
config().await.api.livekit.call_ring_duration
|
||||||
|
)),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use revolt_config::{config, Settings};
|
|||||||
use tokio::sync::Notify;
|
use tokio::sync::Notify;
|
||||||
|
|
||||||
mod consumers;
|
mod consumers;
|
||||||
mod utils;
|
|
||||||
use consumers::{
|
use consumers::{
|
||||||
inbound::{
|
inbound::{
|
||||||
ack::AckConsumer, dm_call::DmCallConsumer, fr_accepted::FRAcceptedConsumer,
|
ack::AckConsumer, dm_call::DmCallConsumer, fr_accepted::FRAcceptedConsumer,
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
mod renderer;
|
|
||||||
pub use renderer::render_notification_content;
|
|
||||||
@@ -1,272 +0,0 @@
|
|||||||
use redis_kiss::{get_connection as _get_conn, AsyncCommands, Conn};
|
|
||||||
use regex::Regex;
|
|
||||||
use revolt_config::config;
|
|
||||||
use revolt_database::{Channel, Database};
|
|
||||||
use revolt_models::v0::PushNotification;
|
|
||||||
use revolt_parser::parse_message;
|
|
||||||
use revolt_result::{create_error, Result, ToRevoltError};
|
|
||||||
use std::{
|
|
||||||
borrow::Cow,
|
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
};
|
|
||||||
use tokio::join;
|
|
||||||
|
|
||||||
async fn get_connection() -> Result<Conn> {
|
|
||||||
_get_conn().await.map_err(|_| create_error!(InternalError))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn render_notification_content(
|
|
||||||
notification: &PushNotification,
|
|
||||||
db: &Database,
|
|
||||||
) -> Result<String> {
|
|
||||||
let parsed = parse_message(¬ification.body);
|
|
||||||
|
|
||||||
let user_mentions: HashMap<String, String>;
|
|
||||||
let channel_mentions: HashMap<String, String>;
|
|
||||||
let emojis: HashMap<String, String>;
|
|
||||||
let roles: HashMap<String, String>;
|
|
||||||
|
|
||||||
let server_id: Option<String> = get_channel_server_id(notification.channel.id(), db)
|
|
||||||
.await
|
|
||||||
.map(Some)
|
|
||||||
.or(Ok(None))?;
|
|
||||||
|
|
||||||
if server_id.is_some() {
|
|
||||||
(user_mentions, channel_mentions, emojis, roles) = join!(
|
|
||||||
get_items(
|
|
||||||
parsed.user_mentions,
|
|
||||||
server_id.as_deref(),
|
|
||||||
db,
|
|
||||||
get_user_display_name,
|
|
||||||
"Unknown User".to_string()
|
|
||||||
),
|
|
||||||
get_items(
|
|
||||||
parsed.channel_mentions,
|
|
||||||
server_id.as_deref(),
|
|
||||||
db,
|
|
||||||
get_channel_name,
|
|
||||||
"Unknown Channel".to_string()
|
|
||||||
),
|
|
||||||
get_items(
|
|
||||||
parsed.emojis,
|
|
||||||
server_id.as_deref(),
|
|
||||||
db,
|
|
||||||
get_emoji_name,
|
|
||||||
"Unknown Emoji".to_string()
|
|
||||||
),
|
|
||||||
get_items(
|
|
||||||
parsed.role_mentions,
|
|
||||||
server_id.as_deref(),
|
|
||||||
db,
|
|
||||||
get_role_name,
|
|
||||||
"Unknown Role".to_string()
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
roles = HashMap::default();
|
|
||||||
|
|
||||||
(user_mentions, channel_mentions, emojis) = join!(
|
|
||||||
get_items(
|
|
||||||
parsed.user_mentions,
|
|
||||||
server_id.as_deref(),
|
|
||||||
db,
|
|
||||||
get_user_display_name,
|
|
||||||
"Unknown User".to_string()
|
|
||||||
),
|
|
||||||
get_items(
|
|
||||||
parsed.channel_mentions,
|
|
||||||
server_id.as_deref(),
|
|
||||||
db,
|
|
||||||
get_channel_name,
|
|
||||||
"Unknown Channel".to_string()
|
|
||||||
),
|
|
||||||
get_items(
|
|
||||||
parsed.emojis,
|
|
||||||
server_id.as_deref(),
|
|
||||||
db,
|
|
||||||
get_emoji_name,
|
|
||||||
"Unknown Emoji".to_string()
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut body = Cow::Borrowed(notification.body.as_str());
|
|
||||||
|
|
||||||
for (uid, name) in user_mentions {
|
|
||||||
replace_all_in_place(
|
|
||||||
Regex::new(format!("<@{uid}>").as_str()).unwrap(),
|
|
||||||
&mut body,
|
|
||||||
format!("@{name}").as_str(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uid, name) in channel_mentions {
|
|
||||||
replace_all_in_place(
|
|
||||||
Regex::new(format!("<#{uid}>").as_str()).unwrap(),
|
|
||||||
&mut body,
|
|
||||||
format!("#{name}").as_str(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uid, name) in roles {
|
|
||||||
replace_all_in_place(
|
|
||||||
Regex::new(format!("<%{uid}>").as_str()).unwrap(),
|
|
||||||
&mut body,
|
|
||||||
format!("%{name}").as_str(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uid, name) in emojis {
|
|
||||||
replace_all_in_place(
|
|
||||||
Regex::new(format!(":{uid}:").as_str()).unwrap(),
|
|
||||||
&mut body,
|
|
||||||
format!(":{name}:").as_str(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(body.to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_items<F>(
|
|
||||||
items: HashSet<String>,
|
|
||||||
server_id: Option<&str>,
|
|
||||||
db: &Database,
|
|
||||||
getter: F,
|
|
||||||
invalid_string: String,
|
|
||||||
) -> HashMap<String, String>
|
|
||||||
where
|
|
||||||
F: AsyncFn(&str, Option<&str>, &Database) -> Result<String>,
|
|
||||||
{
|
|
||||||
let mut resp = HashMap::default();
|
|
||||||
|
|
||||||
for obj_id in items {
|
|
||||||
resp.insert(
|
|
||||||
obj_id.clone(),
|
|
||||||
getter(&obj_id, server_id, db)
|
|
||||||
.await
|
|
||||||
.unwrap_or(invalid_string.clone()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
resp
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
|
|
||||||
async fn get_user_display_name(id: &str, server: Option<&str>, db: &Database) -> Result<String> {
|
|
||||||
let config = config().await;
|
|
||||||
|
|
||||||
let mut conn = get_connection().await?;
|
|
||||||
let key = format!("pushd-user-cache:{}:{id}", server.unwrap_or("GLOBAL"));
|
|
||||||
|
|
||||||
if let Ok(name) = conn.get(key.clone()).await {
|
|
||||||
return Ok(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(server) = server {
|
|
||||||
let member = db.fetch_member(server, id).await?;
|
|
||||||
if let Some(nickname) = member.nickname {
|
|
||||||
conn.set_ex::<_, _, ()>(key, nickname.clone(), config.pushd.render_cache_time)
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
return Ok(nickname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let user = db.fetch_user(id).await?;
|
|
||||||
let name = user.display_name.unwrap_or(user.username);
|
|
||||||
|
|
||||||
conn.set_ex::<_, _, ()>(key, name.clone(), config.pushd.render_cache_time)
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
|
|
||||||
Ok(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_channel_name(id: &str, _server: Option<&str>, db: &Database) -> Result<String> {
|
|
||||||
let config = config().await;
|
|
||||||
|
|
||||||
let mut conn = get_connection().await?;
|
|
||||||
let key = format!("pushd-channel-cache:{id}");
|
|
||||||
|
|
||||||
if let Ok(name) = conn.get(key.clone()).await {
|
|
||||||
return Ok(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
let channel = db.fetch_channel(id).await?;
|
|
||||||
let name = match channel {
|
|
||||||
Channel::DirectMessage { .. } => "DM Channel".to_string(),
|
|
||||||
Channel::Group { name, .. } | Channel::TextChannel { name, .. } => name,
|
|
||||||
Channel::SavedMessages { .. } => "Err".to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
conn.set_ex::<_, _, ()>(key, name.clone(), config.pushd.render_cache_time)
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
|
|
||||||
Ok(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_role_name(id: &str, server: Option<&str>, db: &Database) -> Result<String> {
|
|
||||||
let server = server.unwrap(); // Must be passed, but the interface must stay the same as the other getters
|
|
||||||
let config: revolt_config::Settings = config().await;
|
|
||||||
|
|
||||||
let mut conn = get_connection().await?;
|
|
||||||
let key = format!("pushd-role-cache:{server}:{id}");
|
|
||||||
|
|
||||||
if let Ok(name) = conn.get(key.clone()).await {
|
|
||||||
return Ok(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
let server = db.fetch_server(server).await?;
|
|
||||||
let name = server
|
|
||||||
.roles
|
|
||||||
.get(id)
|
|
||||||
.ok_or_else(|| create_error!(NotFound))?
|
|
||||||
.name
|
|
||||||
.clone();
|
|
||||||
|
|
||||||
conn.set_ex::<_, _, ()>(key, name.clone(), config.pushd.render_cache_time)
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
|
|
||||||
Ok(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_emoji_name(id: &str, _server: Option<&str>, db: &Database) -> Result<String> {
|
|
||||||
let config: revolt_config::Settings = config().await;
|
|
||||||
|
|
||||||
let mut conn = get_connection().await?;
|
|
||||||
let key = format!("pushd-emoji-cache:{id}");
|
|
||||||
|
|
||||||
if let Ok(name) = conn.get(key.clone()).await {
|
|
||||||
return Ok(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
let emoji = db.fetch_emoji(id).await?;
|
|
||||||
let name = emoji.name;
|
|
||||||
|
|
||||||
conn.set_ex::<_, _, ()>(key, name.clone(), config.pushd.render_cache_time)
|
|
||||||
.await
|
|
||||||
.to_internal_error()?;
|
|
||||||
|
|
||||||
Ok(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// utility
|
|
||||||
|
|
||||||
async fn get_channel_server_id(channel_id: &str, db: &Database) -> Result<String> {
|
|
||||||
match db.fetch_channel(channel_id).await? {
|
|
||||||
Channel::DirectMessage { .. } | Channel::Group { .. } | Channel::SavedMessages { .. } => {
|
|
||||||
Err(create_error!(NotFound))
|
|
||||||
}
|
|
||||||
Channel::TextChannel { server, .. } => Ok(server),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn replace_all_in_place<R: regex::Replacer>(regex: Regex, s: &mut Cow<'_, str>, replacer: R) {
|
|
||||||
let new = regex.replace_all(s, replacer);
|
|
||||||
if let Cow::Owned(o) = new {
|
|
||||||
*s = Cow::Owned(o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loaded 100 of 153 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user