Compare commits
103
Commits
20240929-3
...
20250509-3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70d6a5ac08 | ||
|
|
7f85ad5e7b | ||
|
|
c785ae615d | ||
|
|
9c8a362e9f | ||
|
|
e708c612cf | ||
|
|
f75d635c81 | ||
|
|
29b6ac3acf | ||
|
|
a1b0e4767a | ||
|
|
f4281c7050 | ||
|
|
d2e83c94f3 | ||
|
|
2540860129 | ||
|
|
93a5de769d | ||
|
|
717d5e9a88 | ||
|
|
18f06467bb | ||
|
|
8d88ea9963 | ||
|
|
e3e1cab02e | ||
|
|
00bd56b687 | ||
|
|
a7727bba5c | ||
|
|
6b8005f530 | ||
|
|
714fba7ea6 | ||
|
|
ac05fb385c | ||
|
|
537c147c4b | ||
|
|
7bee609b84 | ||
|
|
859c0214ec | ||
|
|
5eea0bbc9a | ||
|
|
15dec656a8 | ||
|
|
bcf6561c0c | ||
|
|
b177a3e201 | ||
|
|
d1236bf8f2 | ||
|
|
01490f5723 | ||
|
|
3ceefb840b | ||
|
|
eb5f5f91cd | ||
|
|
52e1f0ddde | ||
|
|
defc9ec79b | ||
|
|
7026961df4 | ||
|
|
078380d305 | ||
|
|
add3f40b23 | ||
|
|
7216e9909b | ||
|
|
a1e6a19210 | ||
|
|
5f39403ce7 | ||
|
|
e525ffe5e4 | ||
|
|
e3723d647e | ||
|
|
5f84daa9db | ||
|
|
e957af4ca3 | ||
|
|
439bacf067 | ||
|
|
fa55e88dd9 | ||
|
|
71e7fe3086 | ||
|
|
03f2e3b1bf | ||
|
|
8bbb579d23 | ||
|
|
6448af071b | ||
|
|
c2a0ab71df | ||
|
|
7a17165c24 | ||
|
|
d7213fa409 | ||
|
|
479f0402ca | ||
|
|
b62eeef80c | ||
|
|
7b15006a50 | ||
|
|
ac731e547d | ||
|
|
443f374f23 | ||
|
|
42367f477c | ||
|
|
3cb91151ca | ||
|
|
4c46054bff | ||
|
|
f01794af93 | ||
|
|
49f7f9549c | ||
|
|
72e3129557 | ||
|
|
75a07a84c0 | ||
|
|
b55765d7c7 | ||
|
|
ed5ded5e45 | ||
|
|
249749e14d | ||
|
|
4c00a7dfb7 | ||
|
|
acc4317246 | ||
|
|
b9ae333b02 | ||
|
|
bf0fc504a9 | ||
|
|
705e517871 | ||
|
|
6f99ac2160 | ||
|
|
2fcc714546 | ||
|
|
1e72f7bc77 | ||
|
|
af0d24c7c6 | ||
|
|
ab58177dfa | ||
|
|
df07426019 | ||
|
|
c30d9a2620 | ||
|
|
7b44317705 | ||
|
|
876068a37e | ||
|
|
397b9878e1 | ||
|
|
d9deadc65a | ||
|
|
58d3c5cc2e | ||
|
|
520fb02fb6 | ||
|
|
2cb12a3d59 | ||
|
|
18888eae5f | ||
|
|
f31020fb6e | ||
|
|
bb202079e0 | ||
|
|
bb6bcda8bd | ||
|
|
68099bd2b7 | ||
|
|
a8db1cb40d | ||
|
|
efa7ba78ed | ||
|
|
25fc692dc1 | ||
|
|
530d68fe89 | ||
|
|
afd8c906ba | ||
|
|
c596dd5458 | ||
|
|
ed78b253ff | ||
|
|
66c84e0ad9 | ||
|
|
21335b3297 | ||
|
|
8fc791f81a | ||
|
|
1689ee5ddc |
@@ -1,2 +1,2 @@
|
|||||||
[profile.default]
|
[profile.default]
|
||||||
slow-timeout = { period = "3s", terminate-after = 2 }
|
slow-timeout = { period = "5s", terminate-after = 10 }
|
||||||
|
|||||||
+123
-63
@@ -2,24 +2,13 @@ name: Docker Test & Publish
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# branches:
|
|
||||||
# - "main"
|
|
||||||
tags:
|
tags:
|
||||||
- "*"
|
- "*"
|
||||||
paths-ignore:
|
|
||||||
- ".github/**"
|
|
||||||
- "!.github/workflows/docker.yml"
|
|
||||||
- ".vscode/**"
|
|
||||||
- "doc/**"
|
|
||||||
- ".gitignore"
|
|
||||||
- "LICENSE"
|
|
||||||
- "README"
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
paths:
|
paths:
|
||||||
- "Dockerfile"
|
- "Dockerfile"
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -27,8 +16,9 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
base:
|
base:
|
||||||
|
name: Test base image build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Build base image
|
if: github.event_name == 'pull_request'
|
||||||
steps:
|
steps:
|
||||||
# Configure build environment
|
# Configure build environment
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -36,33 +26,21 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
# Authenticate with GHCR
|
# Build the image
|
||||||
- name: Login to Github Container Registry
|
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build base image
|
- name: Build base image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: false
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: ghcr.io/${{ github.repository_owner }}/base:latest
|
tags: ghcr.io/${{ github.repository_owner }}/base:latest
|
||||||
cache-from: type=gha,scope=buildx-base-multi-arch
|
cache-from: type=gha,scope=buildx-base-multi-arch
|
||||||
cache-to: type=gha,scope=buildx-base-multi-arch,mode=max
|
cache-to: type=gha,scope=buildx-base-multi-arch,mode=max
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
needs: [base]
|
runs-on: self-hosted
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
strategy:
|
name: Publish Docker images
|
||||||
matrix:
|
|
||||||
project: [delta, bonfire, autumn, january]
|
|
||||||
name: Build ${{ matrix.project }} image
|
|
||||||
steps:
|
steps:
|
||||||
# Configure build environment
|
# Configure build environment
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -70,6 +48,15 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
# Build the image
|
||||||
|
- name: Build base image
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
tags: ghcr.io/${{ github.repository_owner }}/base:latest
|
||||||
|
|
||||||
# Authenticate with Docker Hub and GHCR
|
# Authenticate with Docker Hub and GHCR
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
@@ -77,6 +64,7 @@ jobs:
|
|||||||
registry: docker.io
|
registry: docker.io
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Login to Github Container Registry
|
- name: Login to Github Container Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@@ -84,50 +72,122 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# Resolve the correct project
|
# revoltchat/server
|
||||||
- uses: kanga333/variable-mapper@master
|
|
||||||
id: export
|
|
||||||
with:
|
|
||||||
key: "${{ matrix.project }}"
|
|
||||||
map: |
|
|
||||||
{
|
|
||||||
"delta": {
|
|
||||||
"path": "crates/delta",
|
|
||||||
"tag": "${{ github.repository_owner }}/server"
|
|
||||||
},
|
|
||||||
"bonfire": {
|
|
||||||
"path": "crates/bonfire",
|
|
||||||
"tag": "${{ github.repository_owner }}/bonfire"
|
|
||||||
},
|
|
||||||
"autumn": {
|
|
||||||
"path": "crates/services/autumn",
|
|
||||||
"tag": "${{ github.repository_owner }}/autumn"
|
|
||||||
},
|
|
||||||
"january": {
|
|
||||||
"path": "crates/services/january",
|
|
||||||
"tag": "${{ github.repository_owner }}/january"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export_to: output
|
|
||||||
|
|
||||||
# Configure metadata
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta-delta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
docker.io/${{ steps.export.outputs.tag }}
|
docker.io/revoltchat/server
|
||||||
ghcr.io/${{ steps.export.outputs.tag }}
|
ghcr.io/revoltchat/server
|
||||||
|
|
||||||
# Build crate image
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
file: ${{ steps.export.outputs.path }}/Dockerfile
|
file: crates/delta/Dockerfile
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta-delta.outputs.tags }}
|
||||||
build-args: |
|
build-args: |
|
||||||
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/base:latest
|
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/base:latest
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta-delta.outputs.labels }}
|
||||||
|
|
||||||
|
# revoltchat/bonfire
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta-bonfire
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
docker.io/revoltchat/bonfire
|
||||||
|
ghcr.io/revoltchat/bonfire
|
||||||
|
- name: Publish
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
file: crates/bonfire/Dockerfile
|
||||||
|
tags: ${{ steps.meta-bonfire.outputs.tags }}
|
||||||
|
build-args: |
|
||||||
|
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/base:latest
|
||||||
|
labels: ${{ steps.meta-bonfire.outputs.labels }}
|
||||||
|
|
||||||
|
# revoltchat/autumn
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta-autumn
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
docker.io/revoltchat/autumn
|
||||||
|
ghcr.io/revoltchat/autumn
|
||||||
|
- name: Publish
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
file: crates/services/autumn/Dockerfile
|
||||||
|
tags: ${{ steps.meta-autumn.outputs.tags }}
|
||||||
|
build-args: |
|
||||||
|
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/base:latest
|
||||||
|
labels: ${{ steps.meta-autumn.outputs.labels }}
|
||||||
|
|
||||||
|
# revoltchat/january
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta-january
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
docker.io/revoltchat/january
|
||||||
|
ghcr.io/revoltchat/january
|
||||||
|
- name: Publish
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
file: crates/services/january/Dockerfile
|
||||||
|
tags: ${{ steps.meta-january.outputs.tags }}
|
||||||
|
build-args: |
|
||||||
|
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/base:latest
|
||||||
|
labels: ${{ steps.meta-january.outputs.labels }}
|
||||||
|
|
||||||
|
# revoltchat/crond
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta-crond
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
docker.io/revoltchat/crond
|
||||||
|
ghcr.io/revoltchat/crond
|
||||||
|
- name: Publish
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
file: crates/daemons/crond/Dockerfile
|
||||||
|
tags: ${{ steps.meta-crond.outputs.tags }}
|
||||||
|
build-args: |
|
||||||
|
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/base:latest
|
||||||
|
labels: ${{ steps.meta-crond.outputs.labels }}
|
||||||
|
|
||||||
|
# revoltchat/pushd
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta-pushd
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
docker.io/revoltchat/pushd
|
||||||
|
ghcr.io/revoltchat/pushd
|
||||||
|
- name: Publish
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
file: crates/daemons/pushd/Dockerfile
|
||||||
|
tags: ${{ steps.meta-pushd.outputs.tags }}
|
||||||
|
build-args: |
|
||||||
|
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/base:latest
|
||||||
|
labels: ${{ steps.meta-pushd.outputs.labels }}
|
||||||
|
|||||||
@@ -41,11 +41,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Run services in background
|
- name: Run services in background
|
||||||
run: |
|
run: |
|
||||||
docker compose -f docker-compose.db.yml up -d
|
docker compose -f compose.yml up -d
|
||||||
|
|
||||||
- name: Copy .env.example
|
|
||||||
run: |
|
|
||||||
cp .env.example .env
|
|
||||||
|
|
||||||
- name: Run cargo test
|
- name: Run cargo test
|
||||||
env:
|
env:
|
||||||
@@ -71,7 +67,7 @@ jobs:
|
|||||||
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
||||||
uses: nev7n/wait_for_response@v1
|
uses: nev7n/wait_for_response@v1
|
||||||
with:
|
with:
|
||||||
url: "http://localhost:8000/"
|
url: "http://localhost:14702/"
|
||||||
|
|
||||||
- name: Checkout API repository
|
- name: Checkout API repository
|
||||||
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
||||||
@@ -83,7 +79,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Download OpenAPI specification
|
- name: Download OpenAPI specification
|
||||||
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
||||||
run: curl http://localhost:8000/openapi.json -o api/OpenAPI.json
|
run: curl http://localhost:14702/openapi.json -o api/OpenAPI.json
|
||||||
|
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
Rocket.toml
|
Rocket.toml
|
||||||
Revolt.*.toml
|
Revolt.*.toml
|
||||||
|
compose.override.yml
|
||||||
|
|
||||||
target
|
target
|
||||||
.data
|
.data
|
||||||
.env
|
.env
|
||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
|
||||||
.vercel
|
.vercel
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
.idea
|
||||||
Vendored
+3
-2
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"rust-analyzer.checkOnSave.command": "clippy",
|
"rust-analyzer.checkOnSave.command": "clippy",
|
||||||
"nixEnvSelector.suggestion": false
|
"nixEnvSelector.suggestion": false,
|
||||||
}
|
"nixEnvSelector.nixFile": "${workspaceFolder}/default.nix"
|
||||||
|
}
|
||||||
Generated
+3035
-1932
File diff suppressed because it is too large
Load Diff
+10
-5
@@ -1,16 +1,21 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
members = [
|
members = [
|
||||||
"crates/delta",
|
"crates/delta",
|
||||||
"crates/bonfire",
|
"crates/bonfire",
|
||||||
"crates/core/*",
|
"crates/core/*",
|
||||||
"crates/services/*",
|
"crates/services/*",
|
||||||
"crates/bindings/*",
|
"crates/bindings/*",
|
||||||
|
"crates/daemons/*",
|
||||||
]
|
]
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
# mobc-redis = { git = "https://github.com/insertish/mobc", rev = "8b880bb59f2ba80b4c7bc40c649c113d8857a186" }
|
redis23 = { package = "redis", version = "0.23.3", git = "https://github.com/revoltchat/redis-rs", rev = "523b2937367e17bd0073722bf6e23d06042cb4e4" }
|
||||||
redis22 = { package = "redis", version = "0.22.3", git = "https://github.com/revoltchat/redis-rs", rev = "1a41faf356fd21aebba71cea7eb7eb2653e5f0ef" }
|
|
||||||
redis23 = { package = "redis", version = "0.23.1", git = "https://github.com/revoltchat/redis-rs", rev = "f8ca28ab85da59d2ccde526b4d2fb390eff5a5f9" }
|
# I'm 99% sure this is overloading the GitHub worker
|
||||||
# authifier = { package = "authifier", version = "1.0.8", path = "../authifier/crates/authifier" }
|
# hence builds have been failing since, let's just
|
||||||
# rocket_authifier = { package = "rocket_authifier", version = "1.0.8", path = "../authifier/crates/rocket_authifier" }
|
# disable it for now. In the future, we could use this
|
||||||
|
# if we were rolling our own CI.
|
||||||
|
# [profile.release]
|
||||||
|
# lto = true
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ COPY crates/core/presence/Cargo.toml ./crates/core/presence/
|
|||||||
COPY crates/core/result/Cargo.toml ./crates/core/result/
|
COPY crates/core/result/Cargo.toml ./crates/core/result/
|
||||||
COPY crates/services/autumn/Cargo.toml ./crates/services/autumn/
|
COPY crates/services/autumn/Cargo.toml ./crates/services/autumn/
|
||||||
COPY crates/services/january/Cargo.toml ./crates/services/january/
|
COPY crates/services/january/Cargo.toml ./crates/services/january/
|
||||||
|
COPY crates/daemons/crond/Cargo.toml ./crates/daemons/crond/
|
||||||
|
COPY crates/daemons/pushd/Cargo.toml ./crates/daemons/pushd/
|
||||||
RUN sh /tmp/build-image-layer.sh deps
|
RUN sh /tmp/build-image-layer.sh deps
|
||||||
|
|
||||||
# Build all apps
|
# Build all apps
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ COPY crates/core/presence/Cargo.toml ./crates/core/presence/
|
|||||||
COPY crates/core/result/Cargo.toml ./crates/core/result/
|
COPY crates/core/result/Cargo.toml ./crates/core/result/
|
||||||
COPY crates/services/autumn/Cargo.toml ./crates/services/autumn/
|
COPY crates/services/autumn/Cargo.toml ./crates/services/autumn/
|
||||||
COPY crates/services/january/Cargo.toml ./crates/services/january/
|
COPY crates/services/january/Cargo.toml ./crates/services/january/
|
||||||
|
COPY crates/daemons/crond/Cargo.toml ./crates/daemons/crond/
|
||||||
|
COPY crates/daemons/pushd/Cargo.toml ./crates/daemons/pushd/
|
||||||
RUN sh /tmp/build-image-layer.sh deps
|
RUN sh /tmp/build-image-layer.sh deps
|
||||||
|
|
||||||
# Build all apps
|
# Build all apps
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ The services and libraries that power the Revolt service.<br/>
|
|||||||
| `services/january` | [crates/services/january](crates/services/january) | Proxy server |  |
|
| `services/january` | [crates/services/january](crates/services/january) | Proxy server |  |
|
||||||
| `services/autumn` | [crates/services/autumn](crates/services/autumn) | File server |  |
|
| `services/autumn` | [crates/services/autumn](crates/services/autumn) | File server |  |
|
||||||
| `bindings/node` | [crates/bindings/node](crates/bindings/node) | Node.js bindings for the Revolt software |  |
|
| `bindings/node` | [crates/bindings/node](crates/bindings/node) | Node.js bindings for the Revolt software |  |
|
||||||
|
| `daemons/crond` | [crates/daemons/crond](crates/daemons/crond) | Timed data clean up daemon server |  |
|
||||||
|
| `daemons/pushd` | [crates/daemons/pushd](crates/daemons/pushd) | Push notification daemon server |  |
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
@@ -55,11 +57,12 @@ As a heads-up, the development environment uses the following ports:
|
|||||||
|
|
||||||
| Service | Port |
|
| Service | Port |
|
||||||
| ------------------------- | :------------: |
|
| ------------------------- | :------------: |
|
||||||
| MongoDB | 14017 |
|
| MongoDB | 27017 |
|
||||||
| Redis | 14079 |
|
| Redis | 6379 |
|
||||||
| MinIO | 14009 |
|
| MinIO | 14009 |
|
||||||
| Maildev | 14025<br>14080 |
|
| Maildev | 14025<br>14080 |
|
||||||
| Revolt Web App | 14701 |
|
| Revolt Web App | 14701 |
|
||||||
|
| RabbitMQ | 5672<br>15672 |
|
||||||
| `crates/delta` | 14702 |
|
| `crates/delta` | 14702 |
|
||||||
| `crates/bonfire` | 14703 |
|
| `crates/bonfire` | 14703 |
|
||||||
| `crates/services/autumn` | 14704 |
|
| `crates/services/autumn` | 14704 |
|
||||||
@@ -89,23 +92,61 @@ If you'd like to change anything, create a `Revolt.overrides.toml` file and spec
|
|||||||
> proxy = "https://abc@your.sentry/1"
|
> proxy = "https://abc@your.sentry/1"
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> If you have port conflicts on common services, you can try the following:
|
||||||
|
>
|
||||||
|
> ```yaml
|
||||||
|
> # compose.override.yml
|
||||||
|
> services:
|
||||||
|
> redis:
|
||||||
|
> ports: !override
|
||||||
|
> - "14079:6379"
|
||||||
|
>
|
||||||
|
> database:
|
||||||
|
> ports: !override
|
||||||
|
> - "14017:27017"
|
||||||
|
>
|
||||||
|
> rabbit:
|
||||||
|
> ports: !override
|
||||||
|
> - "14072:5672"
|
||||||
|
> - "14672:15672"
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> And corresponding Revolt configuration:
|
||||||
|
>
|
||||||
|
> ```toml
|
||||||
|
> # Revolt.overrides.toml
|
||||||
|
> [database]
|
||||||
|
> mongodb = "mongodb://127.0.0.1:14017"
|
||||||
|
> redis = "redis://127.0.0.1:14079/"
|
||||||
|
>
|
||||||
|
> [rabbit]
|
||||||
|
> port = 14072
|
||||||
|
> ```
|
||||||
|
|
||||||
Then continue:
|
Then continue:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# start other necessary services
|
# start other necessary services
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
|
# run everything together
|
||||||
|
./scripts/start.sh
|
||||||
|
# .. or individually
|
||||||
# run the API server
|
# run the API server
|
||||||
cargo run --bin revolt-delta
|
cargo run --bin revolt-delta
|
||||||
# run the events server
|
# run the events server
|
||||||
cargo run --bin revolt-bonfire
|
cargo run --bin revolt-bonfire
|
||||||
# run the file server
|
# run the file server
|
||||||
cargo run --bin revolt-autumn
|
cargo run --bin revolt-autumn
|
||||||
# run th proxy server
|
# run the proxy server
|
||||||
cargo run --bin revolt-january
|
cargo run --bin revolt-january
|
||||||
|
# run the push daemon (not usually needed in regular development)
|
||||||
|
cargo run --bin revolt-pushd
|
||||||
|
|
||||||
# hint:
|
# hint:
|
||||||
# mold -run <cargo build, cargo run, etc...>
|
# mold -run <cargo build, cargo run, etc...>
|
||||||
|
# mold -run ./scripts/start.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
You can start a web client by doing the following:
|
You can start a web client by doing the following:
|
||||||
|
|||||||
+6
-3
@@ -1,13 +1,16 @@
|
|||||||
# ⚠️ This configuration is intended for development environment.
|
# ⚠️ This configuration is intended for development environment.
|
||||||
# If you'd like to override anything, create a Revolt.override.toml
|
# If you'd like to override anything, create a Revolt.overrides.toml
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
# MongoDB connection URL
|
# MongoDB connection URL
|
||||||
# Defaults to the container name specified in self-hosted
|
# Defaults to the container name specified in self-hosted
|
||||||
mongodb = "mongodb://127.0.0.1:14017"
|
mongodb = "mongodb://127.0.0.1:27017"
|
||||||
# Redis connection URL
|
# Redis connection URL
|
||||||
# Defaults to the container name specified in self-hosted
|
# Defaults to the container name specified in self-hosted
|
||||||
redis = "redis://127.0.0.1:14079/"
|
redis = "redis://127.0.0.1:6379/"
|
||||||
|
|
||||||
|
[rabbit]
|
||||||
|
host = "127.0.0.1"
|
||||||
|
|
||||||
[hosts]
|
[hosts]
|
||||||
# Web locations of various services
|
# Web locations of various services
|
||||||
|
|||||||
+21
-11
@@ -3,13 +3,13 @@ services:
|
|||||||
redis:
|
redis:
|
||||||
image: eqalpha/keydb
|
image: eqalpha/keydb
|
||||||
ports:
|
ports:
|
||||||
- "14079:6379"
|
- "6379:6379"
|
||||||
|
|
||||||
# MongoDB
|
# MongoDB
|
||||||
database:
|
database:
|
||||||
image: mongo
|
image: mongo
|
||||||
ports:
|
ports:
|
||||||
- "14017:27017"
|
- "27017:27017"
|
||||||
volumes:
|
volumes:
|
||||||
- ./.data/db:/data/db
|
- ./.data/db:/data/db
|
||||||
|
|
||||||
@@ -32,16 +32,26 @@ services:
|
|||||||
image: minio/mc
|
image: minio/mc
|
||||||
depends_on:
|
depends_on:
|
||||||
- minio
|
- minio
|
||||||
environment:
|
|
||||||
MINIO_ROOT_USER: minioautumn
|
|
||||||
MINIO_ROOT_PASSWORD: minioautumn
|
|
||||||
entrypoint: >
|
entrypoint: >
|
||||||
/bin/sh -c "
|
/bin/sh -c "while ! /usr/bin/mc ready minio; do
|
||||||
/usr/bin/mc config host add minio http://minio:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD;
|
/usr/bin/mc config host add minio http://minio:9000 minioautumn minioautumn;
|
||||||
while ! /usr/bin/mc ready minio; do echo 'Waiting minio...' && sleep 1; done;
|
echo 'Waiting minio...' && sleep 1;
|
||||||
/usr/bin/mc mb minio/revolt-uploads;
|
done; /usr/bin/mc mb minio/revolt-uploads; exit 0;"
|
||||||
exit 0;
|
|
||||||
"
|
# Rabbit
|
||||||
|
rabbit:
|
||||||
|
image: rabbitmq:3-management
|
||||||
|
environment:
|
||||||
|
RABBITMQ_DEFAULT_USER: rabbituser
|
||||||
|
RABBITMQ_DEFAULT_PASS: rabbitpass
|
||||||
|
volumes:
|
||||||
|
- ./.data/rabbit:/var/lib/rabbitmq
|
||||||
|
#- ./rabbit_plugins:/opt/rabbitmq/plugins/
|
||||||
|
#- ./rabbit_enabled_plugins:/etc/rabbitmq/enabled_plugins
|
||||||
|
# uncomment this if you need to enable other plugins
|
||||||
|
ports:
|
||||||
|
- "5672:5672"
|
||||||
|
- "15672:15672" # management UI, for development
|
||||||
|
|
||||||
# Mock SMTP server
|
# Mock SMTP server
|
||||||
maildev:
|
maildev:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-nodejs-bindings"
|
name = "revolt-nodejs-bindings"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
description = "Node.js bindings for the Revolt software"
|
description = "Node.js bindings for the Revolt software"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@@ -20,6 +20,6 @@ serde = { version = "1", features = ["derive"] }
|
|||||||
|
|
||||||
async-std = "1.12.0"
|
async-std = "1.12.0"
|
||||||
|
|
||||||
revolt-config = { version = "0.7.16", path = "../../core/config" }
|
revolt-config = { version = "0.8.4", path = "../../core/config" }
|
||||||
revolt-result = { version = "0.7.16", path = "../../core/result" }
|
revolt-result = { version = "0.8.4", path = "../../core/result" }
|
||||||
revolt-database = { version = "0.7.16", path = "../../core/database" }
|
revolt-database = { version = "0.8.4", path = "../../core/database" }
|
||||||
|
|||||||
@@ -7,25 +7,25 @@ use neon::prelude::*;
|
|||||||
use revolt_database::{Database, DatabaseInfo};
|
use revolt_database::{Database, DatabaseInfo};
|
||||||
|
|
||||||
fn js_init(mut cx: FunctionContext) -> JsResult<JsUndefined> {
|
fn js_init(mut cx: FunctionContext) -> JsResult<JsUndefined> {
|
||||||
static INIT: OnceLock<()> = OnceLock::new();
|
// static INIT: OnceLock<()> = OnceLock::new();
|
||||||
if INIT.get().is_none() {
|
// if INIT.get().is_none() {
|
||||||
INIT.get_or_init(|| {
|
// INIT.get_or_init(|| {
|
||||||
async_std::task::block_on(async {
|
// async_std::task::block_on(async {
|
||||||
revolt_config::configure!(api);
|
// revolt_config::configure!(api);
|
||||||
|
|
||||||
match DatabaseInfo::Auto.connect().await {
|
// match DatabaseInfo::Auto.connect().await {
|
||||||
Ok(db) => {
|
// Ok(db) => {
|
||||||
let authifier_db = db.clone().to_authifier().await.database;
|
// let authifier_db = db.clone().to_authifier().await.database;
|
||||||
revolt_database::tasks::start_workers(db, authifier_db);
|
// revolt_database::tasks::start_workers(db, authifier_db);
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
Err(err) => Err(err),
|
// Err(err) => Err(err),
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
.or_else(|err| cx.throw_error(err))
|
// .or_else(|err| cx.throw_error(err))
|
||||||
.unwrap();
|
// .unwrap();
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
Ok(cx.undefined())
|
Ok(cx.undefined())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -36,12 +36,12 @@ async-std = { version = "1.8.0", features = [
|
|||||||
] }
|
] }
|
||||||
|
|
||||||
# core
|
# core
|
||||||
authifier = { version = "1.0.8" }
|
authifier = { version = "1.0.10" }
|
||||||
revolt-result = { path = "../core/result" }
|
revolt-result = { path = "../core/result" }
|
||||||
revolt-models = { path = "../core/models" }
|
revolt-models = { path = "../core/models" }
|
||||||
revolt-config = { path = "../core/config" }
|
revolt-config = { path = "../core/config" }
|
||||||
revolt-database = { path = "../core/database" }
|
revolt-database = { path = "../core/database" }
|
||||||
revolt-permissions = { version = "0.7.16", path = "../core/permissions" }
|
revolt-permissions = { version = "0.8.4", path = "../core/permissions" }
|
||||||
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
|
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
|
||||||
|
|
||||||
# redis
|
# redis
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
# Build Stage
|
# Build Stage
|
||||||
FROM ghcr.io/revoltchat/base:latest AS builder
|
FROM ghcr.io/revoltchat/base:latest AS builder
|
||||||
|
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-bonfire ./
|
COPY --from=builder /home/rust/src/target/release/revolt-bonfire ./
|
||||||
|
COPY --from=debian /usr/bin/uname /usr/bin/uname
|
||||||
|
|
||||||
EXPOSE 14703
|
EXPOSE 14703
|
||||||
USER nonroot
|
USER nonroot
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
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,
|
||||||
@@ -198,13 +199,12 @@ impl State {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Make all users appear from our perspective.
|
// Make all users appear from our perspective.
|
||||||
let mut users: Vec<v0::User> = users
|
let mut users: Vec<v0::User> = join_all(users
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|other_user| {
|
.map(|other_user| async {
|
||||||
let is_online = online_ids.contains(&other_user.id);
|
let is_online = online_ids.contains(&other_user.id);
|
||||||
other_user.into_known(&user, is_online)
|
other_user.into_known(&user, is_online).await
|
||||||
})
|
})).await;
|
||||||
.collect();
|
|
||||||
|
|
||||||
// Make sure we see our own user correctly.
|
// Make sure we see our own user correctly.
|
||||||
users.push(user.into_self(true).await);
|
users.push(user.into_self(true).await);
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ async fn main() {
|
|||||||
database::connect().await;
|
database::connect().await;
|
||||||
|
|
||||||
// Clean up the current region information.
|
// Clean up the current region information.
|
||||||
clear_region(None).await;
|
let no_clear_region = env::var("NO_CLEAR_PRESENCE").unwrap_or_else(|_| "0".into()) == "1";
|
||||||
|
if !no_clear_region {
|
||||||
|
clear_region(None).await;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup a TCP listener to accept WebSocket connections on.
|
// Setup a TCP listener to accept WebSocket connections on.
|
||||||
// By default, we bind to port 14703 on all interfaces.
|
// By default, we bind to port 14703 on all interfaces.
|
||||||
|
|||||||
@@ -79,7 +79,9 @@ pub async fn client(db: &'static Database, stream: TcpStream, addr: SocketAddr)
|
|||||||
// Try to authenticate the user.
|
// Try to authenticate the user.
|
||||||
let Some(token) = config.get_session_token().as_ref() else {
|
let Some(token) = config.get_session_token().as_ref() else {
|
||||||
write
|
write
|
||||||
.send(config.encode(&create_error!(InvalidSession)))
|
.send(config.encode(&EventV1::Error {
|
||||||
|
data: create_error!(InvalidSession),
|
||||||
|
}))
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
return;
|
return;
|
||||||
@@ -88,7 +90,10 @@ pub async fn client(db: &'static Database, stream: TcpStream, addr: SocketAddr)
|
|||||||
let (user, session_id) = match User::from_token(db, token, UserHint::Any).await {
|
let (user, session_id) = match User::from_token(db, token, UserHint::Any).await {
|
||||||
Ok(user) => user,
|
Ok(user) => user,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
write.send(config.encode(&err)).await.ok();
|
write
|
||||||
|
.send(config.encode(&EventV1::Error { data: err }))
|
||||||
|
.await
|
||||||
|
.ok();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -301,25 +306,23 @@ async fn listener(
|
|||||||
PayloadType::Json => message
|
PayloadType::Json => message
|
||||||
.value
|
.value
|
||||||
.as_str()
|
.as_str()
|
||||||
.and_then(|s| serde_json::from_str::<EventV1>(s.as_ref()).ok()),
|
.and_then(|s| report_internal_error!(serde_json::from_str::<EventV1>(s.as_ref())).ok()),
|
||||||
PayloadType::Msgpack => message
|
PayloadType::Msgpack => message
|
||||||
.value
|
.value
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
.and_then(|b| rmp_serde::from_slice::<EventV1>(b).ok()),
|
.and_then(|b| report_internal_error!(rmp_serde::from_slice::<EventV1>(b)).ok()),
|
||||||
PayloadType::Bincode => message
|
PayloadType::Bincode => message
|
||||||
.value
|
.value
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
.and_then(|b| bincode::deserialize::<EventV1>(b).ok()),
|
.and_then(|b| report_internal_error!(bincode::deserialize::<EventV1>(b)).ok()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(mut event) = event else {
|
let Some(mut event) = event else {
|
||||||
let err = format!(
|
let err = format!(
|
||||||
"Failed to deserialise an event for {}! Introspection: `{:?}`",
|
"Failed to deserialise event for {}: `{:?}`",
|
||||||
message.channel,
|
message.channel,
|
||||||
message
|
message
|
||||||
.value
|
.value
|
||||||
.as_string()
|
|
||||||
.map(|x| x.chars().take(32).collect::<String>())
|
|
||||||
);
|
);
|
||||||
|
|
||||||
error!("{}", err);
|
error!("{}", err);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-config"
|
name = "revolt-config"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -15,7 +15,6 @@ default = ["test"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
dotenv = "0.15.0"
|
|
||||||
config = "0.13.3"
|
config = "0.13.3"
|
||||||
cached = "0.44.0"
|
cached = "0.44.0"
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
@@ -35,4 +34,4 @@ pretty_env_logger = "0.4.0"
|
|||||||
sentry = "0.31.5"
|
sentry = "0.31.5"
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { version = "0.7.16", path = "../result", optional = true }
|
revolt-result = { version = "0.8.4", path = "../result", optional = true }
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
[database]
|
[database]
|
||||||
mongodb = "mongodb://localhost"
|
mongodb = "mongodb://localhost"
|
||||||
redis = "redis://localhost/"
|
redis = "redis://localhost/"
|
||||||
|
|
||||||
|
[rabbit]
|
||||||
|
host = "127.0.0.1"
|
||||||
|
port = 5672
|
||||||
|
username = "rabbituser"
|
||||||
|
password = "rabbitpass"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
webhooks_enabled = true
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
production = false
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
# MongoDB connection URL
|
# MongoDB connection URL
|
||||||
# Defaults to the container name specified in self-hosted
|
# Defaults to the container name specified in self-hosted
|
||||||
@@ -20,6 +22,12 @@ january = "http://local.revolt.chat/january"
|
|||||||
voso_legacy = ""
|
voso_legacy = ""
|
||||||
voso_legacy_ws = ""
|
voso_legacy_ws = ""
|
||||||
|
|
||||||
|
[rabbit]
|
||||||
|
host = "rabbit"
|
||||||
|
port = 5672
|
||||||
|
username = "rabbituser"
|
||||||
|
password = "rabbitpass"
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[api.registration]
|
[api.registration]
|
||||||
@@ -38,34 +46,6 @@ from_address = "noreply@example.com"
|
|||||||
# port = 587
|
# port = 587
|
||||||
# use_tls = true
|
# use_tls = true
|
||||||
|
|
||||||
[api.vapid]
|
|
||||||
# Generate your own keys:
|
|
||||||
# 1. Run `openssl ecparam -name prime256v1 -genkey -noout -out vapid_private.pem`
|
|
||||||
# 2. Find `private_key` using `base64 vapid_private.pem`
|
|
||||||
# 3. Find `public_key` using `openssl ec -in vapid_private.pem -outform DER|tail -c 65|base64|tr '/+' '_-'|tr -d '\n'`
|
|
||||||
private_key = "LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUJSUWpyTWxLRnBiVWhsUHpUbERvcEliYk1yeVNrNXpKYzVYVzIxSjJDS3hvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFWnkrQkg2TGJQZ2hEa3pEempXOG0rUXVPM3pCajRXT1phdkR6ZU00c0pqbmFwd1psTFE0WAp1ZDh2TzVodU94QWhMQlU3WWRldVovWHlBdFpWZmNyQi9BPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo"
|
|
||||||
public_key = "BGcvgR-i2z4IQ5Mw841vJvkLjt8wY-FjmWrw83jOLCY52qcGZS0OF7nfLzuYbjsQISwVO2HXrmf18gLWVX3Kwfw="
|
|
||||||
|
|
||||||
[api.fcm]
|
|
||||||
# Google Firebase Cloud Messaging Service Account Key
|
|
||||||
# Obtained from the cloud messaging console
|
|
||||||
key_type = ""
|
|
||||||
project_id = ""
|
|
||||||
private_key_id = ""
|
|
||||||
private_key = ""
|
|
||||||
client_email = ""
|
|
||||||
client_id = ""
|
|
||||||
auth_uri = ""
|
|
||||||
token_uri = ""
|
|
||||||
auth_provider_x509_cert_url = ""
|
|
||||||
client_x509_cert_url = ""
|
|
||||||
|
|
||||||
[api.apn]
|
|
||||||
# Apple Push Notifications keys for sending notifications
|
|
||||||
sandbox = false
|
|
||||||
pkcs8 = ""
|
|
||||||
key_id = ""
|
|
||||||
team_id = ""
|
|
||||||
|
|
||||||
[api.security]
|
[api.security]
|
||||||
# Authifier Shield API key
|
# Authifier Shield API key
|
||||||
@@ -84,6 +64,55 @@ hcaptcha_sitekey = ""
|
|||||||
# Maximum concurrent connections (to proxy server)
|
# Maximum concurrent connections (to proxy server)
|
||||||
max_concurrent_connections = 50
|
max_concurrent_connections = 50
|
||||||
|
|
||||||
|
[api.users]
|
||||||
|
|
||||||
|
|
||||||
|
[pushd]
|
||||||
|
# this changes the names of the queues to not overlap
|
||||||
|
# prod/beta if they happen to be on the same exchange/instance.
|
||||||
|
# Usually they have to be, so that messages sent from one or the other get sent to everyone
|
||||||
|
production = true
|
||||||
|
|
||||||
|
# Changes how many users are processed in each chunk when resolving role/everyone mentions.
|
||||||
|
# Increasing this will resolve mentions faster, but will consume more memory while resolving.
|
||||||
|
mass_mention_chunk_size = 200
|
||||||
|
|
||||||
|
# none of these should need changing
|
||||||
|
exchange = "revolt.notifications"
|
||||||
|
message_queue = "notifications.origin.message"
|
||||||
|
mass_mention_queue = "notifications.origin.mass_mention" # handles messages that contain role or everyone mentions
|
||||||
|
fr_accepted_queue = "notifications.ingest.fr_accepted" # friend request accepted
|
||||||
|
fr_received_queue = "notifications.ingest.fr_received" # friend request received
|
||||||
|
generic_queue = "notifications.ingest.generic" # generic messages (title + body)
|
||||||
|
ack_queue = "notifications.process.ack" # updates badges for apple devices
|
||||||
|
|
||||||
|
|
||||||
|
[pushd.vapid]
|
||||||
|
queue = "notifications.outbound.vapid"
|
||||||
|
private_key = "LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUJSUWpyTWxLRnBiVWhsUHpUbERvcEliYk1yeVNrNXpKYzVYVzIxSjJDS3hvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFWnkrQkg2TGJQZ2hEa3pEempXOG0rUXVPM3pCajRXT1phdkR6ZU00c0pqbmFwd1psTFE0WAp1ZDh2TzVodU94QWhMQlU3WWRldVovWHlBdFpWZmNyQi9BPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo"
|
||||||
|
public_key = "BGcvgR-i2z4IQ5Mw841vJvkLjt8wY-FjmWrw83jOLCY52qcGZS0OF7nfLzuYbjsQISwVO2HXrmf18gLWVX3Kwfw="
|
||||||
|
|
||||||
|
[pushd.fcm]
|
||||||
|
queue = "notifications.outbound.fcm"
|
||||||
|
key_type = ""
|
||||||
|
project_id = ""
|
||||||
|
private_key_id = ""
|
||||||
|
private_key = ""
|
||||||
|
client_email = ""
|
||||||
|
client_id = ""
|
||||||
|
auth_uri = ""
|
||||||
|
token_uri = ""
|
||||||
|
auth_provider_x509_cert_url = ""
|
||||||
|
client_x509_cert_url = ""
|
||||||
|
|
||||||
|
[pushd.apn]
|
||||||
|
sandbox = false
|
||||||
|
queue = "notifications.outbound.apn"
|
||||||
|
pkcs8 = ""
|
||||||
|
key_id = ""
|
||||||
|
team_id = ""
|
||||||
|
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
# Encryption key for stored files
|
# Encryption key for stored files
|
||||||
# Generate your own key using `openssl rand -base64 32`
|
# Generate your own key using `openssl rand -base64 32`
|
||||||
@@ -132,6 +161,7 @@ emojis = [128, 128]
|
|||||||
#
|
#
|
||||||
# Backblaze B2:
|
# Backblaze B2:
|
||||||
# - endpoint is listed on the "Buckets" page
|
# - endpoint is listed on the "Buckets" page
|
||||||
|
# - path_style_buckets is set to true
|
||||||
# - region is `eu-central-003` string from endpoint URL
|
# - region is `eu-central-003` string from endpoint URL
|
||||||
# - access_key_id is keyID generated on the "Application Keys" page
|
# - access_key_id is keyID generated on the "Application Keys" page
|
||||||
# - secret_access_key is token generated on the "Application Keys" page
|
# - secret_access_key is token generated on the "Application Keys" page
|
||||||
@@ -139,18 +169,26 @@ emojis = [128, 128]
|
|||||||
|
|
||||||
# S3 protocol endpoint
|
# S3 protocol endpoint
|
||||||
endpoint = "http://minio:9000"
|
endpoint = "http://minio:9000"
|
||||||
|
# Whether to use path-style buckets
|
||||||
|
# Generally true, except for MinIO
|
||||||
|
path_style_buckets = false
|
||||||
# S3 region name
|
# S3 region name
|
||||||
region = "minio"
|
region = "minio"
|
||||||
# S3 protocol key ID
|
# S3 protocol key ID
|
||||||
access_key_id = "minioautumn"
|
access_key_id = "minioautumn"
|
||||||
# S3 protocol access key
|
# S3 protocol access key
|
||||||
secret_access_key = "minioautumn"
|
secret_access_key = "minioautumn"
|
||||||
# Bucket to upload to by default
|
|
||||||
default_bucket = "revolt-uploads"
|
default_bucket = "revolt-uploads"
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Feature gate options
|
# Feature gate options
|
||||||
webhooks_enabled = false
|
webhooks_enabled = false
|
||||||
|
# Enable push notifications for mass pings (everyone, online, roles)
|
||||||
|
# When false this will still ping in-client but will not send notifications from pushd
|
||||||
|
mass_mentions_send_notifications = true
|
||||||
|
# Can role/everyone pings be used at all
|
||||||
|
mass_mentions_enabled = true
|
||||||
|
|
||||||
[features.limits]
|
[features.limits]
|
||||||
|
|
||||||
@@ -224,9 +262,15 @@ icons = 2_500_000
|
|||||||
banners = 6_000_000
|
banners = 6_000_000
|
||||||
emojis = 500_000
|
emojis = 500_000
|
||||||
|
|
||||||
|
[features.advanced]
|
||||||
|
# The max amount of messages the rabbitmq provider/db mention adder job will delay for before forcing handling of a channel.
|
||||||
|
# default: 5
|
||||||
|
process_message_delay_limit = 5
|
||||||
|
|
||||||
[sentry]
|
[sentry]
|
||||||
# Configuration for Sentry error reporting
|
# Configuration for Sentry error reporting
|
||||||
api = ""
|
api = ""
|
||||||
events = ""
|
events = ""
|
||||||
files = ""
|
files = ""
|
||||||
proxy = ""
|
proxy = ""
|
||||||
|
crond = ""
|
||||||
|
|||||||
@@ -23,6 +23,17 @@ macro_rules! report_error {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "report-macros")]
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! capture_internal_error {
|
||||||
|
( $expr: expr ) => {
|
||||||
|
$crate::capture_message(
|
||||||
|
&format!("{:?} ({}:{}:{})", $expr, file!(), line!(), column!()),
|
||||||
|
$crate::Level::Error,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "report-macros")]
|
#[cfg(feature = "report-macros")]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! report_internal_error {
|
macro_rules! report_internal_error {
|
||||||
@@ -79,6 +90,14 @@ pub struct Database {
|
|||||||
pub redis: String,
|
pub redis: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct Rabbit {
|
||||||
|
pub host: String,
|
||||||
|
pub port: u16,
|
||||||
|
pub username: String,
|
||||||
|
pub password: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Hosts {
|
pub struct Hosts {
|
||||||
pub app: String,
|
pub app: String,
|
||||||
@@ -107,13 +126,15 @@ pub struct ApiSmtp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct ApiVapid {
|
pub struct PushVapid {
|
||||||
|
pub queue: String,
|
||||||
pub private_key: String,
|
pub private_key: String,
|
||||||
pub public_key: String,
|
pub public_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct ApiFcm {
|
pub struct PushFcm {
|
||||||
|
pub queue: String,
|
||||||
pub key_type: String,
|
pub key_type: String,
|
||||||
pub project_id: String,
|
pub project_id: String,
|
||||||
pub private_key_id: String,
|
pub private_key_id: String,
|
||||||
@@ -127,7 +148,8 @@ pub struct ApiFcm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct ApiApn {
|
pub struct PushApn {
|
||||||
|
pub queue: String,
|
||||||
pub sandbox: bool,
|
pub sandbox: bool,
|
||||||
pub pkcs8: String,
|
pub pkcs8: String,
|
||||||
pub key_id: String,
|
pub key_id: String,
|
||||||
@@ -153,15 +175,70 @@ pub struct ApiWorkers {
|
|||||||
pub max_concurrent_connections: usize,
|
pub max_concurrent_connections: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct ApiUsers {
|
||||||
|
pub early_adopter_cutoff: Option<u64>
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Api {
|
pub struct Api {
|
||||||
pub registration: ApiRegistration,
|
pub registration: ApiRegistration,
|
||||||
pub smtp: ApiSmtp,
|
pub smtp: ApiSmtp,
|
||||||
pub vapid: ApiVapid,
|
|
||||||
pub fcm: ApiFcm,
|
|
||||||
pub apn: ApiApn,
|
|
||||||
pub security: ApiSecurity,
|
pub security: ApiSecurity,
|
||||||
pub workers: ApiWorkers,
|
pub workers: ApiWorkers,
|
||||||
|
pub users: ApiUsers,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct Pushd {
|
||||||
|
pub production: bool,
|
||||||
|
pub exchange: String,
|
||||||
|
pub mass_mention_chunk_size: usize,
|
||||||
|
|
||||||
|
// Queues
|
||||||
|
pub message_queue: String,
|
||||||
|
pub mass_mention_queue: String,
|
||||||
|
pub fr_accepted_queue: String,
|
||||||
|
pub fr_received_queue: String,
|
||||||
|
pub generic_queue: String,
|
||||||
|
pub ack_queue: String,
|
||||||
|
|
||||||
|
pub vapid: PushVapid,
|
||||||
|
pub fcm: PushFcm,
|
||||||
|
pub apn: PushApn,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pushd {
|
||||||
|
fn get_routing_key(&self, key: String) -> String {
|
||||||
|
match self.production {
|
||||||
|
true => key + "-prd",
|
||||||
|
false => key + "-tst",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_ack_routing_key(&self) -> String {
|
||||||
|
self.get_routing_key(self.ack_queue.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_message_routing_key(&self) -> String {
|
||||||
|
self.get_routing_key(self.message_queue.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_mass_mention_routing_key(&self) -> String {
|
||||||
|
self.get_routing_key(self.mass_mention_queue.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_fr_accepted_routing_key(&self) -> String {
|
||||||
|
self.get_routing_key(self.fr_accepted_queue.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_fr_received_routing_key(&self) -> String {
|
||||||
|
self.get_routing_key(self.fr_received_queue.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_generic_routing_key(&self) -> String {
|
||||||
|
self.get_routing_key(self.generic_queue.clone())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -175,6 +252,7 @@ pub struct FilesLimit {
|
|||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct FilesS3 {
|
pub struct FilesS3 {
|
||||||
pub endpoint: String,
|
pub endpoint: String,
|
||||||
|
pub path_style_buckets: bool,
|
||||||
pub region: String,
|
pub region: String,
|
||||||
pub access_key_id: String,
|
pub access_key_id: String,
|
||||||
pub secret_access_key: String,
|
pub secret_access_key: String,
|
||||||
@@ -232,10 +310,29 @@ pub struct FeaturesLimitsCollection {
|
|||||||
pub roles: HashMap<String, FeaturesLimits>,
|
pub roles: HashMap<String, FeaturesLimits>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct FeaturesAdvanced {
|
||||||
|
#[serde(default)]
|
||||||
|
pub process_message_delay_limit: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for FeaturesAdvanced {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
process_message_delay_limit: 5,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Features {
|
pub struct Features {
|
||||||
pub limits: FeaturesLimitsCollection,
|
pub limits: FeaturesLimitsCollection,
|
||||||
pub webhooks_enabled: bool,
|
pub webhooks_enabled: bool,
|
||||||
|
pub mass_mentions_send_notifications: bool,
|
||||||
|
pub mass_mentions_enabled: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub advanced: FeaturesAdvanced,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -244,16 +341,20 @@ pub struct Sentry {
|
|||||||
pub events: String,
|
pub events: String,
|
||||||
pub files: String,
|
pub files: String,
|
||||||
pub proxy: String,
|
pub proxy: String,
|
||||||
|
pub crond: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub database: Database,
|
pub database: Database,
|
||||||
|
pub rabbit: Rabbit,
|
||||||
pub hosts: Hosts,
|
pub hosts: Hosts,
|
||||||
pub api: Api,
|
pub api: Api,
|
||||||
|
pub pushd: Pushd,
|
||||||
pub files: Files,
|
pub files: Files,
|
||||||
pub features: Features,
|
pub features: Features,
|
||||||
pub sentry: Sentry,
|
pub sentry: Sentry,
|
||||||
|
pub production: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
@@ -281,13 +382,18 @@ pub async fn read() -> Config {
|
|||||||
|
|
||||||
#[cached(time = 30)]
|
#[cached(time = 30)]
|
||||||
pub async fn config() -> Settings {
|
pub async fn config() -> Settings {
|
||||||
read().await.try_deserialize::<Settings>().unwrap()
|
let mut config = read().await.try_deserialize::<Settings>().unwrap();
|
||||||
|
|
||||||
|
// auto-detect production nodes
|
||||||
|
if config.hosts.api.contains("https") && config.hosts.api.contains("revolt.chat") {
|
||||||
|
config.production = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configure logging and common Rust variables
|
/// Configure logging and common Rust variables
|
||||||
pub async fn setup_logging(release: &'static str, dsn: String) -> Option<sentry::ClientInitGuard> {
|
pub async fn setup_logging(release: &'static str, dsn: String) -> Option<sentry::ClientInitGuard> {
|
||||||
dotenv::dotenv().ok();
|
|
||||||
|
|
||||||
if std::env::var("RUST_LOG").is_err() {
|
if std::env::var("RUST_LOG").is_err() {
|
||||||
std::env::set_var("RUST_LOG", "info");
|
std::env::set_var("RUST_LOG", "info");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-database"
|
name = "revolt-database"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
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>"]
|
||||||
@@ -24,18 +24,19 @@ default = ["mongodb", "async-std-runtime", "tasks"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { version = "0.7.16", path = "../config", features = [
|
revolt-config = { version = "0.8.4", path = "../config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.7.16", path = "../result" }
|
revolt-result = { version = "0.8.4", path = "../result" }
|
||||||
revolt-models = { version = "0.7.16", path = "../models", features = [
|
revolt-models = { version = "0.8.4", path = "../models", features = [
|
||||||
"validator",
|
"validator",
|
||||||
] }
|
] }
|
||||||
revolt-presence = { version = "0.7.16", path = "../presence" }
|
revolt-presence = { version = "0.8.4", path = "../presence" }
|
||||||
revolt-permissions = { version = "0.7.16", path = "../permissions", features = [
|
revolt-permissions = { version = "0.8.4", path = "../permissions", features = [
|
||||||
"serde",
|
"serde",
|
||||||
"bson",
|
"bson",
|
||||||
] }
|
] }
|
||||||
|
revolt-parser = { version = "0.1.0", path = "../parser" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
@@ -64,7 +65,7 @@ redis-kiss = { version = "0.1.4" }
|
|||||||
|
|
||||||
# Database
|
# Database
|
||||||
bson = { optional = true, version = "2.1.0" }
|
bson = { optional = true, version = "2.1.0" }
|
||||||
mongodb = { optional = true, version = "2.1.0", default-features = false }
|
mongodb = { optional = true, version = "3.1.0" }
|
||||||
|
|
||||||
# Database Migration
|
# Database Migration
|
||||||
unicode-segmentation = "1.10.1"
|
unicode-segmentation = "1.10.1"
|
||||||
@@ -84,11 +85,11 @@ axum = { version = "0.7.5", optional = true }
|
|||||||
|
|
||||||
# Rocket Impl
|
# Rocket Impl
|
||||||
schemars = { version = "0.8.8", optional = true }
|
schemars = { version = "0.8.8", optional = true }
|
||||||
rocket = { version = "0.5.0-rc.2", default-features = false, features = [
|
rocket = { version = "0.5.1", default-features = false, features = [
|
||||||
"json",
|
"json",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
revolt_okapi = { version = "0.9.1", optional = true }
|
revolt_okapi = { version = "0.9.1", optional = true }
|
||||||
revolt_rocket_okapi = { version = "0.9.1", optional = true }
|
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
||||||
|
|
||||||
# Notifications
|
# Notifications
|
||||||
fcm_v1 = "0.3.0"
|
fcm_v1 = "0.3.0"
|
||||||
@@ -96,4 +97,7 @@ web-push = "0.10.0"
|
|||||||
revolt_a2 = { version = "0.10", default-features = false, features = ["ring"] }
|
revolt_a2 = { version = "0.10", default-features = false, features = ["ring"] }
|
||||||
|
|
||||||
# Authifier
|
# Authifier
|
||||||
authifier = { version = "1.0.8" }
|
authifier = { version = "1.0.10", features = ["rocket_impl"] }
|
||||||
|
|
||||||
|
# RabbitMQ
|
||||||
|
amqprs = { version = "1.7.0" }
|
||||||
|
|||||||
@@ -0,0 +1,243 @@
|
|||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
use crate::events::rabbit::*;
|
||||||
|
use crate::User;
|
||||||
|
use amqprs::channel::BasicPublishArguments;
|
||||||
|
use amqprs::{channel::Channel, connection::Connection, error::Error as AMQPError};
|
||||||
|
use amqprs::{BasicProperties, FieldTable};
|
||||||
|
use revolt_models::v0::PushNotification;
|
||||||
|
use revolt_presence::filter_online;
|
||||||
|
|
||||||
|
use serde_json::to_string;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct AMQP {
|
||||||
|
#[allow(unused)]
|
||||||
|
connection: Connection,
|
||||||
|
channel: Channel,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AMQP {
|
||||||
|
pub fn new(connection: Connection, channel: Channel) -> AMQP {
|
||||||
|
AMQP {
|
||||||
|
connection,
|
||||||
|
channel,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn friend_request_accepted(
|
||||||
|
&self,
|
||||||
|
accepted_request_user: &User,
|
||||||
|
sent_request_user: &User,
|
||||||
|
) -> Result<(), AMQPError> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
let payload = FRAcceptedPayload {
|
||||||
|
accepted_user: accepted_request_user.to_owned(),
|
||||||
|
user: sent_request_user.id.clone(),
|
||||||
|
};
|
||||||
|
let payload = to_string(&payload).unwrap();
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Sending friend request accept payload on channel {}: {}",
|
||||||
|
config.pushd.get_fr_accepted_routing_key(),
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
self.channel
|
||||||
|
.basic_publish(
|
||||||
|
BasicProperties::default()
|
||||||
|
.with_content_type("application/json")
|
||||||
|
.with_persistence(true)
|
||||||
|
.finish(),
|
||||||
|
payload.into(),
|
||||||
|
BasicPublishArguments::new(
|
||||||
|
&config.pushd.exchange,
|
||||||
|
&config.pushd.get_fr_accepted_routing_key(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn friend_request_received(
|
||||||
|
&self,
|
||||||
|
received_request_user: &User,
|
||||||
|
sent_request_user: &User,
|
||||||
|
) -> Result<(), AMQPError> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
let payload = FRReceivedPayload {
|
||||||
|
from_user: sent_request_user.to_owned(),
|
||||||
|
user: received_request_user.id.clone(),
|
||||||
|
};
|
||||||
|
let payload = to_string(&payload).unwrap();
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Sending friend request received payload on channel {}: {}",
|
||||||
|
config.pushd.get_fr_received_routing_key(),
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
|
||||||
|
self.channel
|
||||||
|
.basic_publish(
|
||||||
|
BasicProperties::default()
|
||||||
|
.with_content_type("application/json")
|
||||||
|
.with_persistence(true)
|
||||||
|
.finish(),
|
||||||
|
payload.into(),
|
||||||
|
BasicPublishArguments::new(
|
||||||
|
&config.pushd.exchange,
|
||||||
|
&config.pushd.get_fr_received_routing_key(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn generic_message(
|
||||||
|
&self,
|
||||||
|
user: &User,
|
||||||
|
title: String,
|
||||||
|
body: String,
|
||||||
|
icon: Option<String>,
|
||||||
|
) -> Result<(), AMQPError> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
let payload = GenericPayload {
|
||||||
|
title,
|
||||||
|
body,
|
||||||
|
icon,
|
||||||
|
user: user.to_owned(),
|
||||||
|
};
|
||||||
|
let payload = to_string(&payload).unwrap();
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Sending generic payload on channel {}: {}",
|
||||||
|
config.pushd.get_generic_routing_key(),
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
|
||||||
|
self.channel
|
||||||
|
.basic_publish(
|
||||||
|
BasicProperties::default()
|
||||||
|
.with_content_type("application/json")
|
||||||
|
.with_persistence(true)
|
||||||
|
.finish(),
|
||||||
|
payload.into(),
|
||||||
|
BasicPublishArguments::new(
|
||||||
|
&config.pushd.exchange,
|
||||||
|
&config.pushd.get_generic_routing_key(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn message_sent(
|
||||||
|
&self,
|
||||||
|
recipients: Vec<String>,
|
||||||
|
payload: PushNotification,
|
||||||
|
) -> Result<(), AMQPError> {
|
||||||
|
if recipients.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
|
let online_ids = filter_online(&recipients).await;
|
||||||
|
let recipients = (&recipients.into_iter().collect::<HashSet<String>>() - &online_ids)
|
||||||
|
.into_iter()
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
|
let payload = MessageSentPayload {
|
||||||
|
notification: payload,
|
||||||
|
users: recipients,
|
||||||
|
};
|
||||||
|
let payload = to_string(&payload).unwrap();
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Sending message payload on channel {}: {}",
|
||||||
|
config.pushd.get_message_routing_key(),
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
|
||||||
|
self.channel
|
||||||
|
.basic_publish(
|
||||||
|
BasicProperties::default()
|
||||||
|
.with_content_type("application/json")
|
||||||
|
.with_persistence(true)
|
||||||
|
.finish(),
|
||||||
|
payload.into(),
|
||||||
|
BasicPublishArguments::new(
|
||||||
|
&config.pushd.exchange,
|
||||||
|
&config.pushd.get_message_routing_key(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn mass_mention_message_sent(
|
||||||
|
&self,
|
||||||
|
server_id: String,
|
||||||
|
payload: Vec<PushNotification>,
|
||||||
|
) -> Result<(), AMQPError> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
|
let payload = MassMessageSentPayload {
|
||||||
|
notifications: payload,
|
||||||
|
server_id,
|
||||||
|
};
|
||||||
|
let payload = to_string(&payload).unwrap();
|
||||||
|
|
||||||
|
let routing_key = config.pushd.get_mass_mention_routing_key();
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Sending mass mention payload on channel {}: {}",
|
||||||
|
routing_key, payload
|
||||||
|
);
|
||||||
|
|
||||||
|
self.channel
|
||||||
|
.basic_publish(
|
||||||
|
BasicProperties::default()
|
||||||
|
.with_content_type("application/json")
|
||||||
|
.with_persistence(true)
|
||||||
|
.finish(),
|
||||||
|
payload.into(),
|
||||||
|
BasicPublishArguments::new(&config.pushd.exchange, routing_key.as_str()),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn ack_message(
|
||||||
|
&self,
|
||||||
|
user_id: String,
|
||||||
|
channel_id: String,
|
||||||
|
message_id: String,
|
||||||
|
) -> Result<(), AMQPError> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
|
let payload = AckPayload {
|
||||||
|
user_id: user_id.clone(),
|
||||||
|
channel_id: channel_id.clone(),
|
||||||
|
message_id,
|
||||||
|
};
|
||||||
|
let payload = to_string(&payload).unwrap();
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Sending ack payload on channel {}: {}",
|
||||||
|
config.pushd.ack_queue, payload
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut headers = FieldTable::new();
|
||||||
|
headers.insert(
|
||||||
|
"x-deduplication-header".try_into().unwrap(),
|
||||||
|
format!("{}-{}", &user_id, &channel_id).into(),
|
||||||
|
);
|
||||||
|
|
||||||
|
self.channel
|
||||||
|
.basic_publish(
|
||||||
|
BasicProperties::default()
|
||||||
|
.with_content_type("application/json")
|
||||||
|
.with_persistence(true)
|
||||||
|
//.with_headers(headers)
|
||||||
|
.finish(),
|
||||||
|
payload.into(),
|
||||||
|
BasicPublishArguments::new(&config.pushd.exchange, &config.pushd.ack_queue),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#[allow(clippy::module_inception)]
|
||||||
|
pub mod amqp;
|
||||||
@@ -120,26 +120,50 @@ impl Database {
|
|||||||
use_tls: config.api.smtp.use_tls,
|
use_tls: config.api.smtp.use_tls,
|
||||||
},
|
},
|
||||||
expiry: Default::default(),
|
expiry: Default::default(),
|
||||||
templates: Templates {
|
templates: if config.production {
|
||||||
verify: Template {
|
Templates {
|
||||||
title: "Verify your Revolt account.".into(),
|
verify: Template {
|
||||||
text: include_str!("../../templates/verify.txt").into(),
|
title: "Verify your Revolt account.".into(),
|
||||||
url: format!("{}/login/verify/", config.hosts.app),
|
text: include_str!("../../templates/verify.txt").into(),
|
||||||
html: Some(include_str!("../../templates/verify.html").into()),
|
url: format!("{}/login/verify/", config.hosts.app),
|
||||||
},
|
html: Some(include_str!("../../templates/verify.html").into()),
|
||||||
reset: Template {
|
},
|
||||||
title: "Reset your Revolt password.".into(),
|
reset: Template {
|
||||||
text: include_str!("../../templates/reset.txt").into(),
|
title: "Reset your Revolt password.".into(),
|
||||||
url: format!("{}/login/reset/", config.hosts.app),
|
text: include_str!("../../templates/reset.txt").into(),
|
||||||
html: Some(include_str!("../../templates/reset.html").into()),
|
url: format!("{}/login/reset/", config.hosts.app),
|
||||||
},
|
html: Some(include_str!("../../templates/reset.html").into()),
|
||||||
deletion: Template {
|
},
|
||||||
title: "Confirm account deletion.".into(),
|
deletion: Template {
|
||||||
text: include_str!("../../templates/deletion.txt").into(),
|
title: "Confirm account deletion.".into(),
|
||||||
url: format!("{}/delete/", config.hosts.app),
|
text: include_str!("../../templates/deletion.txt").into(),
|
||||||
html: Some(include_str!("../../templates/deletion.html").into()),
|
url: format!("{}/delete/", config.hosts.app),
|
||||||
},
|
html: Some(include_str!("../../templates/deletion.html").into()),
|
||||||
welcome: None,
|
},
|
||||||
|
welcome: None,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Templates {
|
||||||
|
verify: Template {
|
||||||
|
title: "Verify your account.".into(),
|
||||||
|
text: include_str!("../../templates/verify.whitelabel.txt").into(),
|
||||||
|
url: format!("{}/login/verify/", config.hosts.app),
|
||||||
|
html: None,
|
||||||
|
},
|
||||||
|
reset: Template {
|
||||||
|
title: "Reset your password.".into(),
|
||||||
|
text: include_str!("../../templates/reset.whitelabel.txt").into(),
|
||||||
|
url: format!("{}/login/reset/", config.hosts.app),
|
||||||
|
html: None,
|
||||||
|
},
|
||||||
|
deletion: Template {
|
||||||
|
title: "Confirm account deletion.".into(),
|
||||||
|
text: include_str!("../../templates/deletion.whitelabel.txt").into(),
|
||||||
|
url: format!("{}/delete/", config.hosts.app),
|
||||||
|
html: None,
|
||||||
|
},
|
||||||
|
welcome: None,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -31,17 +31,17 @@ impl MongoDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a collection by its name
|
/// Get a collection by its name
|
||||||
pub fn col<T>(&self, collection: &str) -> mongodb::Collection<T> {
|
pub fn col<T: Send + Sync>(&self, collection: &str) -> mongodb::Collection<T> {
|
||||||
self.db().collection(collection)
|
self.db().collection(collection)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert one document into a collection
|
/// Insert one document into a collection
|
||||||
pub async fn insert_one<T: Serialize>(
|
pub async fn insert_one<T: Serialize + Send + Sync>(
|
||||||
&self,
|
&self,
|
||||||
collection: &'static str,
|
collection: &'static str,
|
||||||
document: T,
|
document: T,
|
||||||
) -> Result<InsertOneResult> {
|
) -> Result<InsertOneResult> {
|
||||||
self.col::<T>(collection).insert_one(document, None).await
|
self.col::<T>(collection).insert_one(document).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Count documents by projection
|
/// Count documents by projection
|
||||||
@@ -51,7 +51,7 @@ impl MongoDb {
|
|||||||
projection: Document,
|
projection: Document,
|
||||||
) -> Result<u64> {
|
) -> Result<u64> {
|
||||||
self.col::<Document>(collection)
|
self.col::<Document>(collection)
|
||||||
.count_documents(projection, None)
|
.count_documents(projection)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,8 @@ impl MongoDb {
|
|||||||
{
|
{
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<T>(collection)
|
.col::<T>(collection)
|
||||||
.find(projection, options)
|
.find(projection)
|
||||||
|
.with_options(options)
|
||||||
.await?
|
.await?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
@@ -101,7 +102,8 @@ impl MongoDb {
|
|||||||
O: Into<Option<FindOneOptions>>,
|
O: Into<Option<FindOneOptions>>,
|
||||||
{
|
{
|
||||||
self.col::<T>(collection)
|
self.col::<T>(collection)
|
||||||
.find_one(projection, options)
|
.find_one(projection)
|
||||||
|
.with_options(options)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +167,7 @@ impl MongoDb {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.col::<Document>(collection)
|
self.col::<Document>(collection)
|
||||||
.update_one(projection, query, None)
|
.update_one(projection, query)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +202,7 @@ impl MongoDb {
|
|||||||
projection: Document,
|
projection: Document,
|
||||||
) -> Result<DeleteResult> {
|
) -> Result<DeleteResult> {
|
||||||
self.col::<Document>(collection)
|
self.col::<Document>(collection)
|
||||||
.delete_one(projection, None)
|
.delete_one(projection)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,16 @@
|
|||||||
use authifier::AuthifierEvent;
|
use authifier::AuthifierEvent;
|
||||||
|
use revolt_result::Error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use revolt_models::v0::{
|
use revolt_models::v0::{
|
||||||
AppendMessage, Channel, ChannelUnread, Emoji, FieldsChannel, FieldsMember, FieldsMessage, FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message, PartialChannel, PartialMember, PartialMessage, PartialRole, PartialServer, PartialUser, PartialWebhook, RemovalIntention, Report, Server, User, UserSettings, Webhook
|
AppendMessage, Channel, ChannelUnread, Emoji, FieldsChannel, FieldsMember, FieldsMessage,
|
||||||
|
FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message,
|
||||||
|
PartialChannel, PartialMember, PartialMessage, PartialRole, PartialServer, PartialUser,
|
||||||
|
PartialWebhook, RemovalIntention, Report, Server, User, UserSettings, Webhook,
|
||||||
};
|
};
|
||||||
use revolt_result::Error;
|
|
||||||
|
|
||||||
use crate::Database;
|
use crate::Database;
|
||||||
|
|
||||||
/// WebSocket Client Errors
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
||||||
#[serde(tag = "error")]
|
|
||||||
pub enum WebSocketError {
|
|
||||||
LabelMe,
|
|
||||||
InternalError { at: String },
|
|
||||||
InvalidSession,
|
|
||||||
OnboardingNotFinished,
|
|
||||||
AlreadyAuthenticated,
|
|
||||||
MalformedData { msg: String },
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ping Packet
|
/// Ping Packet
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
@@ -28,14 +19,6 @@ pub enum Ping {
|
|||||||
Number(usize),
|
Number(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Untagged Error
|
|
||||||
#[derive(Serialize)]
|
|
||||||
#[serde(untagged)]
|
|
||||||
pub enum ErrorEvent {
|
|
||||||
Error(WebSocketError),
|
|
||||||
APIError(Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fields provided in Ready payload
|
/// Fields provided in Ready payload
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum ReadyPayloadFields {
|
pub enum ReadyPayloadFields {
|
||||||
@@ -55,6 +38,8 @@ pub enum ReadyPayloadFields {
|
|||||||
pub enum EventV1 {
|
pub enum EventV1 {
|
||||||
/// Multiple events
|
/// Multiple events
|
||||||
Bulk { v: Vec<EventV1> },
|
Bulk { v: Vec<EventV1> },
|
||||||
|
/// Error event
|
||||||
|
Error { data: Error },
|
||||||
|
|
||||||
/// Successfully authenticated
|
/// Successfully authenticated
|
||||||
Authenticated,
|
Authenticated,
|
||||||
@@ -89,6 +74,7 @@ pub enum EventV1 {
|
|||||||
id: String,
|
id: String,
|
||||||
channel: String,
|
channel: String,
|
||||||
data: PartialMessage,
|
data: PartialMessage,
|
||||||
|
#[serde(default)]
|
||||||
clear: Vec<FieldsMessage>,
|
clear: Vec<FieldsMessage>,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -140,6 +126,7 @@ pub enum EventV1 {
|
|||||||
ServerUpdate {
|
ServerUpdate {
|
||||||
id: String,
|
id: String,
|
||||||
data: PartialServer,
|
data: PartialServer,
|
||||||
|
#[serde(default)]
|
||||||
clear: Vec<FieldsServer>,
|
clear: Vec<FieldsServer>,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -150,6 +137,7 @@ pub enum EventV1 {
|
|||||||
ServerMemberUpdate {
|
ServerMemberUpdate {
|
||||||
id: MemberCompositeKey,
|
id: MemberCompositeKey,
|
||||||
data: PartialMember,
|
data: PartialMember,
|
||||||
|
#[serde(default)]
|
||||||
clear: Vec<FieldsMember>,
|
clear: Vec<FieldsMember>,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -168,6 +156,7 @@ pub enum EventV1 {
|
|||||||
id: String,
|
id: String,
|
||||||
role_id: String,
|
role_id: String,
|
||||||
data: PartialRole,
|
data: PartialRole,
|
||||||
|
#[serde(default)]
|
||||||
clear: Vec<FieldsRole>,
|
clear: Vec<FieldsRole>,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -178,6 +167,7 @@ pub enum EventV1 {
|
|||||||
UserUpdate {
|
UserUpdate {
|
||||||
id: String,
|
id: String,
|
||||||
data: PartialUser,
|
data: PartialUser,
|
||||||
|
#[serde(default)]
|
||||||
clear: Vec<FieldsUser>,
|
clear: Vec<FieldsUser>,
|
||||||
event_id: Option<String>,
|
event_id: Option<String>,
|
||||||
},
|
},
|
||||||
@@ -212,6 +202,7 @@ pub enum EventV1 {
|
|||||||
ChannelUpdate {
|
ChannelUpdate {
|
||||||
id: String,
|
id: String,
|
||||||
data: PartialChannel,
|
data: PartialChannel,
|
||||||
|
#[serde(default)]
|
||||||
clear: Vec<FieldsChannel>,
|
clear: Vec<FieldsChannel>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
pub mod client;
|
pub mod client;
|
||||||
|
pub mod rabbit;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use revolt_models::v0::PushNotification;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::User;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct MessageSentPayload {
|
||||||
|
pub notification: PushNotification,
|
||||||
|
pub users: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct MassMessageSentPayload {
|
||||||
|
pub notifications: Vec<PushNotification>,
|
||||||
|
pub server_id: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
pub struct FRAcceptedPayload {
|
||||||
|
pub accepted_user: User,
|
||||||
|
pub user: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
pub struct FRReceivedPayload {
|
||||||
|
pub from_user: User,
|
||||||
|
pub user: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
pub struct GenericPayload {
|
||||||
|
pub title: String,
|
||||||
|
pub body: String,
|
||||||
|
pub icon: Option<String>,
|
||||||
|
pub user: User,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "type", content = "data")]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
pub enum PayloadKind {
|
||||||
|
MessageNotification(PushNotification),
|
||||||
|
FRAccepted(FRAcceptedPayload),
|
||||||
|
FRReceived(FRReceivedPayload),
|
||||||
|
BadgeUpdate(usize),
|
||||||
|
Generic(GenericPayload),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct PayloadToService {
|
||||||
|
pub notification: PayloadKind,
|
||||||
|
pub user_id: String,
|
||||||
|
pub session_id: String,
|
||||||
|
pub token: String,
|
||||||
|
pub extras: HashMap<String, String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct AckPayload {
|
||||||
|
pub user_id: String,
|
||||||
|
pub channel_id: String,
|
||||||
|
pub message_id: String,
|
||||||
|
}
|
||||||
@@ -25,6 +25,26 @@ pub use mongodb;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bson;
|
extern crate bson;
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
macro_rules! query {
|
||||||
|
( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
|
||||||
|
Ok($self.$type($collection, $($rest),+).await.unwrap())
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
macro_rules! query {
|
||||||
|
( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
|
||||||
|
$self.$type($collection, $($rest),+).await
|
||||||
|
.map_err(|err| {
|
||||||
|
revolt_config::capture_internal_error!(err);
|
||||||
|
create_database_error!(stringify!($type), $collection)
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! database_derived {
|
macro_rules! database_derived {
|
||||||
( $( $item:item )+ ) => {
|
( $( $item:item )+ ) => {
|
||||||
$(
|
$(
|
||||||
@@ -85,6 +105,9 @@ pub use models::*;
|
|||||||
pub mod events;
|
pub mod events;
|
||||||
pub mod tasks;
|
pub mod tasks;
|
||||||
|
|
||||||
|
mod amqp;
|
||||||
|
pub use amqp::amqp::AMQP;
|
||||||
|
|
||||||
/// Utility function to check if a boolean value is false
|
/// Utility function to check if a boolean value is false
|
||||||
pub fn if_false(t: &bool) -> bool {
|
pub fn if_false(t: &bool) -> bool {
|
||||||
!t
|
!t
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ impl AbstractMigrations for MongoDb {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
/// Drop the database
|
/// Drop the database
|
||||||
async fn drop_database(&self) {
|
async fn drop_database(&self) {
|
||||||
self.db().drop(None).await.ok();
|
self.db().drop().await.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Migrate the database
|
/// Migrate the database
|
||||||
@@ -18,7 +18,7 @@ impl AbstractMigrations for MongoDb {
|
|||||||
info!("Migrating the database.");
|
info!("Migrating the database.");
|
||||||
|
|
||||||
let list = self
|
let list = self
|
||||||
.list_database_names(None, None)
|
.list_database_names()
|
||||||
.await
|
.await
|
||||||
.expect("Failed to fetch database names.");
|
.expect("Failed to fetch database names.");
|
||||||
|
|
||||||
|
|||||||
@@ -8,278 +8,254 @@ pub async fn create_database(db: &MongoDb) {
|
|||||||
info!("Creating database.");
|
info!("Creating database.");
|
||||||
let db = db.db();
|
let db = db.db();
|
||||||
|
|
||||||
db.create_collection("accounts", None)
|
db.create_collection("accounts")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create accounts collection.");
|
.expect("Failed to create accounts collection.");
|
||||||
|
|
||||||
db.create_collection("users", None)
|
db.create_collection("users")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create users collection.");
|
.expect("Failed to create users collection.");
|
||||||
|
|
||||||
db.create_collection("channels", None)
|
db.create_collection("channels")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create channels collection.");
|
.expect("Failed to create channels collection.");
|
||||||
|
|
||||||
db.create_collection("messages", None)
|
db.create_collection("messages")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create messages collection.");
|
.expect("Failed to create messages collection.");
|
||||||
|
|
||||||
db.create_collection("servers", None)
|
db.create_collection("servers")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create servers collection.");
|
.expect("Failed to create servers collection.");
|
||||||
|
|
||||||
db.create_collection("server_members", None)
|
db.create_collection("server_members")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create server_members collection.");
|
.expect("Failed to create server_members collection.");
|
||||||
|
|
||||||
db.create_collection("server_bans", None)
|
db.create_collection("server_bans")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create server_bans collection.");
|
.expect("Failed to create server_bans collection.");
|
||||||
|
|
||||||
db.create_collection("channel_invites", None)
|
db.create_collection("channel_invites")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create channel_invites collection.");
|
.expect("Failed to create channel_invites collection.");
|
||||||
|
|
||||||
db.create_collection("channel_unreads", None)
|
db.create_collection("channel_unreads")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create channel_unreads collection.");
|
.expect("Failed to create channel_unreads collection.");
|
||||||
|
|
||||||
db.create_collection("channel_webhooks", None)
|
db.create_collection("channel_webhooks")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create channel_webhooks collection.");
|
.expect("Failed to create channel_webhooks collection.");
|
||||||
|
|
||||||
db.create_collection("migrations", None)
|
db.create_collection("migrations")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create migrations collection.");
|
.expect("Failed to create migrations collection.");
|
||||||
|
|
||||||
db.create_collection("attachments", None)
|
db.create_collection("attachments")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create attachments collection.");
|
.expect("Failed to create attachments collection.");
|
||||||
|
|
||||||
db.create_collection("attachment_hashes", None)
|
db.create_collection("attachment_hashes")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create attachment_hashes collection.");
|
.expect("Failed to create attachment_hashes collection.");
|
||||||
|
|
||||||
db.create_collection("user_settings", None)
|
db.create_collection("user_settings")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create user_settings collection.");
|
.expect("Failed to create user_settings collection.");
|
||||||
|
|
||||||
db.create_collection("safety_reports", None)
|
db.create_collection("safety_reports")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create safety_reports collection.");
|
.expect("Failed to create safety_reports collection.");
|
||||||
|
|
||||||
db.create_collection("safety_snapshots", None)
|
db.create_collection("safety_snapshots")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create safety_snapshots collection.");
|
.expect("Failed to create safety_snapshots collection.");
|
||||||
|
|
||||||
db.create_collection("safety_strikes", None)
|
db.create_collection("safety_strikes")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create safety_strikes collection.");
|
.expect("Failed to create safety_strikes collection.");
|
||||||
|
|
||||||
db.create_collection("bots", None)
|
db.create_collection("bots")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create bots collection.");
|
.expect("Failed to create bots collection.");
|
||||||
|
|
||||||
db.create_collection("ratelimit_events", None)
|
db.create_collection("ratelimit_events")
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create ratelimit_events collection.");
|
.expect("Failed to create ratelimit_events collection.");
|
||||||
|
|
||||||
db.create_collection(
|
db.create_collection("pubsub")
|
||||||
"pubsub",
|
.with_options(
|
||||||
CreateCollectionOptions::builder()
|
CreateCollectionOptions::builder()
|
||||||
.capped(true)
|
.capped(true)
|
||||||
.size(1_000_000)
|
.size(1_000_000)
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create pubsub collection.");
|
.expect("Failed to create pubsub collection.");
|
||||||
|
|
||||||
db.run_command(
|
db.run_command(doc! {
|
||||||
doc! {
|
"createIndexes": "users",
|
||||||
"createIndexes": "users",
|
"indexes": [
|
||||||
"indexes": [
|
{
|
||||||
{
|
"key": {
|
||||||
"key": {
|
"username": 1_i32
|
||||||
"username": 1_i32
|
|
||||||
},
|
|
||||||
"name": "username",
|
|
||||||
"unique": false,
|
|
||||||
"collation": {
|
|
||||||
"locale": "en",
|
|
||||||
"strength": 2_i32
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
"name": "username",
|
||||||
"key": {
|
"unique": false,
|
||||||
"username": 1_i32,
|
"collation": {
|
||||||
"discriminator": 1_i32
|
"locale": "en",
|
||||||
},
|
"strength": 2_i32
|
||||||
"name": "username_discriminator",
|
|
||||||
"unique": true,
|
|
||||||
"collation": {
|
|
||||||
"locale": "en",
|
|
||||||
"strength": 2_i32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
},
|
{
|
||||||
None,
|
"key": {
|
||||||
)
|
"username": 1_i32,
|
||||||
|
"discriminator": 1_i32
|
||||||
|
},
|
||||||
|
"name": "username_discriminator",
|
||||||
|
"unique": true,
|
||||||
|
"collation": {
|
||||||
|
"locale": "en",
|
||||||
|
"strength": 2_i32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create username index.");
|
.expect("Failed to create username index.");
|
||||||
|
|
||||||
db.run_command(
|
db.run_command(doc! {
|
||||||
doc! {
|
"createIndexes": "messages",
|
||||||
"createIndexes": "messages",
|
"indexes": [
|
||||||
"indexes": [
|
{
|
||||||
{
|
"key": {
|
||||||
"key": {
|
"content": "text"
|
||||||
"content": "text"
|
|
||||||
},
|
|
||||||
"name": "content"
|
|
||||||
},
|
},
|
||||||
{
|
"name": "content"
|
||||||
"key": {
|
},
|
||||||
"channel": 1_i32,
|
{
|
||||||
"_id": 1_i32
|
"key": {
|
||||||
},
|
"channel": 1_i32,
|
||||||
"name": "channel_id_compound"
|
"_id": 1_i32
|
||||||
},
|
},
|
||||||
{
|
"name": "channel_id_compound"
|
||||||
"key": {
|
},
|
||||||
"author": 1_i32
|
{
|
||||||
},
|
"key": {
|
||||||
"name": "author"
|
"author": 1_i32
|
||||||
},
|
},
|
||||||
{
|
"name": "author"
|
||||||
"key": {
|
},
|
||||||
"channel": 1_i32,
|
{
|
||||||
"pinned": 1_i32
|
"key": {
|
||||||
},
|
"channel": 1_i32,
|
||||||
"name": "channel_pinned_compound"
|
"pinned": 1_i32
|
||||||
},
|
},
|
||||||
]
|
"name": "channel_pinned_compound"
|
||||||
},
|
},
|
||||||
None,
|
]
|
||||||
)
|
})
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create message index.");
|
.expect("Failed to create message index.");
|
||||||
|
|
||||||
db.run_command(
|
db.run_command(doc! {
|
||||||
doc! {
|
"createIndexes": "channel_unreads",
|
||||||
"createIndexes": "channel_unreads",
|
"indexes": [
|
||||||
"indexes": [
|
{
|
||||||
{
|
"key": {
|
||||||
"key": {
|
"_id.channel": 1_i32,
|
||||||
"_id.channel": 1_i32,
|
"_id.user": 1_i32,
|
||||||
"_id.user": 1_i32,
|
|
||||||
},
|
|
||||||
"name": "compound_id"
|
|
||||||
},
|
},
|
||||||
{
|
"name": "compound_id"
|
||||||
"key": {
|
},
|
||||||
"_id.user": 1_i32,
|
{
|
||||||
},
|
"key": {
|
||||||
"name": "user_id"
|
"_id.user": 1_i32,
|
||||||
}
|
},
|
||||||
]
|
"name": "user_id"
|
||||||
},
|
}
|
||||||
None,
|
]
|
||||||
)
|
})
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create channel_unreads index.");
|
.expect("Failed to create channel_unreads index.");
|
||||||
|
|
||||||
db.run_command(
|
db.run_command(doc! {
|
||||||
doc! {
|
"createIndexes": "server_members",
|
||||||
"createIndexes": "server_members",
|
"indexes": [
|
||||||
"indexes": [
|
{
|
||||||
{
|
"key": {
|
||||||
"key": {
|
"_id.server": 1_i32,
|
||||||
"_id.server": 1_i32,
|
"_id.user": 1_i32,
|
||||||
"_id.user": 1_i32,
|
|
||||||
},
|
|
||||||
"name": "compound_id"
|
|
||||||
},
|
},
|
||||||
{
|
"name": "compound_id"
|
||||||
"key": {
|
},
|
||||||
"_id.user": 1_i32,
|
{
|
||||||
},
|
"key": {
|
||||||
"name": "user_id"
|
"_id.user": 1_i32,
|
||||||
}
|
},
|
||||||
]
|
"name": "user_id"
|
||||||
},
|
}
|
||||||
None,
|
]
|
||||||
)
|
})
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create server_members index.");
|
.expect("Failed to create server_members index.");
|
||||||
|
|
||||||
db.run_command(
|
db.run_command(doc! {
|
||||||
doc! {
|
"createIndexes": "attachments",
|
||||||
"createIndexes": "attachments",
|
"indexes": [
|
||||||
"indexes": [
|
{
|
||||||
{
|
"key": {
|
||||||
"key": {
|
"hash": 1_i32
|
||||||
"hash": 1_i32
|
|
||||||
},
|
|
||||||
"name": "hash"
|
|
||||||
},
|
},
|
||||||
{
|
"name": "hash"
|
||||||
"key": {
|
},
|
||||||
"used_for.id": 1_i32
|
{
|
||||||
},
|
"key": {
|
||||||
"name": "used_for_id"
|
"used_for.id": 1_i32
|
||||||
}
|
},
|
||||||
]
|
"name": "used_for_id"
|
||||||
},
|
}
|
||||||
None,
|
]
|
||||||
)
|
})
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create attachments index.");
|
.expect("Failed to create attachments index.");
|
||||||
|
|
||||||
db.run_command(
|
db.run_command(doc! {
|
||||||
doc! {
|
"createIndexes": "attachment_hashes",
|
||||||
"createIndexes": "attachment_hashes",
|
"indexes": [
|
||||||
"indexes": [
|
{
|
||||||
{
|
"key": {
|
||||||
"key": {
|
"processed_hash": 1_i32
|
||||||
"processed_hash": 1_i32
|
},
|
||||||
},
|
"name": "processed_hash"
|
||||||
"name": "processed_hash"
|
}
|
||||||
}
|
]
|
||||||
]
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create attachment_hashes index.");
|
.expect("Failed to create attachment_hashes index.");
|
||||||
|
|
||||||
db.collection("migrations")
|
db.collection("migrations")
|
||||||
.insert_one(
|
.insert_one(doc! {
|
||||||
doc! {
|
"_id": 0_i32,
|
||||||
"_id": 0_i32,
|
"revision": LATEST_REVISION
|
||||||
"revision": LATEST_REVISION
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.expect("Failed to save migration info.");
|
.expect("Failed to save migration info.");
|
||||||
|
|
||||||
db.run_command(
|
db.run_command(doc! {
|
||||||
doc! {
|
"createIndexes": "ratelimit_events",
|
||||||
"createIndexes": "ratelimit_events",
|
"indexes": [
|
||||||
"indexes": [
|
{
|
||||||
{
|
"key": {
|
||||||
"key": {
|
"_id": 1_i32,
|
||||||
"_id": 1_i32,
|
"target_id": 1_i32,
|
||||||
"target_id": 1_i32,
|
"event_type": 1_i32,
|
||||||
"event_type": 1_i32,
|
},
|
||||||
},
|
"name": "compound_key"
|
||||||
"name": "compound_key"
|
}
|
||||||
}
|
]
|
||||||
]
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create ratelimit_events index.");
|
.expect("Failed to create ratelimit_events index.");
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -24,12 +24,9 @@ impl AbstractChannelInvites for MongoDb {
|
|||||||
async fn fetch_invites_for_server(&self, server_id: &str) -> Result<Vec<Invite>> {
|
async fn fetch_invites_for_server(&self, server_id: &str) -> Result<Vec<Invite>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<Invite>(COL)
|
.col::<Invite>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"server": server_id,
|
||||||
"server": server_id,
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", COL))?
|
.map_err(|_| create_database_error!("find", COL))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
|
|||||||
@@ -26,6 +26,17 @@ pub trait AbstractChannelUnreads: Sync + Send {
|
|||||||
message_ids: &[String],
|
message_ids: &[String],
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
|
/// Add a mention.
|
||||||
|
async fn add_mention_to_many_unreads<'a>(
|
||||||
|
&self,
|
||||||
|
channel_id: &str,
|
||||||
|
user_ids: &[String],
|
||||||
|
message_ids: &[String],
|
||||||
|
) -> Result<()>;
|
||||||
|
|
||||||
|
/// Fetch all unreads with mentions for a user.
|
||||||
|
async fn fetch_unread_mentions(&self, user_id: &str) -> Result<Vec<ChannelUnread>>;
|
||||||
|
|
||||||
/// Fetch all channel unreads for a user.
|
/// Fetch all channel unreads for a user.
|
||||||
async fn fetch_unreads(&self, user_id: &str) -> Result<Vec<ChannelUnread>>;
|
async fn fetch_unreads(&self, user_id: &str) -> Result<Vec<ChannelUnread>>;
|
||||||
|
|
||||||
|
|||||||
@@ -30,13 +30,15 @@ impl AbstractChannelUnreads for MongoDb {
|
|||||||
doc! {
|
doc! {
|
||||||
"$pull": {
|
"$pull": {
|
||||||
"mentions": {
|
"mentions": {
|
||||||
"$lt": message_id
|
"$lte": message_id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"$set": {
|
"$set": {
|
||||||
"last_id": message_id
|
"last_id": message_id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
)
|
||||||
|
.with_options(
|
||||||
FindOneAndUpdateOptions::builder()
|
FindOneAndUpdateOptions::builder()
|
||||||
.upsert(true)
|
.upsert(true)
|
||||||
.return_document(ReturnDocument::After)
|
.return_document(ReturnDocument::After)
|
||||||
@@ -51,15 +53,12 @@ impl AbstractChannelUnreads for MongoDb {
|
|||||||
let current_time = Ulid::new().to_string();
|
let current_time = Ulid::new().to_string();
|
||||||
|
|
||||||
self.col::<Document>(COL)
|
self.col::<Document>(COL)
|
||||||
.delete_many(
|
.delete_many(doc! {
|
||||||
doc! {
|
"_id.channel": {
|
||||||
"_id.channel": {
|
"$in": channel_ids
|
||||||
"$in": channel_ids
|
|
||||||
},
|
|
||||||
"_id.user": user_id
|
|
||||||
},
|
},
|
||||||
None,
|
"_id.user": user_id
|
||||||
)
|
})
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("delete_many", COL))?;
|
.map_err(|_| create_database_error!("delete_many", COL))?;
|
||||||
|
|
||||||
@@ -77,7 +76,6 @@ impl AbstractChannelUnreads for MongoDb {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<Document>>(),
|
.collect::<Vec<Document>>(),
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -104,13 +102,42 @@ impl AbstractChannelUnreads for MongoDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpdateOptions::builder().upsert(true).build(),
|
|
||||||
)
|
)
|
||||||
|
.with_options(UpdateOptions::builder().upsert(true).build())
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| create_database_error!("update_one", COL))
|
.map_err(|_| create_database_error!("update_one", COL))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a mention to multiple users.
|
||||||
|
async fn add_mention_to_many_unreads<'a>(
|
||||||
|
&self,
|
||||||
|
channel_id: &str,
|
||||||
|
user_ids: &[String],
|
||||||
|
message_ids: &[String],
|
||||||
|
) -> Result<()> {
|
||||||
|
self.col::<Document>(COL)
|
||||||
|
.update_many(
|
||||||
|
doc! {
|
||||||
|
"_id.channel": channel_id,
|
||||||
|
"_id.user": {
|
||||||
|
"$in": user_ids
|
||||||
|
},
|
||||||
|
},
|
||||||
|
doc! {
|
||||||
|
"$push": {
|
||||||
|
"mentions": {
|
||||||
|
"$each": message_ids
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.with_options(UpdateOptions::builder().upsert(true).build())
|
||||||
|
.await
|
||||||
|
.map(|_| ())
|
||||||
|
.map_err(|_| create_database_error!("update_many", COL))
|
||||||
|
}
|
||||||
|
|
||||||
/// Fetch all channel unreads for a user.
|
/// Fetch all channel unreads for a user.
|
||||||
async fn fetch_unreads(&self, user_id: &str) -> Result<Vec<ChannelUnread>> {
|
async fn fetch_unreads(&self, user_id: &str) -> Result<Vec<ChannelUnread>> {
|
||||||
query!(
|
query!(
|
||||||
@@ -123,6 +150,18 @@ impl AbstractChannelUnreads for MongoDb {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn fetch_unread_mentions(&self, user_id: &str) -> Result<Vec<ChannelUnread>> {
|
||||||
|
query! {
|
||||||
|
self,
|
||||||
|
find,
|
||||||
|
COL,
|
||||||
|
doc! {
|
||||||
|
"_id.user": user_id,
|
||||||
|
"mentions": {"$ne": null}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Fetch unread for a specific user in a channel.
|
/// Fetch unread for a specific user in a channel.
|
||||||
async fn fetch_unread(&self, user_id: &str, channel_id: &str) -> Result<Option<ChannelUnread>> {
|
async fn fetch_unread(&self, user_id: &str, channel_id: &str) -> Result<Option<ChannelUnread>> {
|
||||||
query!(
|
query!(
|
||||||
@@ -135,5 +174,4 @@ impl AbstractChannelUnreads for MongoDb {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,47 @@ impl AbstractChannelUnreads for ReferenceDb {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a mention to multiple users.
|
||||||
|
async fn add_mention_to_many_unreads<'a>(
|
||||||
|
&self,
|
||||||
|
channel_id: &str,
|
||||||
|
user_ids: &[String],
|
||||||
|
message_ids: &[String],
|
||||||
|
) -> Result<()> {
|
||||||
|
let mut unreads = self.channel_unreads.lock().await;
|
||||||
|
|
||||||
|
for user_id in user_ids {
|
||||||
|
let key = ChannelCompositeKey {
|
||||||
|
channel: channel_id.to_string(),
|
||||||
|
user: user_id.to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(unread) = unreads.get_mut(&key) {
|
||||||
|
unread.mentions.replace(message_ids.to_vec());
|
||||||
|
} else {
|
||||||
|
unreads.insert(
|
||||||
|
key.clone(),
|
||||||
|
ChannelUnread {
|
||||||
|
id: key,
|
||||||
|
last_id: None,
|
||||||
|
mentions: Some(message_ids.to_vec()),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_unread_mentions(&self, user_id: &str) -> Result<Vec<ChannelUnread>> {
|
||||||
|
let unreads = self.channel_unreads.lock().await;
|
||||||
|
Ok(unreads
|
||||||
|
.values()
|
||||||
|
.filter(|unread| unread.id.user == user_id && unread.mentions.is_some())
|
||||||
|
.cloned()
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
/// Fetch all channel unreads for a user.
|
/// Fetch all channel unreads for a user.
|
||||||
async fn fetch_unreads(&self, user_id: &str) -> Result<Vec<ChannelUnread>> {
|
async fn fetch_unreads(&self, user_id: &str) -> Result<Vec<ChannelUnread>> {
|
||||||
let unreads = self.channel_unreads.lock().await;
|
let unreads = self.channel_unreads.lock().await;
|
||||||
@@ -92,9 +133,11 @@ impl AbstractChannelUnreads for ReferenceDb {
|
|||||||
async fn fetch_unread(&self, user_id: &str, channel_id: &str) -> Result<Option<ChannelUnread>> {
|
async fn fetch_unread(&self, user_id: &str, channel_id: &str) -> Result<Option<ChannelUnread>> {
|
||||||
let unreads = self.channel_unreads.lock().await;
|
let unreads = self.channel_unreads.lock().await;
|
||||||
|
|
||||||
Ok(unreads.get(&ChannelCompositeKey {
|
Ok(unreads
|
||||||
channel: channel_id.to_string(),
|
.get(&ChannelCompositeKey {
|
||||||
user: user_id.to_string()
|
channel: channel_id.to_string(),
|
||||||
}).cloned())
|
user: user_id.to_string(),
|
||||||
|
})
|
||||||
|
.cloned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,9 @@ impl AbstractWebhooks for MongoDb {
|
|||||||
async fn fetch_webhooks_for_channel(&self, channel_id: &str) -> Result<Vec<Webhook>> {
|
async fn fetch_webhooks_for_channel(&self, channel_id: &str) -> Result<Vec<Webhook>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<Webhook>(COL)
|
.col::<Webhook>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"channel_id": channel_id,
|
||||||
"channel_id": channel_id,
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", COL))?
|
.map_err(|_| create_database_error!("find", COL))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use ulid::Ulid;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::client::EventV1, tasks::ack::AckEvent, Database, File, IntoDocumentPath, PartialServer,
|
events::client::EventV1, tasks::ack::AckEvent, Database, File, IntoDocumentPath, PartialServer,
|
||||||
Server, SystemMessage, User,
|
Server, SystemMessage, User, AMQP,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto_derived!(
|
auto_derived!(
|
||||||
@@ -269,16 +269,24 @@ impl Channel {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let id = ulid::Ulid::new().to_string();
|
||||||
|
|
||||||
|
let icon = if let Some(icon_id) = data.icon {
|
||||||
|
Some(File::use_channel_icon(db, &icon_id, &id, &owner_id).await?)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let recipients = data.users.into_iter().collect::<Vec<String>>();
|
let recipients = data.users.into_iter().collect::<Vec<String>>();
|
||||||
let channel = Channel::Group {
|
let channel = Channel::Group {
|
||||||
id: ulid::Ulid::new().to_string(),
|
id,
|
||||||
|
|
||||||
name: data.name,
|
name: data.name,
|
||||||
owner: owner_id,
|
owner: owner_id,
|
||||||
description: data.description,
|
description: data.description,
|
||||||
recipients: recipients.clone(),
|
recipients: recipients.clone(),
|
||||||
|
|
||||||
icon: None,
|
icon,
|
||||||
last_message_id: None,
|
last_message_id: None,
|
||||||
|
|
||||||
permissions: None,
|
permissions: None,
|
||||||
@@ -337,6 +345,7 @@ impl Channel {
|
|||||||
pub async fn add_user_to_group(
|
pub async fn add_user_to_group(
|
||||||
&mut self,
|
&mut self,
|
||||||
db: &Database,
|
db: &Database,
|
||||||
|
amqp: &AMQP,
|
||||||
user: &User,
|
user: &User,
|
||||||
by_id: &str,
|
by_id: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@@ -373,6 +382,7 @@ impl Channel {
|
|||||||
.into_message(id.to_string())
|
.into_message(id.to_string())
|
||||||
.send(
|
.send(
|
||||||
db,
|
db,
|
||||||
|
Some(amqp),
|
||||||
MessageAuthor::System {
|
MessageAuthor::System {
|
||||||
username: &user.username,
|
username: &user.username,
|
||||||
avatar: user.avatar.as_ref().map(|file| file.id.as_ref()),
|
avatar: user.avatar.as_ref().map(|file| file.id.as_ref()),
|
||||||
@@ -639,7 +649,7 @@ impl Channel {
|
|||||||
.private(user.to_string())
|
.private(user.to_string())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
crate::tasks::ack::queue(
|
crate::tasks::ack::queue_ack(
|
||||||
self.id().to_string(),
|
self.id().to_string(),
|
||||||
user.to_string(),
|
user.to_string(),
|
||||||
AckEvent::AckMessage {
|
AckEvent::AckMessage {
|
||||||
@@ -655,6 +665,7 @@ impl Channel {
|
|||||||
pub async fn remove_user_from_group(
|
pub async fn remove_user_from_group(
|
||||||
&self,
|
&self,
|
||||||
db: &Database,
|
db: &Database,
|
||||||
|
amqp: &AMQP,
|
||||||
user: &User,
|
user: &User,
|
||||||
by_id: Option<&str>,
|
by_id: Option<&str>,
|
||||||
silent: bool,
|
silent: bool,
|
||||||
@@ -686,6 +697,7 @@ impl Channel {
|
|||||||
.into_message(id.to_string())
|
.into_message(id.to_string())
|
||||||
.send(
|
.send(
|
||||||
db,
|
db,
|
||||||
|
Some(amqp),
|
||||||
MessageAuthor::System {
|
MessageAuthor::System {
|
||||||
username: name,
|
username: name,
|
||||||
avatar: None,
|
avatar: None,
|
||||||
@@ -725,6 +737,7 @@ impl Channel {
|
|||||||
.into_message(id.to_string())
|
.into_message(id.to_string())
|
||||||
.send(
|
.send(
|
||||||
db,
|
db,
|
||||||
|
Some(amqp),
|
||||||
MessageAuthor::System {
|
MessageAuthor::System {
|
||||||
username: &user.username,
|
username: &user.username,
|
||||||
avatar: user.avatar.as_ref().map(|file| file.id.as_ref()),
|
avatar: user.avatar.as_ref().map(|file| file.id.as_ref()),
|
||||||
|
|||||||
@@ -23,14 +23,11 @@ impl AbstractChannels for MongoDb {
|
|||||||
async fn fetch_channels<'a>(&self, ids: &'a [String]) -> Result<Vec<Channel>> {
|
async fn fetch_channels<'a>(&self, ids: &'a [String]) -> Result<Vec<Channel>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<Channel>(COL)
|
.col::<Channel>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"_id": {
|
||||||
"_id": {
|
"$in": ids
|
||||||
"$in": ids
|
}
|
||||||
}
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("fetch", "channels"))?
|
.map_err(|_| create_database_error!("fetch", "channels"))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
@@ -119,7 +116,6 @@ impl AbstractChannels for MongoDb {
|
|||||||
"recipients": user
|
"recipients": user
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -141,7 +137,6 @@ impl AbstractChannels for MongoDb {
|
|||||||
"role_permissions.".to_owned() + role: permissions
|
"role_permissions.".to_owned() + role: permissions
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -179,7 +174,6 @@ impl AbstractChannels for MongoDb {
|
|||||||
"recipients": user
|
"recipients": user
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -253,7 +247,6 @@ impl AbstractChannels for MongoDb {
|
|||||||
"_id": server.id
|
"_id": server.id
|
||||||
},
|
},
|
||||||
update,
|
update,
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("update_one", "servers"))?;
|
.map_err(|_| create_database_error!("update_one", "servers"))?;
|
||||||
@@ -274,23 +267,17 @@ impl MongoDb {
|
|||||||
pub async fn delete_associated_channel_objects(&self, id: Bson) -> Result<()> {
|
pub async fn delete_associated_channel_objects(&self, id: Bson) -> Result<()> {
|
||||||
// Delete all invites to these channels.
|
// Delete all invites to these channels.
|
||||||
self.col::<Document>("channel_invites")
|
self.col::<Document>("channel_invites")
|
||||||
.delete_many(
|
.delete_many(doc! {
|
||||||
doc! {
|
"channel": &id
|
||||||
"channel": &id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("delete_many", "channel_invites"))?;
|
.map_err(|_| create_database_error!("delete_many", "channel_invites"))?;
|
||||||
|
|
||||||
// Delete unread message objects on channels.
|
// Delete unread message objects on channels.
|
||||||
self.col::<Document>("channel_unreads")
|
self.col::<Document>("channel_unreads")
|
||||||
.delete_many(
|
.delete_many(doc! {
|
||||||
doc! {
|
"_id.channel": &id
|
||||||
"_id.channel": &id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("delete_many", "channel_unreads"))
|
.map_err(|_| create_database_error!("delete_many", "channel_unreads"))
|
||||||
.map(|_| ())?;
|
.map(|_| ())?;
|
||||||
@@ -299,12 +286,9 @@ impl MongoDb {
|
|||||||
|
|
||||||
// Delete all webhooks on this channel.
|
// Delete all webhooks on this channel.
|
||||||
self.col::<Document>("webhooks")
|
self.col::<Document>("webhooks")
|
||||||
.delete_many(
|
.delete_many(doc! {
|
||||||
doc! {
|
"channel": &id
|
||||||
"channel": &id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("delete_many", "webhooks"))
|
.map_err(|_| create_database_error!("delete_many", "webhooks"))
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ impl AbstractEmojis for MongoDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ auto_derived!(
|
|||||||
Image {
|
Image {
|
||||||
width: isize,
|
width: isize,
|
||||||
height: isize,
|
height: isize,
|
||||||
// animated: bool // TODO: https://docs.rs/image/latest/image/trait.AnimationDecoder.html
|
// animated: bool // TODO: https://docs.rs/image/latest/image/trait.AnimationDecoder.html for APNG support
|
||||||
},
|
},
|
||||||
/// File is a video with specific dimensions
|
/// File is a video with specific dimensions
|
||||||
Video { width: isize, height: isize },
|
Video { width: isize, height: isize },
|
||||||
|
|||||||
@@ -15,4 +15,7 @@ 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<()>;
|
||||||
|
|
||||||
|
/// Delete attachment hash by id.
|
||||||
|
async fn delete_attachment_hash(&self, id: &str) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,14 @@ impl AbstractAttachmentHashes for MongoDb {
|
|||||||
"iv": nonce
|
"iv": nonce
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| create_database_error!("update_one", COL))
|
.map_err(|_| create_database_error!("update_one", COL))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Delete attachment hash by id.
|
||||||
|
async fn delete_attachment_hash(&self, id: &str) -> Result<()> {
|
||||||
|
query!(self, delete_one_by_id, COL, id).map(|_| ())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ impl AbstractAttachmentHashes for ReferenceDb {
|
|||||||
let hashes = self.file_hashes.lock().await;
|
let hashes = self.file_hashes.lock().await;
|
||||||
hashes
|
hashes
|
||||||
.values()
|
.values()
|
||||||
|
.find(|&hash| hash.id == hash_value || hash.processed_hash == hash_value)
|
||||||
.cloned()
|
.cloned()
|
||||||
.find(|hash| hash.id == hash_value || hash.processed_hash == hash_value)
|
|
||||||
.ok_or(create_error!(NotFound))
|
.ok_or(create_error!(NotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,4 +38,14 @@ impl AbstractAttachmentHashes for ReferenceDb {
|
|||||||
Err(create_error!(NotFound))
|
Err(create_error!(NotFound))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Delete attachment hash by id.
|
||||||
|
async fn delete_attachment_hash(&self, id: &str) -> Result<()> {
|
||||||
|
let mut file_hashes = self.file_hashes.lock().await;
|
||||||
|
if file_hashes.remove(id).is_some() {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(create_error!(NotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,15 @@ pub trait AbstractAttachments: Sync + Send {
|
|||||||
/// Fetch an attachment by its id.
|
/// Fetch an attachment by its id.
|
||||||
async fn fetch_attachment(&self, tag: &str, file_id: &str) -> Result<File>;
|
async fn fetch_attachment(&self, tag: &str, file_id: &str) -> Result<File>;
|
||||||
|
|
||||||
|
/// Fetch all deleted attachments.
|
||||||
|
async fn fetch_deleted_attachments(&self) -> Result<Vec<File>>;
|
||||||
|
|
||||||
|
/// Fetch all dangling attachments.
|
||||||
|
async fn fetch_dangling_files(&self) -> Result<Vec<File>>;
|
||||||
|
|
||||||
|
/// Count references to a given hash.
|
||||||
|
async fn count_file_hash_references(&self, hash: &str) -> Result<usize>;
|
||||||
|
|
||||||
/// Find an attachment by its details and mark it as used by a given parent.
|
/// Find an attachment by its details and mark it as used by a given parent.
|
||||||
async fn find_and_use_attachment(
|
async fn find_and_use_attachment(
|
||||||
&self,
|
&self,
|
||||||
@@ -32,4 +41,7 @@ pub trait AbstractAttachments: Sync + Send {
|
|||||||
|
|
||||||
/// Mark multiple attachments as having been deleted.
|
/// Mark multiple attachments as having been deleted.
|
||||||
async fn mark_attachments_as_deleted(&self, ids: &[String]) -> Result<()>;
|
async fn mark_attachments_as_deleted(&self, ids: &[String]) -> Result<()>;
|
||||||
|
|
||||||
|
/// Delete the attachment entry.
|
||||||
|
async fn delete_attachment(&self, id: &str) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,51 @@ impl AbstractAttachments for MongoDb {
|
|||||||
.ok_or_else(|| create_error!(NotFound))
|
.ok_or_else(|| create_error!(NotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch all deleted attachments.
|
||||||
|
async fn fetch_deleted_attachments(&self) -> Result<Vec<File>> {
|
||||||
|
query!(
|
||||||
|
self,
|
||||||
|
find,
|
||||||
|
COL,
|
||||||
|
doc! {
|
||||||
|
"deleted": true,
|
||||||
|
"reported": {
|
||||||
|
"$ne": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetch all dangling attachments.
|
||||||
|
async fn fetch_dangling_files(&self) -> Result<Vec<File>> {
|
||||||
|
query!(
|
||||||
|
self,
|
||||||
|
find,
|
||||||
|
COL,
|
||||||
|
doc! {
|
||||||
|
"used_for.type": {
|
||||||
|
"$exists": 0
|
||||||
|
},
|
||||||
|
"deleted": {
|
||||||
|
"$ne": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Count references to a given hash.
|
||||||
|
async fn count_file_hash_references(&self, hash: &str) -> Result<usize> {
|
||||||
|
query!(
|
||||||
|
self,
|
||||||
|
count_documents,
|
||||||
|
COL,
|
||||||
|
doc! {
|
||||||
|
"hash": hash
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.map(|count| count as usize)
|
||||||
|
}
|
||||||
|
|
||||||
/// Find an attachment by its details and mark it as used by a given parent.
|
/// Find an attachment by its details and mark it as used by a given parent.
|
||||||
async fn find_and_use_attachment(
|
async fn find_and_use_attachment(
|
||||||
&self,
|
&self,
|
||||||
@@ -65,7 +110,6 @@ impl AbstractAttachments for MongoDb {
|
|||||||
"uploader_id": uploader_id
|
"uploader_id": uploader_id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("update_one", COL))?;
|
.map_err(|_| create_database_error!("update_one", COL))?;
|
||||||
@@ -85,7 +129,6 @@ impl AbstractAttachments for MongoDb {
|
|||||||
"reported": true
|
"reported": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -104,7 +147,6 @@ impl AbstractAttachments for MongoDb {
|
|||||||
"deleted": true
|
"deleted": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -114,7 +156,7 @@ impl AbstractAttachments for MongoDb {
|
|||||||
/// Mark multiple attachments as having been deleted.
|
/// Mark multiple attachments as having been deleted.
|
||||||
async fn mark_attachments_as_deleted(&self, ids: &[String]) -> Result<()> {
|
async fn mark_attachments_as_deleted(&self, ids: &[String]) -> Result<()> {
|
||||||
self.col::<Document>(COL)
|
self.col::<Document>(COL)
|
||||||
.update_one(
|
.update_many(
|
||||||
doc! {
|
doc! {
|
||||||
"_id": {
|
"_id": {
|
||||||
"$in": ids
|
"$in": ids
|
||||||
@@ -125,11 +167,15 @@ impl AbstractAttachments for MongoDb {
|
|||||||
"deleted": true
|
"deleted": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| create_database_error!("update_one", COL))
|
.map_err(|_| create_database_error!("update_many", COL))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Delete the attachment entry.
|
||||||
|
async fn delete_attachment(&self, id: &str) -> Result<()> {
|
||||||
|
query!(self, delete_one_by_id, COL, id).map(|_| ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +189,6 @@ impl MongoDb {
|
|||||||
"deleted": true
|
"deleted": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
|
|||||||
@@ -33,6 +33,41 @@ impl AbstractAttachments for ReferenceDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch all deleted attachments.
|
||||||
|
async fn fetch_deleted_attachments(&self) -> Result<Vec<File>> {
|
||||||
|
let files = self.files.lock().await;
|
||||||
|
Ok(files
|
||||||
|
.values()
|
||||||
|
.filter(|file| {
|
||||||
|
// file has been marked as deleted
|
||||||
|
file.deleted.is_some_and(|v| v)
|
||||||
|
// and it has not been reported
|
||||||
|
&& !file.reported.is_some_and(|v| v)
|
||||||
|
})
|
||||||
|
.cloned()
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetch all dangling attachments.
|
||||||
|
async fn fetch_dangling_files(&self) -> Result<Vec<File>> {
|
||||||
|
let files = self.files.lock().await;
|
||||||
|
Ok(files
|
||||||
|
.values()
|
||||||
|
.filter(|file| file.used_for.is_none() && !file.deleted.is_some_and(|v| v))
|
||||||
|
.cloned()
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Count references to a given hash.
|
||||||
|
async fn count_file_hash_references(&self, hash: &str) -> Result<usize> {
|
||||||
|
let files = self.files.lock().await;
|
||||||
|
Ok(files
|
||||||
|
.values()
|
||||||
|
.filter(|file| file.hash.as_ref().is_some_and(|h| h == hash))
|
||||||
|
.cloned()
|
||||||
|
.count())
|
||||||
|
}
|
||||||
|
|
||||||
/// Find an attachment by its details and mark it as used by a given parent.
|
/// Find an attachment by its details and mark it as used by a given parent.
|
||||||
async fn find_and_use_attachment(
|
async fn find_and_use_attachment(
|
||||||
&self,
|
&self,
|
||||||
@@ -96,4 +131,14 @@ impl AbstractAttachments for ReferenceDb {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Delete the attachment entry.
|
||||||
|
async fn delete_attachment(&self, id: &str) -> Result<()> {
|
||||||
|
let mut files = self.files.lock().await;
|
||||||
|
if files.remove(id).is_some() {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(create_error!(NotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
use std::collections::HashSet;
|
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};
|
||||||
use revolt_models::v0::{
|
use revolt_models::v0::{
|
||||||
self, BulkMessageResponse, DataMessageSend, Embed, MessageAuthor, MessageFlags, MessageSort,
|
self, BulkMessageResponse, DataMessageSend, Embed, MessageAuthor, MessageFlags, MessageSort,
|
||||||
MessageWebhook, PushNotification, ReplyIntent, SendableEmbed, Text, RE_MENTION,
|
MessageWebhook, PushNotification, ReplyIntent, SendableEmbed, Text
|
||||||
};
|
};
|
||||||
use revolt_permissions::{ChannelPermission, PermissionValue};
|
use revolt_permissions::{calculate_channel_permissions, ChannelPermission, PermissionValue};
|
||||||
use revolt_result::Result;
|
use revolt_result::{ErrorType, Result};
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::client::EventV1,
|
events::client::EventV1,
|
||||||
tasks::{self, ack::AckEvent},
|
tasks::{self, ack::AckEvent},
|
||||||
util::idempotency::IdempotencyKey,
|
util::{
|
||||||
Channel, Database, Emoji, File, User,
|
bulk_permissions::BulkDatabasePermissionQuery, idempotency::IdempotencyKey,
|
||||||
|
permissions::DatabasePermissionQuery,
|
||||||
|
},
|
||||||
|
Channel, Database, Emoji, File, User, AMQP,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto_derived_partial!(
|
auto_derived_partial!(
|
||||||
@@ -53,6 +56,9 @@ auto_derived_partial!(
|
|||||||
/// Array of user ids mentioned in this message
|
/// Array of user ids mentioned in this message
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub mentions: Option<Vec<String>>,
|
pub mentions: Option<Vec<String>>,
|
||||||
|
/// Array of role ids mentioned in this message
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub role_mentions: Option<Vec<String>>,
|
||||||
/// Array of message ids this message is replying to
|
/// Array of message ids this message is replying to
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub replies: Option<Vec<String>>,
|
pub replies: Option<Vec<String>>,
|
||||||
@@ -71,7 +77,7 @@ auto_derived_partial!(
|
|||||||
|
|
||||||
/// Bitfield of message flags
|
/// Bitfield of message flags
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub flags: Option<i32>,
|
pub flags: Option<u32>,
|
||||||
},
|
},
|
||||||
"PartialMessage"
|
"PartialMessage"
|
||||||
);
|
);
|
||||||
@@ -199,6 +205,30 @@ auto_derived!(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
pub struct MessageFlagsValue(pub u32);
|
||||||
|
|
||||||
|
impl MessageFlagsValue {
|
||||||
|
pub fn has(&self, flag: MessageFlags) -> bool {
|
||||||
|
self.has_value(flag as u32)
|
||||||
|
}
|
||||||
|
pub fn has_value(&self, bit: u32) -> bool {
|
||||||
|
let mask = 1 << bit;
|
||||||
|
self.0 & mask == mask
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set(&mut self, flag: MessageFlags, toggle: bool) -> &mut Self {
|
||||||
|
self.set_value(flag as u32, toggle)
|
||||||
|
}
|
||||||
|
pub fn set_value(&mut self, bit: u32, toggle: bool) -> &mut Self {
|
||||||
|
if toggle {
|
||||||
|
self.0 |= 1 << bit;
|
||||||
|
} else {
|
||||||
|
self.0 &= !(1 << bit);
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::derivable_impls)]
|
#[allow(clippy::derivable_impls)]
|
||||||
impl Default for Message {
|
impl Default for Message {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -214,6 +244,7 @@ impl Default for Message {
|
|||||||
edited: None,
|
edited: None,
|
||||||
embeds: None,
|
embeds: None,
|
||||||
mentions: None,
|
mentions: None,
|
||||||
|
role_mentions: None,
|
||||||
replies: None,
|
replies: None,
|
||||||
reactions: Default::default(),
|
reactions: Default::default(),
|
||||||
interactions: Default::default(),
|
interactions: Default::default(),
|
||||||
@@ -230,6 +261,7 @@ impl Message {
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn create_from_api(
|
pub async fn create_from_api(
|
||||||
db: &Database,
|
db: &Database,
|
||||||
|
amqp: Option<&AMQP>,
|
||||||
channel: Channel,
|
channel: Channel,
|
||||||
data: DataMessageSend,
|
data: DataMessageSend,
|
||||||
author: MessageAuthor<'_>,
|
author: MessageAuthor<'_>,
|
||||||
@@ -261,13 +293,43 @@ impl Message {
|
|||||||
return Err(create_error!(EmptyMessage));
|
return Err(create_error!(EmptyMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure flags are either not set or have permissible values
|
let allow_mass_mentions = allow_mentions && config.features.mass_mentions_enabled;
|
||||||
if let Some(flags) = &data.flags {
|
|
||||||
if flags != &0 && flags != &1 {
|
let mut mentions_everyone = false;
|
||||||
|
let mut mentions_online = false;
|
||||||
|
let mut suppress_notifications = false;
|
||||||
|
|
||||||
|
if let Some(raw_flags) = &data.flags {
|
||||||
|
if raw_flags > &7 {
|
||||||
|
// quick path to failure: bigger than all the bits combined
|
||||||
return Err(create_error!(InvalidProperty));
|
return Err(create_error!(InvalidProperty));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First step of mass mention resolution
|
||||||
|
let flags = MessageFlagsValue(*raw_flags);
|
||||||
|
suppress_notifications = flags.has(MessageFlags::SuppressNotifications);
|
||||||
|
mentions_everyone = allow_mentions && flags.has(MessageFlags::MentionsEveryone);
|
||||||
|
mentions_online = allow_mentions && flags.has(MessageFlags::MentionsOnline);
|
||||||
|
|
||||||
|
// Not a bot, and attempting to set mention flags
|
||||||
|
if user.as_ref().is_some_and(|u| u.bot.as_ref().is_none())
|
||||||
|
&& (mentions_everyone || mentions_online)
|
||||||
|
{
|
||||||
|
return Err(create_error!(IsNotBot));
|
||||||
|
}
|
||||||
|
|
||||||
|
if mentions_everyone && mentions_online {
|
||||||
|
return Err(create_error!(InvalidFlagValue));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let server_id = match channel {
|
||||||
|
Channel::TextChannel { ref server, .. } | Channel::VoiceChannel { ref server, .. } => {
|
||||||
|
Some(server.clone())
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
// Ensure restrict_reactions is not specified without reactions list
|
// Ensure restrict_reactions is not specified without reactions list
|
||||||
if let Some(interactions) = &data.interactions {
|
if let Some(interactions) = &data.interactions {
|
||||||
if interactions.restrict_reactions {
|
if interactions.restrict_reactions {
|
||||||
@@ -301,18 +363,76 @@ impl Message {
|
|||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
author: author_id,
|
author: author_id,
|
||||||
webhook: webhook.map(|w| w.into()),
|
webhook: webhook.map(|w| w.into()),
|
||||||
flags: data.flags.map(|v| v as i32),
|
flags: data.flags,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Parse mentions in message.
|
// Parse mentions in message.
|
||||||
let mut mentions = HashSet::new();
|
|
||||||
if allow_mentions {
|
let mut message_mentions = if let Some(raw_content) = &data.content {
|
||||||
if let Some(content) = &data.content {
|
revolt_parser::parse_message(raw_content)
|
||||||
for capture in RE_MENTION.captures_iter(content) {
|
} else {
|
||||||
if let Some(mention) = capture.get(1) {
|
revolt_parser::MessageResults::default()
|
||||||
mentions.insert(mention.as_str().to_string());
|
};
|
||||||
}
|
|
||||||
|
message_mentions.mentions_everyone |= mentions_everyone;
|
||||||
|
message_mentions.mentions_online |= mentions_online;
|
||||||
|
|
||||||
|
let revolt_parser::MessageResults {
|
||||||
|
mut user_mentions,
|
||||||
|
mut role_mentions,
|
||||||
|
mut mentions_everyone,
|
||||||
|
mut mentions_online
|
||||||
|
} = message_mentions;
|
||||||
|
|
||||||
|
if allow_mass_mentions && server_id.is_some() && !role_mentions.is_empty() {
|
||||||
|
let server_data = db
|
||||||
|
.fetch_server(server_id.unwrap().as_str())
|
||||||
|
.await
|
||||||
|
.expect("Failed to fetch server");
|
||||||
|
|
||||||
|
role_mentions.retain(|role_id| server_data.roles.contains_key(role_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the user can perform a mass mention
|
||||||
|
if !config.features.mass_mentions_enabled
|
||||||
|
&& (mentions_everyone || mentions_online || !role_mentions.is_empty())
|
||||||
|
{
|
||||||
|
mentions_everyone = false;
|
||||||
|
mentions_online = false;
|
||||||
|
role_mentions.clear();
|
||||||
|
} else if mentions_everyone || mentions_online || !role_mentions.is_empty() {
|
||||||
|
debug!(
|
||||||
|
"Mentioned everyone: {}, mentioned online: {}, mentioned roles: {:?}",
|
||||||
|
mentions_everyone, mentions_online, &role_mentions
|
||||||
|
);
|
||||||
|
if let Some(user) = match author {
|
||||||
|
MessageAuthor::User(user) => Some(Ok(user)),
|
||||||
|
MessageAuthor::System { .. } => Some(Err(())), // DISALLOWED
|
||||||
|
MessageAuthor::Webhook(..) => None, // Bypass check
|
||||||
|
} {
|
||||||
|
if user.is_err() {
|
||||||
|
return Err(create_error!(InvalidProperty));
|
||||||
|
}
|
||||||
|
let owned_user: User = user.unwrap().to_owned().into();
|
||||||
|
|
||||||
|
let mut query = DatabasePermissionQuery::new(db, &owned_user).channel(&channel);
|
||||||
|
let perms = calculate_channel_permissions(&mut query).await;
|
||||||
|
|
||||||
|
if (mentions_everyone || mentions_online)
|
||||||
|
&& !perms.has_channel_permission(ChannelPermission::MentionEveryone)
|
||||||
|
{
|
||||||
|
return Err(create_error!(MissingPermission {
|
||||||
|
permission: ChannelPermission::MentionEveryone.to_string()
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if !role_mentions.is_empty()
|
||||||
|
&& !perms.has_channel_permission(ChannelPermission::MentionRoles)
|
||||||
|
{
|
||||||
|
return Err(create_error!(MissingPermission {
|
||||||
|
permission: ChannelPermission::MentionRoles.to_string()
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,19 +446,84 @@ impl Message {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
for ReplyIntent { id, mention } in entries {
|
for ReplyIntent {
|
||||||
let message = db.fetch_message(&id).await?;
|
id,
|
||||||
|
mention,
|
||||||
|
fail_if_not_exists,
|
||||||
|
} in entries
|
||||||
|
{
|
||||||
|
match db.fetch_message(&id).await {
|
||||||
|
// Referenced message exists
|
||||||
|
Ok(message) => {
|
||||||
|
if mention && allow_mentions {
|
||||||
|
user_mentions.insert(message.author.to_owned());
|
||||||
|
}
|
||||||
|
|
||||||
if mention && allow_mentions {
|
replies.insert(message.id);
|
||||||
mentions.insert(message.author.to_owned());
|
}
|
||||||
|
// If the referenced message doesn't exist and fail_if_not_exists
|
||||||
|
// is set to false, send the message without the reply.
|
||||||
|
Err(e) => {
|
||||||
|
if !matches!(e.error_type, ErrorType::NotFound)
|
||||||
|
|| fail_if_not_exists.unwrap_or(true)
|
||||||
|
{
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
replies.insert(message.id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !mentions.is_empty() {
|
// Validate the mentions go to users in the channel/server
|
||||||
message.mentions.replace(mentions.into_iter().collect());
|
if !user_mentions.is_empty() {
|
||||||
|
match channel {
|
||||||
|
Channel::DirectMessage { ref recipients, .. }
|
||||||
|
| Channel::Group { ref recipients, .. } => {
|
||||||
|
let recipients_hash = HashSet::<&String, RandomState>::from_iter(recipients);
|
||||||
|
user_mentions.retain(|m| recipients_hash.contains(m));
|
||||||
|
role_mentions.clear();
|
||||||
|
}
|
||||||
|
Channel::TextChannel { ref server, .. }
|
||||||
|
| Channel::VoiceChannel { ref server, .. } => {
|
||||||
|
let mentions_vec = Vec::from_iter(user_mentions.iter().cloned());
|
||||||
|
|
||||||
|
let valid_members = db.fetch_members(server.as_str(), &mentions_vec[..]).await;
|
||||||
|
if let Ok(valid_members) = valid_members {
|
||||||
|
let valid_mentions = HashSet::<&String, RandomState>::from_iter(valid_members.iter().map(|m| &m.id.user));
|
||||||
|
|
||||||
|
user_mentions.retain(|m| valid_mentions.contains(m)); // quick pass, validate mentions are in the server
|
||||||
|
|
||||||
|
if !user_mentions.is_empty() {
|
||||||
|
// if there are still mentions, drill down to a channel-level
|
||||||
|
let member_channel_view_perms =
|
||||||
|
BulkDatabasePermissionQuery::from_server_id(db, server)
|
||||||
|
.await
|
||||||
|
.channel(&channel)
|
||||||
|
.members(&valid_members)
|
||||||
|
.members_can_see_channel()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
user_mentions.retain(|m| *member_channel_view_perms.get(m).unwrap_or(&false));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
revolt_config::capture_error(&valid_members.unwrap_err());
|
||||||
|
return Err(create_error!(InternalError));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Channel::SavedMessages { .. } => {
|
||||||
|
user_mentions.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !user_mentions.is_empty() {
|
||||||
|
message.mentions.replace(user_mentions.into_iter().collect());
|
||||||
|
}
|
||||||
|
|
||||||
|
if !role_mentions.is_empty() {
|
||||||
|
message
|
||||||
|
.role_mentions
|
||||||
|
.replace(role_mentions.into_iter().collect());
|
||||||
}
|
}
|
||||||
|
|
||||||
if !replies.is_empty() {
|
if !replies.is_empty() {
|
||||||
@@ -347,6 +532,15 @@ impl Message {
|
|||||||
.replace(replies.into_iter().collect::<Vec<String>>());
|
.replace(replies.into_iter().collect::<Vec<String>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate final message flags
|
||||||
|
let mut flag_value = MessageFlagsValue(0);
|
||||||
|
flag_value
|
||||||
|
.set(MessageFlags::SuppressNotifications, suppress_notifications)
|
||||||
|
.set(MessageFlags::MentionsEveryone, mentions_everyone)
|
||||||
|
.set(MessageFlags::MentionsOnline, mentions_online);
|
||||||
|
|
||||||
|
message.flags = Some(flag_value.0);
|
||||||
|
|
||||||
// Add attachments to message.
|
// Add attachments to message.
|
||||||
let mut attachments = vec![];
|
let mut attachments = vec![];
|
||||||
if data
|
if data
|
||||||
@@ -391,7 +585,7 @@ impl Message {
|
|||||||
|
|
||||||
// Send the message
|
// Send the message
|
||||||
message
|
message
|
||||||
.send(db, author, user, member, &channel, generate_embeds)
|
.send(db, amqp, author, user, member, &channel, generate_embeds)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(message)
|
Ok(message)
|
||||||
@@ -405,6 +599,9 @@ impl Message {
|
|||||||
member: Option<v0::Member>,
|
member: Option<v0::Member>,
|
||||||
is_dm: bool,
|
is_dm: bool,
|
||||||
generate_embeds: bool,
|
generate_embeds: bool,
|
||||||
|
// This determines if this function should queue the mentions task or if somewhere else will.
|
||||||
|
// If this is true, you MUST call tasks::ack::queue yourself.
|
||||||
|
mentions_elsewhere: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
db.insert_message(self).await?;
|
db.insert_message(self).await?;
|
||||||
|
|
||||||
@@ -417,13 +614,17 @@ impl Message {
|
|||||||
tasks::last_message_id::queue(self.channel.to_string(), self.id.to_string(), is_dm).await;
|
tasks::last_message_id::queue(self.channel.to_string(), self.id.to_string(), is_dm).await;
|
||||||
|
|
||||||
// Add mentions for affected users
|
// Add mentions for affected users
|
||||||
if let Some(mentions) = &self.mentions {
|
if !mentions_elsewhere {
|
||||||
for user in mentions {
|
if let Some(mentions) = &self.mentions {
|
||||||
tasks::ack::queue(
|
tasks::ack::queue_message(
|
||||||
self.channel.to_string(),
|
self.channel.to_string(),
|
||||||
user.to_string(),
|
AckEvent::ProcessMessage {
|
||||||
AckEvent::AddMention {
|
messages: vec![(
|
||||||
ids: vec![self.id.to_string()],
|
None,
|
||||||
|
self.clone(),
|
||||||
|
mentions.clone(),
|
||||||
|
self.has_suppressed_notifications(),
|
||||||
|
)],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -446,9 +647,11 @@ impl Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send a message
|
/// Send a message
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn send(
|
pub async fn send(
|
||||||
&mut self,
|
&mut self,
|
||||||
db: &Database,
|
db: &Database,
|
||||||
|
amqp: Option<&AMQP>, // this is optional mostly for tests.
|
||||||
author: MessageAuthor<'_>,
|
author: MessageAuthor<'_>,
|
||||||
user: Option<v0::User>,
|
user: Option<v0::User>,
|
||||||
member: Option<v0::Member>,
|
member: Option<v0::Member>,
|
||||||
@@ -461,26 +664,38 @@ impl Message {
|
|||||||
member.clone(),
|
member.clone(),
|
||||||
matches!(channel, Channel::DirectMessage { .. }),
|
matches!(channel, Channel::DirectMessage { .. }),
|
||||||
generate_embeds,
|
generate_embeds,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if !self.has_suppressed_notifications() {
|
if !self.has_suppressed_notifications()
|
||||||
// Push out Web Push notifications
|
&& (self.mentions.is_some() || self.contains_mass_push_mention())
|
||||||
crate::tasks::web_push::queue(
|
{
|
||||||
{
|
// send Push notifications
|
||||||
match channel {
|
tasks::ack::queue_message(
|
||||||
Channel::DirectMessage { recipients, .. }
|
self.channel.to_string(),
|
||||||
| Channel::Group { recipients, .. } => recipients.clone(),
|
AckEvent::ProcessMessage {
|
||||||
Channel::TextChannel { .. } => self.mentions.clone().unwrap_or_default(),
|
messages: vec![(
|
||||||
_ => vec![],
|
Some(
|
||||||
}
|
PushNotification::from(
|
||||||
|
self.clone().into_model(user, member),
|
||||||
|
Some(author),
|
||||||
|
channel.to_owned().into(),
|
||||||
|
)
|
||||||
|
.await,
|
||||||
|
),
|
||||||
|
self.clone(),
|
||||||
|
match channel {
|
||||||
|
Channel::DirectMessage { recipients, .. }
|
||||||
|
| Channel::Group { recipients, .. } => recipients.clone(),
|
||||||
|
Channel::TextChannel { .. } => {
|
||||||
|
self.mentions.clone().unwrap_or_default()
|
||||||
|
}
|
||||||
|
_ => vec![],
|
||||||
|
},
|
||||||
|
false, // branch already dictates this
|
||||||
|
)],
|
||||||
},
|
},
|
||||||
PushNotification::from(
|
|
||||||
self.clone().into_model(user, member),
|
|
||||||
Some(author),
|
|
||||||
channel.id(),
|
|
||||||
)
|
|
||||||
.await,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@@ -515,13 +730,24 @@ impl Message {
|
|||||||
/// Whether this message has suppressed notifications
|
/// Whether this message has suppressed notifications
|
||||||
pub fn has_suppressed_notifications(&self) -> bool {
|
pub fn has_suppressed_notifications(&self) -> bool {
|
||||||
if let Some(flags) = self.flags {
|
if let Some(flags) = self.flags {
|
||||||
flags & MessageFlags::SuppressNotifications as i32
|
flags & MessageFlags::SuppressNotifications as u32
|
||||||
== MessageFlags::SuppressNotifications as i32
|
== MessageFlags::SuppressNotifications as u32
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn contains_mass_push_mention(&self) -> bool {
|
||||||
|
let ping = if let Some(flags) = self.flags {
|
||||||
|
let flags = MessageFlagsValue(flags);
|
||||||
|
flags.has(MessageFlags::MentionsEveryone)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
ping || self.role_mentions.is_some()
|
||||||
|
}
|
||||||
|
|
||||||
/// Update message data
|
/// Update message data
|
||||||
pub async fn update(
|
pub async fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ impl AbstractMessages for MongoDb {
|
|||||||
COL,
|
COL,
|
||||||
older_message_filter,
|
older_message_filter,
|
||||||
FindOptions::builder()
|
FindOptions::builder()
|
||||||
.limit(limit / 2)
|
.limit(limit / 2 + 1)
|
||||||
.sort(doc! {
|
.sort(doc! {
|
||||||
"_id": -1_i32
|
"_id": -1_i32
|
||||||
})
|
})
|
||||||
@@ -171,7 +171,7 @@ impl AbstractMessages for MongoDb {
|
|||||||
self.find_with_options(
|
self.find_with_options(
|
||||||
COL,
|
COL,
|
||||||
doc! {
|
doc! {
|
||||||
"ids": {
|
"_id": {
|
||||||
"$in": ids
|
"$in": ids
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -228,7 +228,6 @@ impl AbstractMessages for MongoDb {
|
|||||||
"_id": id
|
"_id": id
|
||||||
},
|
},
|
||||||
query,
|
query,
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -247,7 +246,6 @@ impl AbstractMessages for MongoDb {
|
|||||||
format!("reactions.{emoji}"): user
|
format!("reactions.{emoji}"): user
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -266,7 +264,6 @@ impl AbstractMessages for MongoDb {
|
|||||||
format!("reactions.{emoji}"): user
|
format!("reactions.{emoji}"): user
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -285,7 +282,6 @@ impl AbstractMessages for MongoDb {
|
|||||||
format!("reactions.{emoji}"): 1
|
format!("reactions.{emoji}"): 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -300,15 +296,12 @@ impl AbstractMessages for MongoDb {
|
|||||||
/// 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<()> {
|
||||||
self.col::<Document>(COL)
|
self.col::<Document>(COL)
|
||||||
.delete_many(
|
.delete_many(doc! {
|
||||||
doc! {
|
"channel": channel,
|
||||||
"channel": channel,
|
"_id": {
|
||||||
"_id": {
|
"$in": ids
|
||||||
"$in": ids
|
}
|
||||||
}
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| create_database_error!("delete_many", COL))
|
.map_err(|_| create_database_error!("delete_many", COL))
|
||||||
@@ -362,7 +355,6 @@ impl MongoDb {
|
|||||||
"deleted": true
|
"deleted": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("update_many", "attachments"))?;
|
.map_err(|_| create_database_error!("update_many", "attachments"))?;
|
||||||
@@ -370,7 +362,7 @@ impl MongoDb {
|
|||||||
|
|
||||||
// And then delete said messages.
|
// And then delete said messages.
|
||||||
self.col::<Document>(COL)
|
self.col::<Document>(COL)
|
||||||
.delete_many(projection, None)
|
.delete_many(projection)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| create_database_error!("delete_many", COL))
|
.map_err(|_| create_database_error!("delete_many", COL))
|
||||||
|
|||||||
@@ -23,16 +23,13 @@ impl AbstractRatelimitEvents for MongoDb {
|
|||||||
count: usize,
|
count: usize,
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
self.col::<RatelimitEvent>(COL)
|
self.col::<RatelimitEvent>(COL)
|
||||||
.count_documents(
|
.count_documents(doc! {
|
||||||
doc! {
|
"_id": {
|
||||||
"_id": {
|
"$gte": Ulid::from_datetime(SystemTime::now() - period).to_string()
|
||||||
"$gte": Ulid::from_datetime(SystemTime::now() - period).to_string()
|
|
||||||
},
|
|
||||||
"target_id": target_id,
|
|
||||||
"event_type": event_type.to_string()
|
|
||||||
},
|
},
|
||||||
None,
|
"target_id": target_id,
|
||||||
)
|
"event_type": event_type.to_string()
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.map(|c| c as usize >= count)
|
.map(|c| c as usize >= count)
|
||||||
.map_err(|_| create_database_error!("count_documents", COL))
|
.map_err(|_| create_database_error!("count_documents", COL))
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ impl Member {
|
|||||||
id: user.id.clone(),
|
id: user.id.clone(),
|
||||||
}
|
}
|
||||||
.into_message(id.to_string())
|
.into_message(id.to_string())
|
||||||
.send_without_notifications(db, None, None, false, false)
|
.send_without_notifications(db, None, None, false, false, false)
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ impl Member {
|
|||||||
}
|
}
|
||||||
.into_message(id.to_string())
|
.into_message(id.to_string())
|
||||||
// TODO: support notifications here in the future?
|
// TODO: support notifications here in the future?
|
||||||
.send_without_notifications(db, None, None, false, false)
|
.send_without_notifications(db, None, None, false, false, false)
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use ::mongodb::SessionCursor;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{FieldsMember, Member, MemberCompositeKey, PartialMember};
|
use crate::{FieldsMember, Member, MemberCompositeKey, PartialMember};
|
||||||
@@ -5,6 +6,66 @@ use crate::{FieldsMember, Member, MemberCompositeKey, PartialMember};
|
|||||||
mod mongodb;
|
mod mongodb;
|
||||||
mod reference;
|
mod reference;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ChunkedServerMembersGenerator {
|
||||||
|
#[cfg(feature = "mongodb")]
|
||||||
|
MongoDb {
|
||||||
|
session: ::mongodb::ClientSession,
|
||||||
|
cursor: Option<SessionCursor<Member>>,
|
||||||
|
},
|
||||||
|
|
||||||
|
Reference {
|
||||||
|
offset: i32,
|
||||||
|
data: Option<Vec<Member>>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChunkedServerMembersGenerator {
|
||||||
|
#[cfg(feature = "mongodb")]
|
||||||
|
pub fn new_mongo(session: ::mongodb::ClientSession, cursor: SessionCursor<Member>) -> Self {
|
||||||
|
ChunkedServerMembersGenerator::MongoDb {
|
||||||
|
session,
|
||||||
|
cursor: Some(cursor),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_reference(data: Vec<Member>) -> Self {
|
||||||
|
ChunkedServerMembersGenerator::Reference {
|
||||||
|
offset: 0,
|
||||||
|
data: Some(data),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn next(&mut self) -> Option<Member> {
|
||||||
|
match self {
|
||||||
|
#[cfg(feature = "mongodb")]
|
||||||
|
ChunkedServerMembersGenerator::MongoDb { session, cursor } => {
|
||||||
|
if let Some(cursor) = cursor {
|
||||||
|
let value = cursor.next(session).await;
|
||||||
|
value.map(|val| val.expect("Failed to fetch the next member"))
|
||||||
|
} else {
|
||||||
|
warn!("Attempted to access a (MongoDb) server member generator without first setting a cursor");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ChunkedServerMembersGenerator::Reference { offset, data } => {
|
||||||
|
if let Some(data) = data {
|
||||||
|
if data.len() as i32 >= *offset {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
let resp = &data[*offset as usize];
|
||||||
|
*offset += 1;
|
||||||
|
Some(resp.clone())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
warn!("Attempted to access a (Reference) server member generator without first providing data");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait AbstractServerMembers: Sync + Send {
|
pub trait AbstractServerMembers: Sync + Send {
|
||||||
/// Insert a new server member into the database
|
/// Insert a new server member into the database
|
||||||
@@ -16,6 +77,24 @@ pub trait AbstractServerMembers: Sync + Send {
|
|||||||
/// Fetch all members in a server
|
/// Fetch all members in a server
|
||||||
async fn fetch_all_members<'a>(&self, server_id: &str) -> Result<Vec<Member>>;
|
async fn fetch_all_members<'a>(&self, server_id: &str) -> Result<Vec<Member>>;
|
||||||
|
|
||||||
|
/// Fetch all members in a server as an iterator
|
||||||
|
async fn fetch_all_members_chunked(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
) -> Result<ChunkedServerMembersGenerator>;
|
||||||
|
|
||||||
|
async fn fetch_all_members_with_roles(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
roles: &[String],
|
||||||
|
) -> Result<Vec<Member>>;
|
||||||
|
|
||||||
|
async fn fetch_all_members_with_roles_chunked(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
roles: &[String],
|
||||||
|
) -> Result<ChunkedServerMembersGenerator>;
|
||||||
|
|
||||||
/// Fetch all memberships for a user
|
/// Fetch all memberships for a user
|
||||||
async fn fetch_all_memberships<'a>(&self, user_id: &str) -> Result<Vec<Member>>;
|
async fn fetch_all_memberships<'a>(&self, user_id: &str) -> Result<Vec<Member>>;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
use mongodb::options::ReadConcern;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{FieldsMember, Member, MemberCompositeKey, PartialMember};
|
use crate::{FieldsMember, Member, MemberCompositeKey, PartialMember};
|
||||||
use crate::{IntoDocumentPath, MongoDb};
|
use crate::{IntoDocumentPath, MongoDb};
|
||||||
|
|
||||||
use super::AbstractServerMembers;
|
use super::{AbstractServerMembers, ChunkedServerMembersGenerator};
|
||||||
|
|
||||||
static COL: &str = "server_members";
|
static COL: &str = "server_members";
|
||||||
|
|
||||||
@@ -33,12 +34,9 @@ impl AbstractServerMembers for MongoDb {
|
|||||||
async fn fetch_all_members<'a>(&self, server_id: &str) -> Result<Vec<Member>> {
|
async fn fetch_all_members<'a>(&self, server_id: &str) -> Result<Vec<Member>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<Member>(COL)
|
.col::<Member>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"_id.server": server_id
|
||||||
"_id.server": server_id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", COL))?
|
.map_err(|_| create_database_error!("find", COL))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
@@ -52,16 +50,101 @@ impl AbstractServerMembers for MongoDb {
|
|||||||
.await)
|
.await)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch all members in a server as a generator.
|
||||||
|
/// Uses config key pushd.mass_mention_chunk_size as the batch size.
|
||||||
|
async fn fetch_all_members_chunked(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
) -> Result<ChunkedServerMembersGenerator> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
|
let mut session = self
|
||||||
|
.start_session()
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_database_error!("start_session", COL))?;
|
||||||
|
|
||||||
|
session
|
||||||
|
.start_transaction()
|
||||||
|
.read_concern(ReadConcern::snapshot())
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_database_error!("start_transaction", COL))?;
|
||||||
|
|
||||||
|
let cursor = self
|
||||||
|
.col::<Member>(COL)
|
||||||
|
.find(doc! {
|
||||||
|
"_id.server": server_id
|
||||||
|
})
|
||||||
|
.session(&mut session)
|
||||||
|
.batch_size(config.pushd.mass_mention_chunk_size as u32)
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_database_error!("find", COL))?;
|
||||||
|
|
||||||
|
Ok(ChunkedServerMembersGenerator::new_mongo(session, cursor))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_all_members_with_roles(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
roles: &[String],
|
||||||
|
) -> Result<Vec<Member>> {
|
||||||
|
Ok(self
|
||||||
|
.col::<Member>(COL)
|
||||||
|
.find(doc! {
|
||||||
|
"_id.server": server_id,
|
||||||
|
"roles": {"$in": roles}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_database_error!("find", COL))?
|
||||||
|
.filter_map(|s| async {
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
Some(s.unwrap())
|
||||||
|
} else {
|
||||||
|
s.ok()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
.await)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_all_members_with_roles_chunked(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
roles: &[String],
|
||||||
|
) -> Result<ChunkedServerMembersGenerator> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
|
let mut session = self
|
||||||
|
.start_session()
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_database_error!("start_session", COL))?;
|
||||||
|
|
||||||
|
session
|
||||||
|
.start_transaction()
|
||||||
|
.read_concern(ReadConcern::snapshot())
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_database_error!("start_transaction", COL))?;
|
||||||
|
|
||||||
|
let cursor = self
|
||||||
|
.col::<Member>(COL)
|
||||||
|
.find(doc! {
|
||||||
|
"_id.server": server_id,
|
||||||
|
"roles": {"$in": roles}
|
||||||
|
})
|
||||||
|
.session(&mut session)
|
||||||
|
.batch_size(config.pushd.mass_mention_chunk_size as u32)
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_database_error!("find", COL))?;
|
||||||
|
|
||||||
|
return Ok(ChunkedServerMembersGenerator::new_mongo(session, cursor));
|
||||||
|
}
|
||||||
|
|
||||||
/// Fetch all memberships for a user
|
/// Fetch all memberships for a user
|
||||||
async fn fetch_all_memberships<'a>(&self, user_id: &str) -> Result<Vec<Member>> {
|
async fn fetch_all_memberships<'a>(&self, user_id: &str) -> Result<Vec<Member>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<Member>(COL)
|
.col::<Member>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"_id.user": user_id
|
||||||
"_id.user": user_id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", COL))?
|
.map_err(|_| create_database_error!("find", COL))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
@@ -79,15 +162,12 @@ impl AbstractServerMembers for MongoDb {
|
|||||||
async fn fetch_members<'a>(&self, server_id: &str, ids: &'a [String]) -> Result<Vec<Member>> {
|
async fn fetch_members<'a>(&self, server_id: &str, ids: &'a [String]) -> Result<Vec<Member>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<Member>(COL)
|
.col::<Member>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"_id.server": server_id,
|
||||||
"_id.server": server_id,
|
"_id.user": {
|
||||||
"_id.user": {
|
"$in": ids
|
||||||
"$in": ids
|
}
|
||||||
}
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", COL))?
|
.map_err(|_| create_database_error!("find", COL))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
@@ -104,12 +184,9 @@ impl AbstractServerMembers for MongoDb {
|
|||||||
/// Fetch member count of a server
|
/// Fetch member count of a server
|
||||||
async fn fetch_member_count(&self, server_id: &str) -> Result<usize> {
|
async fn fetch_member_count(&self, server_id: &str) -> Result<usize> {
|
||||||
self.col::<Member>(COL)
|
self.col::<Member>(COL)
|
||||||
.count_documents(
|
.count_documents(doc! {
|
||||||
doc! {
|
"_id.server": server_id
|
||||||
"_id.server": server_id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map(|c| c as usize)
|
.map(|c| c as usize)
|
||||||
.map_err(|_| create_database_error!("count_documents", COL))
|
.map_err(|_| create_database_error!("count_documents", COL))
|
||||||
@@ -118,12 +195,9 @@ impl AbstractServerMembers for MongoDb {
|
|||||||
/// Fetch server count of a user
|
/// Fetch server count of a user
|
||||||
async fn fetch_server_count(&self, user_id: &str) -> Result<usize> {
|
async fn fetch_server_count(&self, user_id: &str) -> Result<usize> {
|
||||||
self.col::<Member>(COL)
|
self.col::<Member>(COL)
|
||||||
.count_documents(
|
.count_documents(doc! {
|
||||||
doc! {
|
"_id.user": user_id
|
||||||
"_id.user": user_id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map(|c| c as usize)
|
.map(|c| c as usize)
|
||||||
.map_err(|_| create_database_error!("count_documents", COL))
|
.map_err(|_| create_database_error!("count_documents", COL))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use revolt_result::Result;
|
|||||||
use crate::ReferenceDb;
|
use crate::ReferenceDb;
|
||||||
use crate::{FieldsMember, Member, MemberCompositeKey, PartialMember};
|
use crate::{FieldsMember, Member, MemberCompositeKey, PartialMember};
|
||||||
|
|
||||||
use super::AbstractServerMembers;
|
use super::{AbstractServerMembers, ChunkedServerMembersGenerator};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl AbstractServerMembers for ReferenceDb {
|
impl AbstractServerMembers for ReferenceDb {
|
||||||
@@ -40,6 +40,70 @@ impl AbstractServerMembers for ReferenceDb {
|
|||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch all members in a server as an iterator
|
||||||
|
async fn fetch_all_members_chunked(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
) -> Result<ChunkedServerMembersGenerator> {
|
||||||
|
let server_members = self.server_members.lock().await;
|
||||||
|
|
||||||
|
let members = server_members
|
||||||
|
.clone()
|
||||||
|
.into_values()
|
||||||
|
.filter(move |member| member.id.server == server_id)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// this is inefficient as shit but its the reference db so its fine
|
||||||
|
Ok(ChunkedServerMembersGenerator::new_reference(members))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetch all members that have any of the roles given
|
||||||
|
async fn fetch_all_members_with_roles(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
roles: &[String],
|
||||||
|
) -> Result<Vec<Member>> {
|
||||||
|
let server_members = self.server_members.lock().await;
|
||||||
|
|
||||||
|
Ok(server_members
|
||||||
|
.clone()
|
||||||
|
.into_values()
|
||||||
|
.filter(|member| {
|
||||||
|
member.id.server == server_id
|
||||||
|
&& !member
|
||||||
|
.roles
|
||||||
|
.iter()
|
||||||
|
.filter(|p| roles.contains(*p))
|
||||||
|
.collect::<Vec<&String>>()
|
||||||
|
.is_empty()
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_all_members_with_roles_chunked(
|
||||||
|
&self,
|
||||||
|
server_id: &str,
|
||||||
|
roles: &[String],
|
||||||
|
) -> Result<ChunkedServerMembersGenerator> {
|
||||||
|
let server_members = self.server_members.lock().await;
|
||||||
|
|
||||||
|
let resp = server_members
|
||||||
|
.clone()
|
||||||
|
.into_values()
|
||||||
|
.filter(|member| {
|
||||||
|
member.id.server == server_id
|
||||||
|
&& !member
|
||||||
|
.roles
|
||||||
|
.iter()
|
||||||
|
.filter(|p| roles.contains(*p))
|
||||||
|
.collect::<Vec<&String>>()
|
||||||
|
.is_empty()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
return Ok(ChunkedServerMembersGenerator::new_reference(resp));
|
||||||
|
}
|
||||||
|
|
||||||
/// Fetch all memberships for a user
|
/// Fetch all memberships for a user
|
||||||
async fn fetch_all_memberships<'a>(&self, user_id: &str) -> Result<Vec<Member>> {
|
async fn fetch_all_memberships<'a>(&self, user_id: &str) -> Result<Vec<Member>> {
|
||||||
let server_members = self.server_members.lock().await;
|
let server_members = self.server_members.lock().await;
|
||||||
@@ -53,17 +117,17 @@ impl AbstractServerMembers for ReferenceDb {
|
|||||||
/// Fetch multiple members by their ids
|
/// Fetch multiple members by their ids
|
||||||
async fn fetch_members<'a>(&self, server_id: &str, ids: &'a [String]) -> Result<Vec<Member>> {
|
async fn fetch_members<'a>(&self, server_id: &str, ids: &'a [String]) -> Result<Vec<Member>> {
|
||||||
let server_members = self.server_members.lock().await;
|
let server_members = self.server_members.lock().await;
|
||||||
ids.iter()
|
Ok(ids
|
||||||
.map(|id| {
|
.iter()
|
||||||
|
.filter_map(|id| {
|
||||||
server_members
|
server_members
|
||||||
.get(&MemberCompositeKey {
|
.get(&MemberCompositeKey {
|
||||||
server: server_id.to_string(),
|
server: server_id.to_string(),
|
||||||
user: id.to_string(),
|
user: id.to_string(),
|
||||||
})
|
})
|
||||||
.cloned()
|
.cloned()
|
||||||
.ok_or_else(|| create_error!(NotFound))
|
|
||||||
})
|
})
|
||||||
.collect()
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch member count of a server
|
/// Fetch member count of a server
|
||||||
|
|||||||
@@ -25,14 +25,11 @@ impl AbstractServers for MongoDb {
|
|||||||
async fn fetch_servers<'a>(&self, ids: &'a [String]) -> Result<Vec<Server>> {
|
async fn fetch_servers<'a>(&self, ids: &'a [String]) -> Result<Vec<Server>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<Server>(COL)
|
.col::<Server>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"_id": {
|
||||||
"_id": {
|
"$in": ids
|
||||||
"$in": ids
|
}
|
||||||
}
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", "servers"))?
|
.map_err(|_| create_database_error!("find", "servers"))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
@@ -84,7 +81,6 @@ impl AbstractServers for MongoDb {
|
|||||||
.map_err(|_| create_database_error!("to_document", "role"))?
|
.map_err(|_| create_database_error!("to_document", "role"))?
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -125,7 +121,6 @@ impl AbstractServers for MongoDb {
|
|||||||
"roles": &role_id
|
"roles": &role_id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("update_many", "server_members"))?;
|
.map_err(|_| create_database_error!("update_many", "server_members"))?;
|
||||||
@@ -140,7 +135,6 @@ impl AbstractServers for MongoDb {
|
|||||||
"role_permissions.".to_owned() + role_id: 1_i32
|
"role_permissions.".to_owned() + role_id: 1_i32
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("update_one", "channels"))?;
|
.map_err(|_| create_database_error!("update_one", "channels"))?;
|
||||||
@@ -155,7 +149,6 @@ impl AbstractServers for MongoDb {
|
|||||||
"roles.".to_owned() + role_id: 1_i32
|
"roles.".to_owned() + role_id: 1_i32
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -188,12 +181,9 @@ impl MongoDb {
|
|||||||
// Find all channels
|
// Find all channels
|
||||||
let channels: Vec<String> = self
|
let channels: Vec<String> = self
|
||||||
.col::<Document>("channels")
|
.col::<Document>("channels")
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"server": server_id
|
||||||
"server": server_id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", "channels"))?
|
.map_err(|_| create_database_error!("find", "channels"))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
@@ -225,19 +215,15 @@ impl MongoDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("update_many", "emojis"))?;
|
.map_err(|_| create_database_error!("update_many", "emojis"))?;
|
||||||
|
|
||||||
// Delete all channels.
|
// Delete all channels.
|
||||||
self.col::<Document>("channels")
|
self.col::<Document>("channels")
|
||||||
.delete_many(
|
.delete_many(doc! {
|
||||||
doc! {
|
"server": &server_id
|
||||||
"server": &server_id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("delete_many", "channels"))?;
|
.map_err(|_| create_database_error!("delete_many", "channels"))?;
|
||||||
|
|
||||||
@@ -248,12 +234,9 @@ impl MongoDb {
|
|||||||
// Delete members and bans.
|
// Delete members and bans.
|
||||||
for with in &["server_members", "server_bans"] {
|
for with in &["server_members", "server_bans"] {
|
||||||
self.col::<Document>(with)
|
self.col::<Document>(with)
|
||||||
.delete_many(
|
.delete_many(doc! {
|
||||||
doc! {
|
"_id.server": &server_id
|
||||||
"_id.server": &server_id
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("delete_many", with))?;
|
.map_err(|_| create_database_error!("delete_many", with))?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ impl AbstractUserSettings for MongoDb {
|
|||||||
doc! {
|
doc! {
|
||||||
"$set": set
|
"$set": set
|
||||||
},
|
},
|
||||||
UpdateOptions::builder().upsert(true).build(),
|
|
||||||
)
|
)
|
||||||
|
.with_options(UpdateOptions::builder().upsert(true).build())
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| create_database_error!("update_one", "user_settings"))
|
.map_err(|_| create_database_error!("update_one", "user_settings"))
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
use std::{collections::HashSet, str::FromStr, time::Duration};
|
use std::{collections::HashSet, str::FromStr, time::Duration};
|
||||||
|
|
||||||
use crate::{events::client::EventV1, Database, File, RatelimitEvent};
|
use crate::{events::client::EventV1, Database, File, RatelimitEvent, AMQP};
|
||||||
|
|
||||||
use authifier::config::{EmailVerificationConfig, Template};
|
use authifier::config::{EmailVerificationConfig, Template};
|
||||||
|
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 revolt_config::{config, FeaturesLimits};
|
use revolt_config::{config, FeaturesLimits};
|
||||||
use revolt_models::v0::{self, UserFlags};
|
use revolt_models::v0::{self, UserFlags, UserBadges};
|
||||||
use revolt_presence::filter_online;
|
use revolt_presence::filter_online;
|
||||||
use revolt_result::{create_error, Result};
|
use revolt_result::{create_error, Result};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
@@ -152,7 +153,7 @@ pub static DISCRIMINATOR_SEARCH_SPACE: Lazy<HashSet<String>> = Lazy::new(|| {
|
|||||||
.collect::<HashSet<String>>();
|
.collect::<HashSet<String>>();
|
||||||
|
|
||||||
for discrim in [
|
for discrim in [
|
||||||
123, 1234, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999,
|
123, 1234, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 1488,
|
||||||
] {
|
] {
|
||||||
set.remove(&format!("{:0>4}", discrim));
|
set.remove(&format!("{:0>4}", discrim));
|
||||||
}
|
}
|
||||||
@@ -293,7 +294,14 @@ impl User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure none of the following substrings show up in the username
|
// Ensure none of the following substrings show up in the username
|
||||||
const BLOCKED_SUBSTRINGS: &[&str] = &["```"];
|
const BLOCKED_SUBSTRINGS: &[&str] = &[
|
||||||
|
"```",
|
||||||
|
"discord.gg",
|
||||||
|
"rvlt.gg",
|
||||||
|
"guilded.gg",
|
||||||
|
"https://",
|
||||||
|
"http://",
|
||||||
|
];
|
||||||
|
|
||||||
for substr in BLOCKED_SUBSTRINGS {
|
for substr in BLOCKED_SUBSTRINGS {
|
||||||
if username_lowercase.contains(substr) {
|
if username_lowercase.contains(substr) {
|
||||||
@@ -341,15 +349,16 @@ impl User {
|
|||||||
) -> Result<Vec<v0::User>> {
|
) -> Result<Vec<v0::User>> {
|
||||||
let online_ids = filter_online(ids).await;
|
let online_ids = filter_online(ids).await;
|
||||||
|
|
||||||
Ok(db
|
Ok(join_all(
|
||||||
|
db
|
||||||
.fetch_users(ids)
|
.fetch_users(ids)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|user| {
|
.map(|user| async {
|
||||||
let is_online = online_ids.contains(&user.id);
|
let is_online = online_ids.contains(&user.id);
|
||||||
user.into_known(perspective, is_online)
|
user.into_known(perspective, is_online).await
|
||||||
})
|
})
|
||||||
.collect())
|
).await)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find a free discriminator for a given username
|
/// Find a free discriminator for a given username
|
||||||
@@ -497,7 +506,12 @@ impl User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add another user as a friend
|
/// Add another user as a friend
|
||||||
pub async fn add_friend(&mut self, db: &Database, target: &mut User) -> Result<()> {
|
pub async fn add_friend(
|
||||||
|
&mut self,
|
||||||
|
db: &Database,
|
||||||
|
amqp: &AMQP,
|
||||||
|
target: &mut User,
|
||||||
|
) -> Result<()> {
|
||||||
match self.relationship_with(&target.id) {
|
match self.relationship_with(&target.id) {
|
||||||
RelationshipStatus::User => Err(create_error!(NoEffect)),
|
RelationshipStatus::User => Err(create_error!(NoEffect)),
|
||||||
RelationshipStatus::Friend => Err(create_error!(AlreadyFriends)),
|
RelationshipStatus::Friend => Err(create_error!(AlreadyFriends)),
|
||||||
@@ -506,6 +520,8 @@ impl User {
|
|||||||
RelationshipStatus::BlockedOther => Err(create_error!(BlockedByOther)),
|
RelationshipStatus::BlockedOther => Err(create_error!(BlockedByOther)),
|
||||||
RelationshipStatus::Incoming => {
|
RelationshipStatus::Incoming => {
|
||||||
// Accept incoming friend request
|
// Accept incoming friend request
|
||||||
|
_ = amqp.friend_request_accepted(self, target).await;
|
||||||
|
|
||||||
self.apply_relationship(
|
self.apply_relationship(
|
||||||
db,
|
db,
|
||||||
target,
|
target,
|
||||||
@@ -534,6 +550,8 @@ impl User {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ = amqp.friend_request_received(target, self).await;
|
||||||
|
|
||||||
// Send the friend request
|
// Send the friend request
|
||||||
self.apply_relationship(
|
self.apply_relationship(
|
||||||
db,
|
db,
|
||||||
@@ -791,4 +809,18 @@ impl User {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets the user's badges along with calculating any dynamic badges
|
||||||
|
pub async fn get_badges(&self) -> u32 {
|
||||||
|
let config = config().await;
|
||||||
|
let badges = self.badges.unwrap_or_default() as u32;
|
||||||
|
|
||||||
|
if let Some(cutoff) = config.api.users.early_adopter_cutoff {
|
||||||
|
if Ulid::from_string(&self.id).unwrap().timestamp_ms() < cutoff {
|
||||||
|
return badges + UserBadges::EarlyAdopter as u32
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
badges
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,9 @@ impl AbstractUsers for MongoDb {
|
|||||||
/// Fetch a session from the database by token
|
/// Fetch a session from the database by token
|
||||||
async fn fetch_session_by_token(&self, token: &str) -> Result<Session> {
|
async fn fetch_session_by_token(&self, token: &str) -> Result<Session> {
|
||||||
self.col::<Session>("sessions")
|
self.col::<Session>("sessions")
|
||||||
.find_one(
|
.find_one(doc! {
|
||||||
doc! {
|
"token": token
|
||||||
"token": token
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find_one", "sessions"))?
|
.map_err(|_| create_database_error!("find_one", "sessions"))?
|
||||||
.ok_or_else(|| create_error!(InvalidSession))
|
.ok_or_else(|| create_error!(InvalidSession))
|
||||||
@@ -64,14 +61,11 @@ impl AbstractUsers for MongoDb {
|
|||||||
async fn fetch_users<'a>(&self, ids: &'a [String]) -> Result<Vec<User>> {
|
async fn fetch_users<'a>(&self, ids: &'a [String]) -> Result<Vec<User>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<User>(COL)
|
.col::<User>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"_id": {
|
||||||
"_id": {
|
"$in": ids
|
||||||
"$in": ids
|
}
|
||||||
}
|
})
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", COL))?
|
.map_err(|_| create_database_error!("find", COL))?
|
||||||
.filter_map(|s| async {
|
.filter_map(|s| async {
|
||||||
@@ -94,10 +88,10 @@ impl AbstractUsers for MongoDb {
|
|||||||
|
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<UserDocument>(COL)
|
.col::<UserDocument>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"username": username
|
||||||
"username": username
|
})
|
||||||
},
|
.with_options(
|
||||||
FindOptions::builder()
|
FindOptions::builder()
|
||||||
.collation(
|
.collation(
|
||||||
Collation::builder()
|
Collation::builder()
|
||||||
@@ -122,15 +116,13 @@ impl AbstractUsers for MongoDb {
|
|||||||
async fn fetch_mutual_user_ids(&self, user_a: &str, user_b: &str) -> Result<Vec<String>> {
|
async fn fetch_mutual_user_ids(&self, user_a: &str, user_b: &str) -> Result<Vec<String>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<DocumentId>(COL)
|
.col::<DocumentId>(COL)
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"$and": [
|
||||||
"$and": [
|
{ "relations": { "$elemMatch": { "_id": &user_a, "status": "Friend" } } },
|
||||||
{ "relations": { "$elemMatch": { "_id": &user_a, "status": "Friend" } } },
|
{ "relations": { "$elemMatch": { "_id": &user_b, "status": "Friend" } } }
|
||||||
{ "relations": { "$elemMatch": { "_id": &user_b, "status": "Friend" } } }
|
]
|
||||||
]
|
})
|
||||||
},
|
.with_options(FindOptions::builder().projection(doc! { "_id": 1 }).build())
|
||||||
FindOptions::builder().projection(doc! { "_id": 1 }).build(),
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", COL))?
|
.map_err(|_| create_database_error!("find", COL))?
|
||||||
.filter_map(|s| async { s.ok() })
|
.filter_map(|s| async { s.ok() })
|
||||||
@@ -143,17 +135,15 @@ impl AbstractUsers for MongoDb {
|
|||||||
async fn fetch_mutual_channel_ids(&self, user_a: &str, user_b: &str) -> Result<Vec<String>> {
|
async fn fetch_mutual_channel_ids(&self, user_a: &str, user_b: &str) -> Result<Vec<String>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<DocumentId>("channels")
|
.col::<DocumentId>("channels")
|
||||||
.find(
|
.find(doc! {
|
||||||
doc! {
|
"channel_type": {
|
||||||
"channel_type": {
|
"$in": ["Group", "DirectMessage"]
|
||||||
"$in": ["Group", "DirectMessage"]
|
|
||||||
},
|
|
||||||
"recipients": {
|
|
||||||
"$all": [ user_a, user_b ]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
FindOptions::builder().projection(doc! { "_id": 1 }).build(),
|
"recipients": {
|
||||||
)
|
"$all": [ user_a, user_b ]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.with_options(FindOptions::builder().projection(doc! { "_id": 1 }).build())
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("find", "channels"))?
|
.map_err(|_| create_database_error!("find", "channels"))?
|
||||||
.filter_map(|s| async { s.ok() })
|
.filter_map(|s| async { s.ok() })
|
||||||
@@ -166,49 +156,46 @@ impl AbstractUsers for MongoDb {
|
|||||||
async fn fetch_mutual_server_ids(&self, user_a: &str, user_b: &str) -> Result<Vec<String>> {
|
async fn fetch_mutual_server_ids(&self, user_a: &str, user_b: &str) -> Result<Vec<String>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.col::<DocumentId>("server_members")
|
.col::<DocumentId>("server_members")
|
||||||
.aggregate(
|
.aggregate(vec![
|
||||||
vec![
|
doc! {
|
||||||
doc! {
|
"$match": {
|
||||||
"$match": {
|
"_id.user": user_a
|
||||||
"_id.user": user_a
|
}
|
||||||
}
|
},
|
||||||
},
|
doc! {
|
||||||
doc! {
|
"$lookup": {
|
||||||
"$lookup": {
|
"from": "server_members",
|
||||||
"from": "server_members",
|
"as": "members",
|
||||||
"as": "members",
|
"let": {
|
||||||
"let": {
|
"server": "$_id.server"
|
||||||
"server": "$_id.server"
|
},
|
||||||
},
|
"pipeline": [
|
||||||
"pipeline": [
|
{
|
||||||
{
|
"$match": {
|
||||||
"$match": {
|
"$expr": {
|
||||||
"$expr": {
|
"$and": [
|
||||||
"$and": [
|
{ "$eq": [ "$_id.user", user_b ] },
|
||||||
{ "$eq": [ "$_id.user", user_b ] },
|
{ "$eq": [ "$_id.server", "$$server" ] }
|
||||||
{ "$eq": [ "$_id.server", "$$server" ] }
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
doc! {
|
|
||||||
"$match": {
|
|
||||||
"members": {
|
|
||||||
"$size": 1_i32
|
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
doc! {
|
||||||
|
"$match": {
|
||||||
|
"members": {
|
||||||
|
"$size": 1_i32
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
doc! {
|
},
|
||||||
"$project": {
|
doc! {
|
||||||
"_id": "$_id.server"
|
"$project": {
|
||||||
}
|
"_id": "$_id.server"
|
||||||
},
|
}
|
||||||
],
|
},
|
||||||
None,
|
])
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_database_error!("aggregate", "server_members"))?
|
.map_err(|_| create_database_error!("aggregate", "server_members"))?
|
||||||
.filter_map(|s| async { s.ok() })
|
.filter_map(|s| async { s.ok() })
|
||||||
@@ -284,7 +271,6 @@ impl AbstractUsers for MongoDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -305,7 +291,6 @@ impl AbstractUsers for MongoDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
@@ -329,7 +314,6 @@ impl AbstractUsers for MongoDb {
|
|||||||
"subscription": 1
|
"subscription": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ impl<'r> FromRequest<'r> for User {
|
|||||||
if let Some(user) = user {
|
if let Some(user) = user {
|
||||||
Outcome::Success(user.clone())
|
Outcome::Success(user.clone())
|
||||||
} else {
|
} else {
|
||||||
Outcome::Failure((Status::Unauthorized, authifier::Error::InvalidSession))
|
Outcome::Error((Status::Unauthorized, authifier::Error::InvalidSession))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,28 @@
|
|||||||
// Queue Type: Debounced
|
// Queue Type: Debounced
|
||||||
use crate::Database;
|
use crate::{Database, Message, AMQP};
|
||||||
|
|
||||||
use deadqueue::limited::Queue;
|
use deadqueue::limited::Queue;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::{collections::HashMap, time::Duration};
|
use revolt_models::v0::PushNotification;
|
||||||
|
use rocket::form::validate::Contains;
|
||||||
|
use std::{
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
use validator::HasLen;
|
||||||
|
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use super::{apple_notifications::{self, ApnJob}, DelayedTask};
|
use super::DelayedTask;
|
||||||
|
use crate::Channel::{TextChannel, VoiceChannel};
|
||||||
|
|
||||||
/// Enumeration of possible events
|
/// Enumeration of possible events
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub enum AckEvent {
|
pub enum AckEvent {
|
||||||
/// Add mentions for a user in a channel
|
/// Add mentions for a channel
|
||||||
AddMention {
|
ProcessMessage {
|
||||||
/// Message IDs
|
/// push notification, message, recipients, push silenced
|
||||||
ids: Vec<String>,
|
messages: Vec<(Option<PushNotification>, Message, Vec<String>, bool)>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Acknowledge message in a channel for a user
|
/// Acknowledge message in a channel for a user
|
||||||
@@ -30,7 +37,7 @@ struct Data {
|
|||||||
/// Channel to ack
|
/// Channel to ack
|
||||||
channel: String,
|
channel: String,
|
||||||
/// User to ack for
|
/// User to ack for
|
||||||
user: String,
|
user: Option<String>,
|
||||||
/// Event
|
/// Event
|
||||||
event: AckEvent,
|
event: AckEvent,
|
||||||
}
|
}
|
||||||
@@ -43,21 +50,49 @@ struct Task {
|
|||||||
static Q: Lazy<Queue<Data>> = Lazy::new(|| Queue::new(10_000));
|
static Q: Lazy<Queue<Data>> = Lazy::new(|| Queue::new(10_000));
|
||||||
|
|
||||||
/// Queue a new task for a worker
|
/// Queue a new task for a worker
|
||||||
pub async fn queue(channel: String, user: String, event: AckEvent) {
|
pub async fn queue_ack(channel: String, user: String, event: AckEvent) {
|
||||||
Q.try_push(Data {
|
Q.try_push(Data {
|
||||||
channel,
|
channel,
|
||||||
user,
|
user: Some(user),
|
||||||
event,
|
event,
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
info!("Queue is using {} slots from {}.", Q.len(), Q.capacity());
|
info!(
|
||||||
|
"Queue is using {} slots from {}. Queued type: ACK",
|
||||||
|
Q.len(),
|
||||||
|
Q.capacity()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_ack_event(event: &AckEvent, db: &Database, authifier_db: &authifier::Database, user: &str, channel: &str) -> Result<()> {
|
pub async fn queue_message(channel: String, event: AckEvent) {
|
||||||
|
Q.try_push(Data {
|
||||||
|
channel,
|
||||||
|
user: None,
|
||||||
|
event,
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Queue is using {} slots from {}. Queued type: MENTION",
|
||||||
|
Q.len(),
|
||||||
|
Q.capacity()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn handle_ack_event(
|
||||||
|
event: &AckEvent,
|
||||||
|
db: &Database,
|
||||||
|
amqp: &AMQP,
|
||||||
|
user: &Option<String>,
|
||||||
|
channel: &str,
|
||||||
|
) -> Result<()> {
|
||||||
match &event {
|
match &event {
|
||||||
#[allow(clippy::disallowed_methods)] // event is sent by higher level function
|
#[allow(clippy::disallowed_methods)] // event is sent by higher level function
|
||||||
AckEvent::AckMessage { id } => {
|
AckEvent::AckMessage { id } => {
|
||||||
|
let user = user.as_ref().unwrap();
|
||||||
|
let user: &str = user.as_str();
|
||||||
|
|
||||||
let unread = db.fetch_unread(user, channel).await?;
|
let unread = db.fetch_unread(user, channel).await?;
|
||||||
let updated = db.acknowledge_message(channel, user, id).await?;
|
let updated = db.acknowledge_message(channel, user, id).await?;
|
||||||
|
|
||||||
@@ -68,21 +103,106 @@ pub async fn handle_ack_event(event: &AckEvent, db: &Database, authifier_db: &au
|
|||||||
let mentions_acked = before_mentions - after_mentions;
|
let mentions_acked = before_mentions - after_mentions;
|
||||||
|
|
||||||
if mentions_acked > 0 {
|
if mentions_acked > 0 {
|
||||||
if let Ok(sessions) = authifier_db.find_sessions(user).await {
|
if let Err(err) = amqp
|
||||||
for session in sessions {
|
.ack_message(user.to_string(), channel.to_string(), id.to_owned())
|
||||||
if let Some(sub) = session.subscription {
|
.await
|
||||||
if sub.endpoint == "apn" {
|
{
|
||||||
apple_notifications::queue(ApnJob::from_ack(session.id, user.to_string(), sub.auth)).await;
|
revolt_config::capture_error(&err);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
AckEvent::AddMention { ids } => {
|
AckEvent::ProcessMessage { messages } => {
|
||||||
db.add_mention_to_unread(channel, user, ids).await?;
|
let mut users: HashSet<&String> = HashSet::new();
|
||||||
|
debug!(
|
||||||
|
"Processing {} messages from channel {}",
|
||||||
|
messages.len(),
|
||||||
|
messages[0].1.channel
|
||||||
|
);
|
||||||
|
|
||||||
|
// find all the users we'll be notifying
|
||||||
|
messages.iter().for_each(|(_, _, recipents, _)| {
|
||||||
|
users.extend(recipents.iter());
|
||||||
|
});
|
||||||
|
|
||||||
|
debug!("Found {} users to notify.", users.len());
|
||||||
|
|
||||||
|
for user in users {
|
||||||
|
let message_ids: Vec<String> = messages
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(_, message, recipients, _)| {
|
||||||
|
if recipients.contains(user) {
|
||||||
|
Some(message.id.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
if !message_ids.is_empty() {
|
||||||
|
db.add_mention_to_unread(channel, user, &message_ids)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
debug!("Added {} mentions for user {}", message_ids.len(), &user);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut mass_mentions = vec![];
|
||||||
|
|
||||||
|
for (push, message, recipients, silenced) in messages {
|
||||||
|
if *silenced
|
||||||
|
|| push.is_none()
|
||||||
|
|| (recipients.is_empty() && !message.contains_mass_push_mention())
|
||||||
|
{
|
||||||
|
debug!(
|
||||||
|
"Rejecting push: silenced: {}, recipient count: {}, push exists: {:?}",
|
||||||
|
*silenced,
|
||||||
|
recipients.length(),
|
||||||
|
push.is_some()
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Sending push event to AMQP; message {} for {} users",
|
||||||
|
push.as_ref().unwrap().message.id,
|
||||||
|
recipients.len()
|
||||||
|
);
|
||||||
|
if let Err(err) = amqp
|
||||||
|
.message_sent(recipients.clone(), push.clone().unwrap())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
revolt_config::capture_error(&err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if message.contains_mass_push_mention() {
|
||||||
|
mass_mentions.push(push.clone().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !mass_mentions.is_empty() {
|
||||||
|
debug!(
|
||||||
|
"Sending mass mention push event to AMQP; channel {}",
|
||||||
|
&mass_mentions[0].message.channel
|
||||||
|
);
|
||||||
|
|
||||||
|
let channel = db
|
||||||
|
.fetch_channel(&mass_mentions[0].message.channel)
|
||||||
|
.await
|
||||||
|
.expect("Failed to fetch channel from db");
|
||||||
|
|
||||||
|
match channel {
|
||||||
|
TextChannel { server, .. } | VoiceChannel { server, .. } => {
|
||||||
|
if let Err(err) =
|
||||||
|
amqp.mass_mention_message_sent(server, mass_mentions).await
|
||||||
|
{
|
||||||
|
revolt_config::capture_error(&err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
panic!("Unknown channel type when sending mass mention event");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,9 +210,9 @@ pub async fn handle_ack_event(event: &AckEvent, db: &Database, authifier_db: &au
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Start a new worker
|
/// Start a new worker
|
||||||
pub async fn worker(db: Database, authifier_db: authifier::Database) {
|
pub async fn worker(db: Database, amqp: AMQP) {
|
||||||
let mut tasks = HashMap::<(String, String), DelayedTask<Task>>::new();
|
let mut tasks = HashMap::<(Option<String>, String, u8), DelayedTask<Task>>::new();
|
||||||
let mut keys = vec![];
|
let mut keys: Vec<(Option<String>, String, u8)> = vec![];
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Find due tasks.
|
// Find due tasks.
|
||||||
@@ -106,12 +226,13 @@ pub async fn worker(db: Database, authifier_db: authifier::Database) {
|
|||||||
for key in &keys {
|
for key in &keys {
|
||||||
if let Some(task) = tasks.remove(key) {
|
if let Some(task) = tasks.remove(key) {
|
||||||
let Task { event } = task.data;
|
let Task { event } = task.data;
|
||||||
let (user, channel) = key;
|
let (user, channel, _) = key;
|
||||||
|
|
||||||
if let Err(err) = handle_ack_event(&event, &db, &authifier_db, user, channel).await {
|
if let Err(err) = handle_ack_event(&event, &db, &amqp, user, channel).await {
|
||||||
error!("{err:?} for {event:?}. ({user}, {channel})");
|
revolt_config::capture_error(&err);
|
||||||
|
error!("{err:?} for {event:?}. ({user:?}, {channel})");
|
||||||
} else {
|
} else {
|
||||||
info!("User {user} ack in {channel} with {event:?}");
|
debug!("User {user:?} ack in {channel} with {event:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,20 +247,47 @@ pub async fn worker(db: Database, authifier_db: authifier::Database) {
|
|||||||
mut event,
|
mut event,
|
||||||
}) = Q.try_pop()
|
}) = Q.try_pop()
|
||||||
{
|
{
|
||||||
let key = (user, channel);
|
let key: (Option<String>, String, u8) = (
|
||||||
|
user,
|
||||||
|
channel,
|
||||||
|
match &event {
|
||||||
|
AckEvent::AckMessage { .. } => 0,
|
||||||
|
AckEvent::ProcessMessage { .. } => 1,
|
||||||
|
},
|
||||||
|
);
|
||||||
if let Some(task) = tasks.get_mut(&key) {
|
if let Some(task) = tasks.get_mut(&key) {
|
||||||
task.delay();
|
|
||||||
|
|
||||||
match &mut event {
|
match &mut event {
|
||||||
AckEvent::AddMention { ids } => {
|
AckEvent::ProcessMessage { messages: new_data } => {
|
||||||
if let AckEvent::AddMention { ids: existing } = &mut task.data.event {
|
if let AckEvent::ProcessMessage { messages: existing } =
|
||||||
existing.append(ids);
|
&mut task.data.event
|
||||||
|
{
|
||||||
|
// add the new message to the list of messages to be processed.
|
||||||
|
existing.append(new_data);
|
||||||
|
|
||||||
|
// if the message contains a mass mention, do not delay it any further.
|
||||||
|
if new_data[0].1.contains_mass_push_mention() {
|
||||||
|
task.run_immediately();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// put a cap on the amount of messages that can be queued, for particularly active channels
|
||||||
|
if (existing.length() as u16)
|
||||||
|
< revolt_config::config()
|
||||||
|
.await
|
||||||
|
.features
|
||||||
|
.advanced
|
||||||
|
.process_message_delay_limit
|
||||||
|
{
|
||||||
|
task.delay();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
task.data.event = event;
|
panic!("Somehow got an ack message in the add mention arm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AckEvent::AckMessage { .. } => {
|
AckEvent::AckMessage { .. } => {
|
||||||
|
// replace the last acked message with the new acked message
|
||||||
task.data.event = event;
|
task.data.event = event;
|
||||||
|
task.delay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,314 +0,0 @@
|
|||||||
use std::io::Cursor;
|
|
||||||
|
|
||||||
use base64::{
|
|
||||||
engine::{self},
|
|
||||||
Engine as _,
|
|
||||||
};
|
|
||||||
use deadqueue::limited::Queue;
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use revolt_a2::{
|
|
||||||
request::{
|
|
||||||
notification::{DefaultAlert, NotificationOptions},
|
|
||||||
payload::{APSAlert, APSSound, PayloadLike, APS},
|
|
||||||
},
|
|
||||||
Client, ClientConfig, Endpoint, Error, ErrorBody, ErrorReason, Priority, PushType, Response,
|
|
||||||
};
|
|
||||||
use revolt_config::config;
|
|
||||||
use revolt_models::v0::{Message, PushNotification};
|
|
||||||
|
|
||||||
use crate::Database;
|
|
||||||
|
|
||||||
/// Payload information, before assembly
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub struct ApnPayload {
|
|
||||||
message: Message,
|
|
||||||
url: String,
|
|
||||||
authorAvatar: String,
|
|
||||||
authorDisplayName: String,
|
|
||||||
channelName: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Debug)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
struct Payload<'a> {
|
|
||||||
aps: APS<'a>,
|
|
||||||
#[serde(skip_serializing)]
|
|
||||||
options: NotificationOptions<'a>,
|
|
||||||
#[serde(skip_serializing)]
|
|
||||||
device_token: &'a str,
|
|
||||||
|
|
||||||
message: &'a Message,
|
|
||||||
url: &'a str,
|
|
||||||
authorAvatar: &'a str,
|
|
||||||
authorDisplayName: &'a str,
|
|
||||||
channelName: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> PayloadLike for Payload<'a> {
|
|
||||||
fn get_device_token(&self) -> &'a str {
|
|
||||||
self.device_token
|
|
||||||
}
|
|
||||||
fn get_options(&self) -> &NotificationOptions {
|
|
||||||
&self.options
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Task information
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct AlertJob {
|
|
||||||
/// Session Id
|
|
||||||
session_id: String,
|
|
||||||
|
|
||||||
/// Device token
|
|
||||||
device_token: String,
|
|
||||||
|
|
||||||
/// User Id
|
|
||||||
user_id: String,
|
|
||||||
|
|
||||||
/// Title
|
|
||||||
title: String,
|
|
||||||
|
|
||||||
/// Body
|
|
||||||
body: String,
|
|
||||||
|
|
||||||
/// Thread Id
|
|
||||||
thread_id: String,
|
|
||||||
|
|
||||||
/// Category (informs the client what kind of notification is being sent.)
|
|
||||||
category: String,
|
|
||||||
|
|
||||||
/// Payload used by the iOS client to modify the notification
|
|
||||||
custom_payload: ApnPayload,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AlertJob {
|
|
||||||
fn format_title(notification: &PushNotification) -> String {
|
|
||||||
// ideally this changes depending on context
|
|
||||||
// in a server, it would look like "Sendername, #channelname in servername"
|
|
||||||
// in a group, it would look like "Sendername in groupname"
|
|
||||||
// in a dm it should just be "Sendername".
|
|
||||||
// not sure how feasible all those are given the PushNotification object as it currently stands.
|
|
||||||
format!(
|
|
||||||
"{} in {}",
|
|
||||||
notification.author, notification.message.channel
|
|
||||||
) // TODO: this absolutely needs a channel name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct BadgeJob {
|
|
||||||
/// Session Id
|
|
||||||
session_id: String,
|
|
||||||
|
|
||||||
/// Device token
|
|
||||||
device_token: String,
|
|
||||||
|
|
||||||
/// User Id
|
|
||||||
user_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum JobType {
|
|
||||||
Alert(AlertJob),
|
|
||||||
Badge(BadgeJob),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ApnJob {
|
|
||||||
job_type: JobType,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ApnJob {
|
|
||||||
pub fn from_notification(
|
|
||||||
session_id: String,
|
|
||||||
user_id: String,
|
|
||||||
device_token: String,
|
|
||||||
notification: &PushNotification,
|
|
||||||
) -> ApnJob {
|
|
||||||
ApnJob {
|
|
||||||
job_type: JobType::Alert(AlertJob {
|
|
||||||
session_id,
|
|
||||||
device_token,
|
|
||||||
user_id,
|
|
||||||
title: AlertJob::format_title(notification),
|
|
||||||
body: notification.body.to_string(),
|
|
||||||
thread_id: notification.tag.to_string(),
|
|
||||||
category: "ALERT_MESSAGE".to_string(),
|
|
||||||
custom_payload: ApnPayload {
|
|
||||||
message: notification.message.clone(),
|
|
||||||
url: notification.url.clone(),
|
|
||||||
authorAvatar: notification.icon.clone(),
|
|
||||||
authorDisplayName: notification.author.clone(),
|
|
||||||
channelName: "#fetchchannelnamehere".to_string(), // TODO: get actual channel name
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_ack(session_id: String, user_id: String, device_token: String) -> ApnJob {
|
|
||||||
ApnJob {
|
|
||||||
job_type: JobType::Badge(BadgeJob {
|
|
||||||
session_id,
|
|
||||||
device_token,
|
|
||||||
user_id,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum AssembledPayload<'a> {
|
|
||||||
Alert(Payload<'a>),
|
|
||||||
Default(revolt_a2::request::payload::Payload<'a>),
|
|
||||||
}
|
|
||||||
|
|
||||||
static Q: Lazy<Queue<ApnJob>> = Lazy::new(|| Queue::new(10_000));
|
|
||||||
|
|
||||||
/// Queue a new task for a worker
|
|
||||||
pub async fn queue(task: ApnJob) {
|
|
||||||
Q.try_push(task).ok();
|
|
||||||
info!("Queue is using {} slots from {}.", Q.len(), Q.capacity());
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_badge_count(db: &Database, user: &str) -> Option<u32> {
|
|
||||||
if let Ok(unreads) = db.fetch_unreads(user).await {
|
|
||||||
let mut mention_count = 0;
|
|
||||||
for channel in unreads {
|
|
||||||
if let Some(mentions) = channel.mentions {
|
|
||||||
mention_count += mentions.len() as u32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Some(mention_count);
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Start a new worker
|
|
||||||
pub async fn worker(db: Database) {
|
|
||||||
let config = config().await;
|
|
||||||
if config.api.apn.pkcs8.is_empty()
|
|
||||||
|| config.api.apn.key_id.is_empty()
|
|
||||||
|| config.api.apn.team_id.is_empty()
|
|
||||||
{
|
|
||||||
eprintln!("Missing APN keys.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let endpoint = if config.api.apn.sandbox {
|
|
||||||
Endpoint::Sandbox
|
|
||||||
} else {
|
|
||||||
Endpoint::Production
|
|
||||||
};
|
|
||||||
|
|
||||||
let pkcs8 = engine::general_purpose::STANDARD
|
|
||||||
.decode(config.api.apn.pkcs8)
|
|
||||||
.expect("valid `pcks8`");
|
|
||||||
|
|
||||||
let client_config = ClientConfig::new(endpoint);
|
|
||||||
|
|
||||||
let client = Client::token(
|
|
||||||
&mut Cursor::new(pkcs8),
|
|
||||||
config.api.apn.key_id,
|
|
||||||
config.api.apn.team_id,
|
|
||||||
client_config,
|
|
||||||
)
|
|
||||||
.expect("could not create APN client");
|
|
||||||
|
|
||||||
let payload_options = NotificationOptions {
|
|
||||||
apns_id: None,
|
|
||||||
apns_push_type: Some(PushType::Alert),
|
|
||||||
apns_expiration: None,
|
|
||||||
apns_priority: Some(Priority::High),
|
|
||||||
apns_topic: Some("chat.revolt.app"),
|
|
||||||
apns_collapse_id: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let task = Q.pop().await;
|
|
||||||
let payload: AssembledPayload;
|
|
||||||
|
|
||||||
match task.job_type {
|
|
||||||
JobType::Alert(ref alert) => {
|
|
||||||
payload = AssembledPayload::Alert(Payload {
|
|
||||||
aps: APS {
|
|
||||||
alert: Some(APSAlert::Default(DefaultAlert {
|
|
||||||
title: Some(&alert.title),
|
|
||||||
subtitle: None,
|
|
||||||
body: Some(&alert.body),
|
|
||||||
title_loc_key: None,
|
|
||||||
title_loc_args: None,
|
|
||||||
action_loc_key: None,
|
|
||||||
loc_key: None,
|
|
||||||
loc_args: None,
|
|
||||||
launch_image: None,
|
|
||||||
})),
|
|
||||||
badge: get_badge_count(&db, &alert.user_id).await,
|
|
||||||
sound: Some(APSSound::Sound("default")),
|
|
||||||
thread_id: Some(&alert.thread_id),
|
|
||||||
content_available: None,
|
|
||||||
category: Some(&alert.category),
|
|
||||||
mutable_content: Some(1),
|
|
||||||
url_args: None,
|
|
||||||
},
|
|
||||||
device_token: &alert.device_token,
|
|
||||||
options: payload_options.clone(),
|
|
||||||
message: &alert.custom_payload.message,
|
|
||||||
url: &alert.custom_payload.url,
|
|
||||||
authorAvatar: &alert.custom_payload.authorAvatar,
|
|
||||||
authorDisplayName: &alert.custom_payload.authorDisplayName,
|
|
||||||
channelName: &alert.custom_payload.channelName,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
JobType::Badge(ref alert) => {
|
|
||||||
payload = AssembledPayload::Default(revolt_a2::request::payload::Payload {
|
|
||||||
aps: APS {
|
|
||||||
alert: None,
|
|
||||||
badge: get_badge_count(&db, &alert.user_id).await,
|
|
||||||
sound: None,
|
|
||||||
thread_id: None,
|
|
||||||
content_available: None,
|
|
||||||
category: None,
|
|
||||||
mutable_content: None,
|
|
||||||
url_args: None,
|
|
||||||
},
|
|
||||||
device_token: &alert.device_token,
|
|
||||||
options: payload_options.clone(),
|
|
||||||
data: std::collections::BTreeMap::new(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let resp = match payload {
|
|
||||||
AssembledPayload::Alert(p) => client.send(p).await,
|
|
||||||
AssembledPayload::Default(p) => client.send(p).await,
|
|
||||||
};
|
|
||||||
//println!("response from APNS: {:?}", resp);
|
|
||||||
|
|
||||||
if let Err(err) = resp {
|
|
||||||
match err {
|
|
||||||
Error::ResponseError(Response {
|
|
||||||
error:
|
|
||||||
Some(ErrorBody {
|
|
||||||
reason: ErrorReason::BadDeviceToken | ErrorReason::Unregistered,
|
|
||||||
..
|
|
||||||
}),
|
|
||||||
..
|
|
||||||
}) => {
|
|
||||||
if let Err(err) = db
|
|
||||||
.remove_push_subscription_by_session_id(match task.job_type {
|
|
||||||
JobType::Alert(ref a) => &a.session_id.as_str(),
|
|
||||||
JobType::Badge(ref a) => &a.session_id.as_str(),
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
revolt_config::capture_error(&err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err => {
|
|
||||||
revolt_config::capture_error(&err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//! Semi-important background task management
|
//! Semi-important background task management
|
||||||
|
|
||||||
use crate::Database;
|
use crate::{Database, AMQP};
|
||||||
|
|
||||||
use async_std::task;
|
use async_std::task;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
@@ -8,28 +8,25 @@ use std::time::Instant;
|
|||||||
const WORKER_COUNT: usize = 5;
|
const WORKER_COUNT: usize = 5;
|
||||||
|
|
||||||
pub mod ack;
|
pub mod ack;
|
||||||
pub mod apple_notifications;
|
|
||||||
pub mod authifier_relay;
|
pub mod authifier_relay;
|
||||||
pub mod last_message_id;
|
pub mod last_message_id;
|
||||||
pub mod process_embeds;
|
pub mod process_embeds;
|
||||||
pub mod web_push;
|
|
||||||
|
|
||||||
/// Spawn background workers
|
/// Spawn background workers
|
||||||
pub fn start_workers(db: Database, authifier_db: authifier::Database) {
|
pub fn start_workers(db: Database, amqp: AMQP) {
|
||||||
task::spawn(authifier_relay::worker());
|
task::spawn(authifier_relay::worker());
|
||||||
task::spawn(apple_notifications::worker(db.clone()));
|
|
||||||
|
|
||||||
for _ in 0..WORKER_COUNT {
|
for _ in 0..WORKER_COUNT {
|
||||||
task::spawn(ack::worker(db.clone(), authifier_db.clone()));
|
task::spawn(ack::worker(db.clone(), amqp.clone()));
|
||||||
task::spawn(last_message_id::worker(db.clone()));
|
task::spawn(last_message_id::worker(db.clone()));
|
||||||
task::spawn(process_embeds::worker(db.clone()));
|
task::spawn(process_embeds::worker(db.clone()));
|
||||||
task::spawn(web_push::worker(db.clone(), authifier_db.clone()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Task with additional information on when it should run
|
/// Task with additional information on when it should run
|
||||||
pub struct DelayedTask<T> {
|
pub struct DelayedTask<T> {
|
||||||
pub data: T,
|
pub data: T,
|
||||||
|
run_now: bool,
|
||||||
last_updated: Instant,
|
last_updated: Instant,
|
||||||
first_seen: Instant,
|
first_seen: Instant,
|
||||||
}
|
}
|
||||||
@@ -45,6 +42,7 @@ impl<T> DelayedTask<T> {
|
|||||||
pub fn new(data: T) -> Self {
|
pub fn new(data: T) -> Self {
|
||||||
DelayedTask {
|
DelayedTask {
|
||||||
data,
|
data,
|
||||||
|
run_now: false,
|
||||||
last_updated: Instant::now(),
|
last_updated: Instant::now(),
|
||||||
first_seen: Instant::now(),
|
first_seen: Instant::now(),
|
||||||
}
|
}
|
||||||
@@ -55,9 +53,15 @@ impl<T> DelayedTask<T> {
|
|||||||
self.last_updated = Instant::now()
|
self.last_updated = Instant::now()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Flag the task to run right away, regardless of the time
|
||||||
|
pub fn run_immediately(&mut self) {
|
||||||
|
self.run_now = true
|
||||||
|
}
|
||||||
|
|
||||||
/// Check if a task should run yet
|
/// Check if a task should run yet
|
||||||
pub fn should_run(&self) -> bool {
|
pub fn should_run(&self) -> bool {
|
||||||
self.first_seen.elapsed().as_secs() > EXPIRE_CONSTANT
|
self.run_now
|
||||||
|
|| self.first_seen.elapsed().as_secs() > EXPIRE_CONSTANT
|
||||||
|| self.last_updated.elapsed().as_secs() > SAVE_CONSTANT
|
|| self.last_updated.elapsed().as_secs() > SAVE_CONSTANT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,198 +0,0 @@
|
|||||||
use std::{
|
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
|
|
||||||
use authifier::Database as AuthifierDatabase;
|
|
||||||
use base64::{
|
|
||||||
engine::{self},
|
|
||||||
Engine as _,
|
|
||||||
};
|
|
||||||
use deadqueue::limited::Queue;
|
|
||||||
use fcm_v1::auth::{Authenticator, ServiceAccountKey};
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use revolt_config::{config, report_internal_error};
|
|
||||||
use revolt_models::v0::PushNotification;
|
|
||||||
use revolt_presence::filter_online;
|
|
||||||
use serde_json::json;
|
|
||||||
use web_push::{
|
|
||||||
ContentEncoding, IsahcWebPushClient, SubscriptionInfo, SubscriptionKeys, VapidSignatureBuilder,
|
|
||||||
WebPushClient, WebPushMessageBuilder,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::Database;
|
|
||||||
|
|
||||||
use super::apple_notifications;
|
|
||||||
|
|
||||||
/// Task information
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct PushTask {
|
|
||||||
/// User IDs of the targets that are to receive this notification
|
|
||||||
recipients: Vec<String>,
|
|
||||||
/// Push Notification
|
|
||||||
payload: PushNotification,
|
|
||||||
}
|
|
||||||
|
|
||||||
static Q: Lazy<Queue<PushTask>> = Lazy::new(|| Queue::new(10_000));
|
|
||||||
|
|
||||||
/// Queue a new task for a worker
|
|
||||||
pub async fn queue(recipients: Vec<String>, payload: PushNotification) {
|
|
||||||
if recipients.is_empty() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let online_ids = filter_online(&recipients).await;
|
|
||||||
let recipients = (&recipients.into_iter().collect::<HashSet<String>>() - &online_ids)
|
|
||||||
.into_iter()
|
|
||||||
.collect::<Vec<String>>();
|
|
||||||
|
|
||||||
Q.try_push(PushTask {
|
|
||||||
recipients,
|
|
||||||
payload,
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
|
|
||||||
info!("Queue is using {} slots from {}.", Q.len(), Q.capacity());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Start a new worker
|
|
||||||
pub async fn worker(db: Database, authifier_db: AuthifierDatabase) {
|
|
||||||
let config = config().await;
|
|
||||||
|
|
||||||
let web_push_client = IsahcWebPushClient::new().unwrap();
|
|
||||||
let fcm_client = if config.api.fcm.key_type.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(fcm_v1::Client::new(
|
|
||||||
Authenticator::service_account::<&str>(ServiceAccountKey {
|
|
||||||
key_type: Some(config.api.fcm.key_type),
|
|
||||||
project_id: Some(config.api.fcm.project_id.clone()),
|
|
||||||
private_key_id: Some(config.api.fcm.private_key_id),
|
|
||||||
private_key: config.api.fcm.private_key,
|
|
||||||
client_email: config.api.fcm.client_email,
|
|
||||||
client_id: Some(config.api.fcm.client_id),
|
|
||||||
auth_uri: Some(config.api.fcm.auth_uri),
|
|
||||||
token_uri: config.api.fcm.token_uri,
|
|
||||||
auth_provider_x509_cert_url: Some(config.api.fcm.auth_provider_x509_cert_url),
|
|
||||||
client_x509_cert_url: Some(config.api.fcm.client_x509_cert_url),
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.unwrap(),
|
|
||||||
config.api.fcm.project_id,
|
|
||||||
false,
|
|
||||||
Duration::from_secs(5),
|
|
||||||
))
|
|
||||||
};
|
|
||||||
|
|
||||||
let web_push_private_key = engine::general_purpose::URL_SAFE_NO_PAD
|
|
||||||
.decode(config.api.vapid.private_key)
|
|
||||||
.expect("valid `VAPID_PRIVATE_KEY`");
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let task = Q.pop().await;
|
|
||||||
|
|
||||||
if let Ok(sessions) = authifier_db
|
|
||||||
.find_sessions_with_subscription(&task.recipients)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
for session in sessions {
|
|
||||||
if let Some(sub) = session.subscription {
|
|
||||||
if sub.endpoint == "fcm" {
|
|
||||||
// Use Firebase Cloud Messaging
|
|
||||||
if let Some(client) = &fcm_client {
|
|
||||||
let message = fcm_v1::message::Message {
|
|
||||||
token: Some(sub.auth),
|
|
||||||
data: Some(HashMap::from([(
|
|
||||||
"payload".to_owned(),
|
|
||||||
serde_json::Value::String(json!(&task.payload).to_string()),
|
|
||||||
)])),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(err) = client.send(&message).await {
|
|
||||||
error!("Failed to send FCM notification! {:?}", err);
|
|
||||||
|
|
||||||
if let fcm_v1::Error::FCM(fcm_error) = err {
|
|
||||||
if fcm_error.contains("404 (Not Found)") {
|
|
||||||
println!("Unregistering {:?}", session.id);
|
|
||||||
|
|
||||||
report_internal_error!(
|
|
||||||
db.remove_push_subscription_by_session_id(&session.id)
|
|
||||||
.await
|
|
||||||
)
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
info!("Sent FCM notification to {:?}.", session.id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
info!("No FCM token was specified!");
|
|
||||||
}
|
|
||||||
} else if sub.endpoint == "apn" {
|
|
||||||
apple_notifications::queue(apple_notifications::ApnJob::from_notification(
|
|
||||||
session.id,
|
|
||||||
session.user_id,
|
|
||||||
sub.auth,
|
|
||||||
&task.payload,
|
|
||||||
))
|
|
||||||
.await;
|
|
||||||
} else {
|
|
||||||
// Use Web Push Standard
|
|
||||||
let subscription = SubscriptionInfo {
|
|
||||||
endpoint: sub.endpoint,
|
|
||||||
keys: SubscriptionKeys {
|
|
||||||
auth: sub.auth,
|
|
||||||
p256dh: sub.p256dh,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
match VapidSignatureBuilder::from_pem(
|
|
||||||
std::io::Cursor::new(&web_push_private_key),
|
|
||||||
&subscription,
|
|
||||||
) {
|
|
||||||
Ok(sig_builder) => match sig_builder.build() {
|
|
||||||
Ok(signature) => {
|
|
||||||
let mut builder = WebPushMessageBuilder::new(&subscription);
|
|
||||||
builder.set_vapid_signature(signature);
|
|
||||||
|
|
||||||
let payload = json!(task.payload).to_string();
|
|
||||||
builder
|
|
||||||
.set_payload(ContentEncoding::AesGcm, payload.as_bytes());
|
|
||||||
|
|
||||||
match builder.build() {
|
|
||||||
Ok(msg) => match web_push_client.send(msg).await {
|
|
||||||
Ok(_) => {
|
|
||||||
info!(
|
|
||||||
"Sent Web Push notification to {:?}.",
|
|
||||||
session.id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
error!("Hit error sending Web Push! {:?}", err)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Err(err) => {
|
|
||||||
error!(
|
|
||||||
"Failed to build message for {}! {:?}",
|
|
||||||
session.user_id, err
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => error!(
|
|
||||||
"Failed to build signature for {}! {:?}",
|
|
||||||
session.user_id, err
|
|
||||||
),
|
|
||||||
},
|
|
||||||
Err(err) => error!(
|
|
||||||
"Failed to create signature builder for {}! {:?}",
|
|
||||||
session.user_id, err
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -483,6 +483,7 @@ impl crate::Message {
|
|||||||
edited: self.edited,
|
edited: self.edited,
|
||||||
embeds: self.embeds,
|
embeds: self.embeds,
|
||||||
mentions: self.mentions,
|
mentions: self.mentions,
|
||||||
|
role_mentions: self.role_mentions,
|
||||||
replies: self.replies,
|
replies: self.replies,
|
||||||
reactions: self.reactions,
|
reactions: self.reactions,
|
||||||
interactions: self.interactions.into(),
|
interactions: self.interactions.into(),
|
||||||
@@ -511,6 +512,7 @@ impl From<crate::PartialMessage> for PartialMessage {
|
|||||||
edited: value.edited,
|
edited: value.edited,
|
||||||
embeds: value.embeds,
|
embeds: value.embeds,
|
||||||
mentions: value.mentions,
|
mentions: value.mentions,
|
||||||
|
role_mentions: value.role_mentions,
|
||||||
replies: value.replies,
|
replies: value.replies,
|
||||||
reactions: value.reactions,
|
reactions: value.reactions,
|
||||||
interactions: value.interactions.map(Into::into),
|
interactions: value.interactions.map(Into::into),
|
||||||
@@ -992,6 +994,8 @@ impl crate::User {
|
|||||||
(RelationshipStatus::None, false)
|
(RelationshipStatus::None, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let badges = self.get_badges().await;
|
||||||
|
|
||||||
User {
|
User {
|
||||||
username: self.username,
|
username: self.username,
|
||||||
discriminator: self.discriminator,
|
discriminator: self.discriminator,
|
||||||
@@ -1010,7 +1014,7 @@ impl crate::User {
|
|||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
},
|
},
|
||||||
badges: self.badges.unwrap_or_default() as u32,
|
badges,
|
||||||
online: can_see_profile
|
online: can_see_profile
|
||||||
&& revolt_presence::is_online(&self.id).await
|
&& revolt_presence::is_online(&self.id).await
|
||||||
&& !matches!(
|
&& !matches!(
|
||||||
@@ -1021,7 +1025,7 @@ impl crate::User {
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
status: if can_see_profile {
|
status: if can_see_profile {
|
||||||
self.status.map(|status| status.into())
|
self.status.and_then(|status| status.into(true))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
@@ -1036,7 +1040,7 @@ impl crate::User {
|
|||||||
/// Convert user object into user model assuming mutual connection
|
/// Convert user object into user model assuming mutual connection
|
||||||
///
|
///
|
||||||
/// Relations will never be included, i.e. when we process ourselves
|
/// Relations will never be included, i.e. when we process ourselves
|
||||||
pub fn into_known<'a, P>(self, perspective: P, is_online: bool) -> User
|
pub async fn into_known<'a, P>(self, perspective: P, is_online: bool) -> User
|
||||||
where
|
where
|
||||||
P: Into<Option<&'a crate::User>>,
|
P: Into<Option<&'a crate::User>>,
|
||||||
{
|
{
|
||||||
@@ -1066,13 +1070,15 @@ impl crate::User {
|
|||||||
(RelationshipStatus::None, false)
|
(RelationshipStatus::None, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let badges = self.get_badges().await;
|
||||||
|
|
||||||
User {
|
User {
|
||||||
username: self.username,
|
username: self.username,
|
||||||
discriminator: self.discriminator,
|
discriminator: self.discriminator,
|
||||||
display_name: self.display_name,
|
display_name: self.display_name,
|
||||||
avatar: self.avatar.map(|file| file.into()),
|
avatar: self.avatar.map(|file| file.into()),
|
||||||
relations: vec![],
|
relations: vec![],
|
||||||
badges: self.badges.unwrap_or_default() as u32,
|
badges,
|
||||||
online: can_see_profile
|
online: can_see_profile
|
||||||
&& is_online
|
&& is_online
|
||||||
&& !matches!(
|
&& !matches!(
|
||||||
@@ -1083,7 +1089,7 @@ impl crate::User {
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
status: if can_see_profile {
|
status: if can_see_profile {
|
||||||
self.status.map(|status| status.into())
|
self.status.and_then(|status| status.into(true))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
@@ -1096,14 +1102,16 @@ impl crate::User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convert user object into user model without presence information
|
/// Convert user object into user model without presence information
|
||||||
pub fn into_known_static<'a>(self, is_online: bool) -> User {
|
pub async fn into_known_static<'a>(self, is_online: bool) -> User {
|
||||||
|
let badges = self.get_badges().await;
|
||||||
|
|
||||||
User {
|
User {
|
||||||
username: self.username,
|
username: self.username,
|
||||||
discriminator: self.discriminator,
|
discriminator: self.discriminator,
|
||||||
display_name: self.display_name,
|
display_name: self.display_name,
|
||||||
avatar: self.avatar.map(|file| file.into()),
|
avatar: self.avatar.map(|file| file.into()),
|
||||||
relations: vec![],
|
relations: vec![],
|
||||||
badges: self.badges.unwrap_or_default() as u32,
|
badges,
|
||||||
online: is_online
|
online: is_online
|
||||||
&& !matches!(
|
&& !matches!(
|
||||||
self.status,
|
self.status,
|
||||||
@@ -1112,7 +1120,7 @@ impl crate::User {
|
|||||||
..
|
..
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
status: self.status.map(|status| status.into()),
|
status: self.status.and_then(|status| status.into(true)),
|
||||||
flags: self.flags.unwrap_or_default() as u32,
|
flags: self.flags.unwrap_or_default() as u32,
|
||||||
privileged: self.privileged,
|
privileged: self.privileged,
|
||||||
bot: self.bot.map(|bot| bot.into()),
|
bot: self.bot.map(|bot| bot.into()),
|
||||||
@@ -1122,6 +1130,8 @@ impl crate::User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn into_self(self, force_online: bool) -> User {
|
pub async fn into_self(self, force_online: bool) -> User {
|
||||||
|
let badges = self.get_badges().await;
|
||||||
|
|
||||||
User {
|
User {
|
||||||
username: self.username,
|
username: self.username,
|
||||||
discriminator: self.discriminator,
|
discriminator: self.discriminator,
|
||||||
@@ -1136,7 +1146,7 @@ impl crate::User {
|
|||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
badges: self.badges.unwrap_or_default() as u32,
|
badges,
|
||||||
online: (force_online || revolt_presence::is_online(&self.id).await)
|
online: (force_online || revolt_presence::is_online(&self.id).await)
|
||||||
&& !matches!(
|
&& !matches!(
|
||||||
self.status,
|
self.status,
|
||||||
@@ -1145,7 +1155,7 @@ impl crate::User {
|
|||||||
..
|
..
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
status: self.status.map(|status| status.into()),
|
status: self.status.and_then(|status| status.into(true)),
|
||||||
flags: self.flags.unwrap_or_default() as u32,
|
flags: self.flags.unwrap_or_default() as u32,
|
||||||
privileged: self.privileged,
|
privileged: self.privileged,
|
||||||
bot: self.bot.map(|bot| bot.into()),
|
bot: self.bot.map(|bot| bot.into()),
|
||||||
@@ -1196,7 +1206,7 @@ impl From<crate::PartialUser> for PartialUser {
|
|||||||
.collect()
|
.collect()
|
||||||
}),
|
}),
|
||||||
badges: value.badges.map(|badges| badges as u32),
|
badges: value.badges.map(|badges| badges as u32),
|
||||||
status: value.status.map(|status| status.into()),
|
status: value.status.and_then(|status| status.into(false)),
|
||||||
flags: value.flags.map(|flags| flags as u32),
|
flags: value.flags.map(|flags| flags as u32),
|
||||||
privileged: value.privileged,
|
privileged: value.privileged,
|
||||||
bot: value.bot.map(|bot| bot.into()),
|
bot: value.bot.map(|bot| bot.into()),
|
||||||
@@ -1285,11 +1295,23 @@ impl From<Presence> for crate::Presence {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<crate::UserStatus> for UserStatus {
|
impl crate::UserStatus {
|
||||||
fn from(value: crate::UserStatus) -> Self {
|
fn into(self, discard_invisible: bool) -> Option<UserStatus> {
|
||||||
UserStatus {
|
let status = UserStatus {
|
||||||
text: value.text,
|
text: self.text,
|
||||||
presence: value.presence.map(|presence| presence.into()),
|
presence: self.presence.and_then(|presence| {
|
||||||
|
if discard_invisible && presence == crate::Presence::Invisible {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(presence.into())
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
if status.text.is_none() && status.presence.is_none() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,360 @@
|
|||||||
|
use std::{collections::HashMap, hash::RandomState};
|
||||||
|
|
||||||
|
use revolt_permissions::{
|
||||||
|
ChannelPermission, ChannelType, Override, OverrideField, PermissionValue, ALLOW_IN_TIMEOUT,
|
||||||
|
DEFAULT_PERMISSION_DIRECT_MESSAGE,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{Channel, Database, Member, Server, User};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct BulkDatabasePermissionQuery<'a> {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
database: &'a Database,
|
||||||
|
|
||||||
|
server: Server,
|
||||||
|
channel: Option<Channel>,
|
||||||
|
users: Option<Vec<User>>,
|
||||||
|
members: Option<Vec<Member>>,
|
||||||
|
|
||||||
|
// In case the users or members are fetched as part of the permissions checking operation
|
||||||
|
pub(crate) cached_users: Option<Vec<User>>,
|
||||||
|
pub(crate) cached_members: Option<Vec<Member>>,
|
||||||
|
|
||||||
|
cached_member_perms: Option<HashMap<String, PermissionValue>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'z, 'x> BulkDatabasePermissionQuery<'x> {
|
||||||
|
pub async fn members_can_see_channel(&'z mut self) -> HashMap<String, bool>
|
||||||
|
where
|
||||||
|
'z: 'x,
|
||||||
|
{
|
||||||
|
let member_perms = if self.cached_member_perms.is_some() {
|
||||||
|
// This isn't done as an if let to prevent borrow checker errors with the mut self call when the perms aren't cached.
|
||||||
|
let perms = self.cached_member_perms.as_ref().unwrap();
|
||||||
|
perms
|
||||||
|
.iter()
|
||||||
|
.map(|(m, p)| {
|
||||||
|
(
|
||||||
|
m.clone(),
|
||||||
|
p.has_channel_permission(ChannelPermission::ViewChannel),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
} else {
|
||||||
|
calculate_members_permissions(self)
|
||||||
|
.await
|
||||||
|
.iter()
|
||||||
|
.map(|(m, p)| {
|
||||||
|
(
|
||||||
|
m.clone(),
|
||||||
|
p.has_channel_permission(ChannelPermission::ViewChannel),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
};
|
||||||
|
member_perms
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'z> BulkDatabasePermissionQuery<'z> {
|
||||||
|
pub fn new(database: &Database, server: Server) -> BulkDatabasePermissionQuery<'_> {
|
||||||
|
BulkDatabasePermissionQuery {
|
||||||
|
database,
|
||||||
|
server,
|
||||||
|
channel: None,
|
||||||
|
users: None,
|
||||||
|
members: None,
|
||||||
|
cached_members: None,
|
||||||
|
cached_users: None,
|
||||||
|
cached_member_perms: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn from_server_id<'a>(
|
||||||
|
db: &'a Database,
|
||||||
|
server: &str,
|
||||||
|
) -> BulkDatabasePermissionQuery<'a> {
|
||||||
|
BulkDatabasePermissionQuery {
|
||||||
|
database: db,
|
||||||
|
server: db.fetch_server(server).await.unwrap(),
|
||||||
|
channel: None,
|
||||||
|
users: None,
|
||||||
|
members: None,
|
||||||
|
cached_members: None,
|
||||||
|
cached_users: None,
|
||||||
|
cached_member_perms: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn channel(self, channel: &'z Channel) -> BulkDatabasePermissionQuery {
|
||||||
|
BulkDatabasePermissionQuery {
|
||||||
|
channel: Some(channel.clone()),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn from_channel_id(self, channel_id: String) -> BulkDatabasePermissionQuery<'z> {
|
||||||
|
let channel = self
|
||||||
|
.database
|
||||||
|
.fetch_channel(channel_id.as_str())
|
||||||
|
.await
|
||||||
|
.expect("Valid channel id");
|
||||||
|
|
||||||
|
drop(channel_id);
|
||||||
|
|
||||||
|
BulkDatabasePermissionQuery {
|
||||||
|
channel: Some(channel),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn members(self, members: &'z [Member]) -> BulkDatabasePermissionQuery {
|
||||||
|
BulkDatabasePermissionQuery {
|
||||||
|
members: Some(members.to_owned()),
|
||||||
|
cached_member_perms: None,
|
||||||
|
users: None,
|
||||||
|
cached_members: None,
|
||||||
|
cached_users: None,
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn users(self, users: &'z [User]) -> BulkDatabasePermissionQuery {
|
||||||
|
BulkDatabasePermissionQuery {
|
||||||
|
users: Some(users.to_owned()),
|
||||||
|
cached_member_perms: None,
|
||||||
|
members: None,
|
||||||
|
cached_members: None,
|
||||||
|
cached_users: None,
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the default channel permissions
|
||||||
|
/// Group channel defaults should be mapped to an allow-only override
|
||||||
|
#[allow(dead_code)]
|
||||||
|
async fn get_default_channel_permissions(&mut self) -> Override {
|
||||||
|
if let Some(channel) = &self.channel {
|
||||||
|
match channel {
|
||||||
|
Channel::Group { permissions, .. } => Override {
|
||||||
|
allow: permissions.unwrap_or(*DEFAULT_PERMISSION_DIRECT_MESSAGE as i64) as u64,
|
||||||
|
deny: 0,
|
||||||
|
},
|
||||||
|
Channel::TextChannel {
|
||||||
|
default_permissions,
|
||||||
|
..
|
||||||
|
}
|
||||||
|
| Channel::VoiceChannel {
|
||||||
|
default_permissions,
|
||||||
|
..
|
||||||
|
} => default_permissions.unwrap_or_default().into(),
|
||||||
|
_ => Default::default(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn get_channel_type(&mut self) -> ChannelType {
|
||||||
|
if let Some(channel) = &self.channel {
|
||||||
|
match channel {
|
||||||
|
Channel::DirectMessage { .. } => ChannelType::DirectMessage,
|
||||||
|
Channel::Group { .. } => ChannelType::Group,
|
||||||
|
Channel::SavedMessages { .. } => ChannelType::SavedMessages,
|
||||||
|
Channel::TextChannel { .. } | Channel::VoiceChannel { .. } => {
|
||||||
|
ChannelType::ServerChannel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ChannelType::Unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the ordered role overrides (from lowest to highest) for this member in this channel
|
||||||
|
#[allow(dead_code)]
|
||||||
|
async fn get_channel_role_overrides(&mut self) -> &HashMap<String, OverrideField> {
|
||||||
|
if let Some(channel) = &self.channel {
|
||||||
|
match channel {
|
||||||
|
Channel::TextChannel {
|
||||||
|
role_permissions, ..
|
||||||
|
}
|
||||||
|
| Channel::VoiceChannel {
|
||||||
|
role_permissions, ..
|
||||||
|
} => role_permissions,
|
||||||
|
_ => panic!("Not supported for non-server channels"),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
panic!("No channel added to query")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Calculate members permissions in a server channel.
|
||||||
|
async fn calculate_members_permissions<'a>(
|
||||||
|
query: &'a mut BulkDatabasePermissionQuery<'a>,
|
||||||
|
) -> HashMap<String, PermissionValue> {
|
||||||
|
let mut resp = HashMap::new();
|
||||||
|
|
||||||
|
let (_, channel_role_permissions, channel_default_permissions) = match query
|
||||||
|
.channel
|
||||||
|
.as_ref()
|
||||||
|
.expect("A channel must be assigned to calculate channel permissions")
|
||||||
|
.clone()
|
||||||
|
{
|
||||||
|
Channel::TextChannel {
|
||||||
|
id,
|
||||||
|
role_permissions,
|
||||||
|
default_permissions,
|
||||||
|
..
|
||||||
|
}
|
||||||
|
| Channel::VoiceChannel {
|
||||||
|
id,
|
||||||
|
role_permissions,
|
||||||
|
default_permissions,
|
||||||
|
..
|
||||||
|
} => (id, role_permissions, default_permissions),
|
||||||
|
_ => panic!("Calculation of member permissions must be done on a server channel"),
|
||||||
|
};
|
||||||
|
|
||||||
|
if query.users.is_none() {
|
||||||
|
let ids: Vec<String> = query
|
||||||
|
.members
|
||||||
|
.as_ref()
|
||||||
|
.expect("No users or members added to the query")
|
||||||
|
.iter()
|
||||||
|
.map(|m| m.id.user.clone())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
query.cached_users = Some(
|
||||||
|
query
|
||||||
|
.database
|
||||||
|
.fetch_users(&ids[..])
|
||||||
|
.await
|
||||||
|
.expect("Failed to get data from the db"),
|
||||||
|
);
|
||||||
|
|
||||||
|
query.users = Some(query.cached_users.as_ref().unwrap().to_vec())
|
||||||
|
}
|
||||||
|
|
||||||
|
let users = query.users.as_ref().unwrap();
|
||||||
|
|
||||||
|
if query.members.is_none() {
|
||||||
|
let ids: Vec<String> = query
|
||||||
|
.users
|
||||||
|
.as_ref()
|
||||||
|
.expect("No users or members added to the query")
|
||||||
|
.iter()
|
||||||
|
.map(|m| m.id.clone())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
query.cached_members = Some(
|
||||||
|
query
|
||||||
|
.database
|
||||||
|
.fetch_members(&query.server.id, &ids[..])
|
||||||
|
.await
|
||||||
|
.expect("Failed to get data from the db"),
|
||||||
|
);
|
||||||
|
query.members = Some(query.cached_members.as_ref().unwrap().to_vec())
|
||||||
|
}
|
||||||
|
|
||||||
|
let members: HashMap<&String, &Member, RandomState> = HashMap::from_iter(
|
||||||
|
query
|
||||||
|
.members
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(|m| (&m.id.user, m)),
|
||||||
|
);
|
||||||
|
|
||||||
|
for user in users {
|
||||||
|
let member = members.get(&user.id);
|
||||||
|
|
||||||
|
// User isn't a part of the server
|
||||||
|
if member.is_none() {
|
||||||
|
resp.insert(user.id.clone(), 0_u64.into());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let member = *member.unwrap();
|
||||||
|
|
||||||
|
if user.privileged {
|
||||||
|
resp.insert(
|
||||||
|
user.id.clone(),
|
||||||
|
PermissionValue::from(ChannelPermission::GrantAllSafe),
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.id == query.server.owner {
|
||||||
|
resp.insert(
|
||||||
|
user.id.clone(),
|
||||||
|
PermissionValue::from(ChannelPermission::GrantAllSafe),
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the user's server permissions
|
||||||
|
let mut permission = calculate_server_permissions(&query.server, user, member);
|
||||||
|
|
||||||
|
if let Some(defaults) = channel_default_permissions {
|
||||||
|
permission.apply(defaults.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the applicable role overrides
|
||||||
|
let mut roles = channel_role_permissions
|
||||||
|
.iter()
|
||||||
|
.filter(|(id, _)| member.roles.contains(id))
|
||||||
|
.filter_map(|(id, permission)| {
|
||||||
|
query.server.roles.get(id).map(|role| {
|
||||||
|
let v: Override = (*permission).into();
|
||||||
|
(role.rank, v)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect::<Vec<(i64, Override)>>();
|
||||||
|
|
||||||
|
roles.sort_by(|a, b| b.0.cmp(&a.0));
|
||||||
|
let overrides = roles.into_iter().map(|(_, v)| v);
|
||||||
|
|
||||||
|
for role_override in overrides {
|
||||||
|
permission.apply(role_override)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.insert(user.id.clone(), permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
resp
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Calculates a member's server permissions
|
||||||
|
fn calculate_server_permissions(server: &Server, user: &User, member: &Member) -> PermissionValue {
|
||||||
|
if user.privileged || server.owner == user.id {
|
||||||
|
return ChannelPermission::GrantAllSafe.into();
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut permissions: PermissionValue = server.default_permissions.into();
|
||||||
|
|
||||||
|
let mut roles = server
|
||||||
|
.roles
|
||||||
|
.iter()
|
||||||
|
.filter(|(id, _)| member.roles.contains(id))
|
||||||
|
.map(|(_, role)| {
|
||||||
|
let v: Override = role.permissions.into();
|
||||||
|
(role.rank, v)
|
||||||
|
})
|
||||||
|
.collect::<Vec<(i64, Override)>>();
|
||||||
|
|
||||||
|
roles.sort_by(|a, b| b.0.cmp(&a.0));
|
||||||
|
let role_overrides: Vec<Override> = roles.into_iter().map(|(_, v)| v).collect();
|
||||||
|
|
||||||
|
for role in role_overrides {
|
||||||
|
permissions.apply(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
if member.in_timeout() {
|
||||||
|
permissions.restrict(*ALLOW_IN_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
permissions
|
||||||
|
}
|
||||||
@@ -102,7 +102,7 @@ impl<'r> FromRequest<'r> for IdempotencyKey {
|
|||||||
.map(|k| k.to_string())
|
.map(|k| k.to_string())
|
||||||
{
|
{
|
||||||
if key.len() > 64 {
|
if key.len() > 64 {
|
||||||
return Outcome::Failure((
|
return Outcome::Error((
|
||||||
Status::BadRequest,
|
Status::BadRequest,
|
||||||
create_error!(FailedValidation {
|
create_error!(FailedValidation {
|
||||||
error: "idempotency key too long".to_string(),
|
error: "idempotency key too long".to_string(),
|
||||||
@@ -113,7 +113,7 @@ impl<'r> FromRequest<'r> for IdempotencyKey {
|
|||||||
let idempotency = IdempotencyKey { key };
|
let idempotency = IdempotencyKey { key };
|
||||||
let mut cache = TOKEN_CACHE.lock().await;
|
let mut cache = TOKEN_CACHE.lock().await;
|
||||||
if cache.get(&idempotency.key).is_some() {
|
if cache.get(&idempotency.key).is_some() {
|
||||||
return Outcome::Failure((Status::Conflict, create_error!(DuplicateNonce)));
|
return Outcome::Error((Status::Conflict, create_error!(DuplicateNonce)));
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.put(idempotency.key.clone(), ());
|
cache.put(idempotency.key.clone(), ());
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
pub mod bridge;
|
pub mod bridge;
|
||||||
|
pub mod bulk_permissions;
|
||||||
pub mod idempotency;
|
pub mod idempotency;
|
||||||
pub mod permissions;
|
pub mod permissions;
|
||||||
pub mod reference;
|
pub mod reference;
|
||||||
|
|||||||
@@ -1,464 +1,93 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!-- Compiled with Bootstrap Email version: 1.3.1 -->
|
<!-- Compiled with Bootstrap Email version: 1.5.1 --><meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
<meta name="x-apple-disable-message-reformatting">
|
||||||
<meta name="x-apple-disable-message-reformatting" />
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
|
||||||
<meta
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
name="format-detection"
|
|
||||||
content="telephone=no, date=no, address=no, email=no"
|
|
||||||
/>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body,
|
body,table,td{font-family:Helvetica,Arial,sans-serif !important}.ExternalClass{width:100%}.ExternalClass,.ExternalClass p,.ExternalClass span,.ExternalClass font,.ExternalClass td,.ExternalClass div{line-height:150%}a{text-decoration:none}*{color:inherit}a[x-apple-data-detectors],u+#body a,#MessageViewBody a{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}img{-ms-interpolation-mode:bicubic}table:not([class^=s-]){font-family:Helvetica,Arial,sans-serif;mso-table-lspace:0pt;mso-table-rspace:0pt;border-spacing:0px;border-collapse:collapse}table:not([class^=s-]) td{border-spacing:0px;border-collapse:collapse}@media screen and (max-width: 600px){.w-full,.w-full>tbody>tr>td{width:100% !important}.w-24,.w-24>tbody>tr>td{width:96px !important}.p-lg-10:not(table),.p-lg-10:not(.btn)>tbody>tr>td,.p-lg-10.btn td a{padding:0 !important}.p-3:not(table),.p-3:not(.btn)>tbody>tr>td,.p-3.btn td a{padding:12px !important}.p-6:not(table),.p-6:not(.btn)>tbody>tr>td,.p-6.btn td a{padding:24px !important}*[class*=s-lg-]>tbody>tr>td{font-size:0 !important;line-height:0 !important;height:0 !important}.s-4>tbody>tr>td{font-size:16px !important;line-height:16px !important;height:16px !important}.s-6>tbody>tr>td{font-size:24px !important;line-height:24px !important;height:24px !important}.s-10>tbody>tr>td{font-size:40px !important;line-height:40px !important;height:40px !important}}
|
||||||
table,
|
|
||||||
td {
|
|
||||||
font-family: Helvetica, Arial, sans-serif !important;
|
|
||||||
}
|
|
||||||
.ExternalClass {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.ExternalClass,
|
|
||||||
.ExternalClass p,
|
|
||||||
.ExternalClass span,
|
|
||||||
.ExternalClass font,
|
|
||||||
.ExternalClass td,
|
|
||||||
.ExternalClass div {
|
|
||||||
line-height: 150%;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
* {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
a[x-apple-data-detectors],
|
|
||||||
u + #body a,
|
|
||||||
#MessageViewBody a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: inherit;
|
|
||||||
font-family: inherit;
|
|
||||||
font-weight: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
-ms-interpolation-mode: bicubic;
|
|
||||||
}
|
|
||||||
table:not([class^="s-"]) {
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
mso-table-lspace: 0pt;
|
|
||||||
mso-table-rspace: 0pt;
|
|
||||||
border-spacing: 0px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
table:not([class^="s-"]) td {
|
|
||||||
border-spacing: 0px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 600px) {
|
|
||||||
.w-full,
|
|
||||||
.w-full > tbody > tr > td {
|
|
||||||
width: 100% !important;
|
|
||||||
}
|
|
||||||
.w-24,
|
|
||||||
.w-24 > tbody > tr > td {
|
|
||||||
width: 96px !important;
|
|
||||||
}
|
|
||||||
.p-lg-10:not(table),
|
|
||||||
.p-lg-10:not(.btn) > tbody > tr > td,
|
|
||||||
.p-lg-10.btn td a {
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
|
||||||
.p-3:not(table),
|
|
||||||
.p-3:not(.btn) > tbody > tr > td,
|
|
||||||
.p-3.btn td a {
|
|
||||||
padding: 12px !important;
|
|
||||||
}
|
|
||||||
.p-6:not(table),
|
|
||||||
.p-6:not(.btn) > tbody > tr > td,
|
|
||||||
.p-6.btn td a {
|
|
||||||
padding: 24px !important;
|
|
||||||
}
|
|
||||||
*[class*="s-lg-"] > tbody > tr > td {
|
|
||||||
font-size: 0 !important;
|
|
||||||
line-height: 0 !important;
|
|
||||||
height: 0 !important;
|
|
||||||
}
|
|
||||||
.s-4 > tbody > tr > td {
|
|
||||||
font-size: 16px !important;
|
|
||||||
line-height: 16px !important;
|
|
||||||
height: 16px !important;
|
|
||||||
}
|
|
||||||
.s-6 > tbody > tr > td {
|
|
||||||
font-size: 24px !important;
|
|
||||||
line-height: 24px !important;
|
|
||||||
height: 24px !important;
|
|
||||||
}
|
|
||||||
.s-10 > tbody > tr > td {
|
|
||||||
font-size: 40px !important;
|
|
||||||
line-height: 40px !important;
|
|
||||||
height: 40px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body class="bg-light" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||||
class="bg-light"
|
<table class="bg-light body" valign="top" role="presentation" border="0" cellpadding="0" cellspacing="0" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||||
style="
|
|
||||||
outline: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 24px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 16px;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #000000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="bg-light body"
|
|
||||||
valign="top"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
outline: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 24px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 16px;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #000000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td valign="top" style="line-height: 24px; font-size: 16px; margin: 0;" align="left" bgcolor="#f7fafc">
|
||||||
valign="top"
|
<table class="container" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
|
||||||
style="line-height: 24px; font-size: 16px; margin: 0"
|
|
||||||
align="left"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="container"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td align="center" style="line-height: 24px; font-size: 16px; margin: 0; padding: 0 16px;">
|
||||||
align="center"
|
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0 16px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<!--[if (gte mso 9)|(IE)]>
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
<table align="center" role="presentation">
|
<table align="center" role="presentation">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="600">
|
<td width="600">
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<table
|
<table align="center" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%; max-width: 600px; margin: 0 auto;">
|
||||||
align="center"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%; max-width: 600px; margin: 0 auto"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
style="
|
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="s-10 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||||
style="
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 40px;
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="40"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||||
class="ax-center"
|
|
||||||
role="presentation"
|
|
||||||
align="center"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="margin: 0 auto"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
style="
|
<img alt="Revolt Logo" class="w-24" src="https://app.revolt.chat/assets/logo_round.png" style="height: auto; line-height: 100%; outline: none; text-decoration: none; display: block; width: 96px; border-style: none; border-width: 0;" width="96">
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="Revolt Logo"
|
|
||||||
class="w-24"
|
|
||||||
src="https://app.revolt.chat/assets/logo_round.png"
|
|
||||||
style="
|
|
||||||
height: auto;
|
|
||||||
line-height: 100%;
|
|
||||||
outline: none;
|
|
||||||
text-decoration: none;
|
|
||||||
display: block;
|
|
||||||
width: 96px;
|
|
||||||
border-style: none;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
width="96"
|
|
||||||
/>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-10 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||||
style="
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 40px;
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="40"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="card p-6 p-lg-10 space-y-4" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; width: 100%; overflow: hidden; border: 1px solid #e2e8f0;" bgcolor="#ffffff">
|
||||||
class="card p-6 p-lg-10 space-y-4"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
border-radius: 6px;
|
|
||||||
border-collapse: separate !important;
|
|
||||||
width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid #e2e8f0;
|
|
||||||
"
|
|
||||||
bgcolor="#ffffff"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; width: 100%; margin: 0; padding: 40px;" align="left" bgcolor="#ffffff">
|
||||||
style="
|
<h1 class="h3 fw-700" style="padding-top: 0; padding-bottom: 0; font-weight: 700 !important; vertical-align: baseline; font-size: 28px; line-height: 33.6px; margin: 0;" align="left">Account Deletion</h1>
|
||||||
line-height: 24px;
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 40px;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
bgcolor="#ffffff"
|
|
||||||
>
|
|
||||||
<h1
|
|
||||||
class="h3 fw-700"
|
|
||||||
style="
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 0;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
vertical-align: baseline;
|
|
||||||
font-size: 28px;
|
|
||||||
line-height: 33.6px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
Account Deletion
|
|
||||||
</h1>
|
|
||||||
<table
|
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">
|
||||||
class=""
|
You requested to have your account deleted, if you did not perform
|
||||||
style="
|
this action please take measures to secure your account immediately.
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
You requested to have your account
|
|
||||||
deleted, if you did not perform this
|
|
||||||
action please take measures to secure your
|
|
||||||
account immediately.
|
|
||||||
</p>
|
</p>
|
||||||
<table
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="btn btn-primary p-3 fw-700" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; font-weight: 700 !important;">
|
||||||
class="btn btn-primary p-3 fw-700"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
border-radius: 6px;
|
|
||||||
border-collapse: separate !important;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; border-radius: 6px; font-weight: 700 !important; margin: 0;" align="center" bgcolor="#0d6efd">
|
||||||
style="
|
<a href="{{url}}" style="color: #ffffff; font-size: 16px; font-family: Helvetica, Arial, sans-serif; text-decoration: none; border-radius: 6px; line-height: 20px; display: block; font-weight: 700 !important; white-space: nowrap; background-color: #0d6efd; padding: 12px; border: 1px solid #0d6efd;">Confirm</a>
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="center"
|
|
||||||
bgcolor="#0d6efd"
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="{{url}}"
|
|
||||||
style="
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 16px;
|
|
||||||
font-family: Helvetica, Arial,
|
|
||||||
sans-serif;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
line-height: 20px;
|
|
||||||
display: block;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
white-space: nowrap;
|
|
||||||
background-color: #0d6efd;
|
|
||||||
padding: 12px;
|
|
||||||
border: 1px solid #0d6efd;
|
|
||||||
"
|
|
||||||
>Confirm</a
|
|
||||||
>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -467,66 +96,58 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-6 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 24px;
|
|
||||||
width: 100%;
|
|
||||||
height: 24px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="24"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div
|
<div class="text-muted text-center" style="color: #718096;" align="center">
|
||||||
class="text-muted text-center"
|
This email is intended for {{email}}<br>
|
||||||
style="color: #718096"
|
Sent from Revolt<br>
|
||||||
align="center"
|
|
||||||
>
|
|
||||||
This email is intended for {{email}}<br />
|
|
||||||
Sent from Revolt<br />
|
|
||||||
Made in Europe
|
Made in Europe
|
||||||
</div>
|
</div>
|
||||||
<table
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-6 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
style="
|
 
|
||||||
line-height: 24px;
|
</td>
|
||||||
font-size: 24px;
|
</tr>
|
||||||
width: 100%;
|
</tbody>
|
||||||
height: 24px;
|
</table>
|
||||||
margin: 0;
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
"
|
<tbody>
|
||||||
align="left"
|
<tr>
|
||||||
width="100%"
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
height="24"
|
 
|
||||||
>
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
|
<div class="text-muted text-xs" style="color: #718096; font-size: 12px; line-height: 14.4px;">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br>
|
||||||
|
Registered Company Number: 16260658<br>
|
||||||
|
Registered Office:<br>
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br>
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -25,6 +25,14 @@
|
|||||||
Sent from Revolt<br />
|
Sent from Revolt<br />
|
||||||
Made in Europe
|
Made in Europe
|
||||||
</div>
|
</div>
|
||||||
|
<div class="text-muted text-xs my-6 ax-center">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br />
|
||||||
|
Registered Company Number: 16260658<br />
|
||||||
|
Registered Office:<br />
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br />
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -5,3 +5,10 @@ Please navigate to: {{url}}
|
|||||||
This email is intended for {{email}}
|
This email is intended for {{email}}
|
||||||
Sent by Revolt
|
Sent by Revolt
|
||||||
Made in Europe
|
Made in Europe
|
||||||
|
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the laws of England and Wales.
|
||||||
|
|
||||||
|
Registration Number: 16260658
|
||||||
|
Registered Office:
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
You requested to have your account deleted, if you did not perform this action please take measures to secure your account immediately.
|
||||||
|
|
||||||
|
Please navigate to: {{url}}
|
||||||
|
|
||||||
|
This email is intended for {{email}}
|
||||||
|
|
||||||
|
This email has no association with Revolt or Revolt Platforms Ltd.
|
||||||
|
Learn more about third party instances here:
|
||||||
|
https://developers.revolt.chat/faq.html
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<style>
|
||||||
|
/* Add custom classes and styles that you want inlined here */
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="bg-light">
|
||||||
|
<div class="container">
|
||||||
|
<img
|
||||||
|
alt="Revolt Logo"
|
||||||
|
class="ax-center my-10 w-24"
|
||||||
|
src="https://app.revolt.chat/assets/logo_round.png"
|
||||||
|
/>
|
||||||
|
<div class="card p-6 p-lg-10 space-y-4">
|
||||||
|
<h1 class="h3 fw-700">Notice of Terms & Policy Change</h1>
|
||||||
|
<p>
|
||||||
|
This email is to notify you that we're updating all of our policy
|
||||||
|
documents.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
You can read our updated Terms of Service and Privacy Policy below:<br />
|
||||||
|
Effective. 24th March 2025
|
||||||
|
</p>
|
||||||
|
<a class="p-3 fw-700" href="https://revolt.chat/terms"
|
||||||
|
>Terms of Service</a
|
||||||
|
>
|
||||||
|
<a class="p-3 fw-700" href="https://revolt.chat/terms"
|
||||||
|
>Privacy Policy</a
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
Our Community Guidelines have also been updated to help us better
|
||||||
|
protect and safeguard the platform. You can check them out here:
|
||||||
|
</p>
|
||||||
|
<a class="p-3 fw-700" href="https://revolt.chat/terms"
|
||||||
|
>Community Guidelines</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="text-muted text-center my-6">
|
||||||
|
Sent by Revolt<br />
|
||||||
|
Made in Europe
|
||||||
|
</div>
|
||||||
|
<div class="text-muted text-xs my-6 ax-center">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br />
|
||||||
|
Registered Company Number: 16260658<br />
|
||||||
|
Registered Office:<br />
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br />
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,462 +1,90 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!-- Compiled with Bootstrap Email version: 1.3.1 -->
|
<!-- Compiled with Bootstrap Email version: 1.5.1 --><meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
<meta name="x-apple-disable-message-reformatting">
|
||||||
<meta name="x-apple-disable-message-reformatting" />
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
|
||||||
<meta
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
name="format-detection"
|
|
||||||
content="telephone=no, date=no, address=no, email=no"
|
|
||||||
/>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body,
|
body,table,td{font-family:Helvetica,Arial,sans-serif !important}.ExternalClass{width:100%}.ExternalClass,.ExternalClass p,.ExternalClass span,.ExternalClass font,.ExternalClass td,.ExternalClass div{line-height:150%}a{text-decoration:none}*{color:inherit}a[x-apple-data-detectors],u+#body a,#MessageViewBody a{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}img{-ms-interpolation-mode:bicubic}table:not([class^=s-]){font-family:Helvetica,Arial,sans-serif;mso-table-lspace:0pt;mso-table-rspace:0pt;border-spacing:0px;border-collapse:collapse}table:not([class^=s-]) td{border-spacing:0px;border-collapse:collapse}@media screen and (max-width: 600px){.w-full,.w-full>tbody>tr>td{width:100% !important}.w-24,.w-24>tbody>tr>td{width:96px !important}.p-lg-10:not(table),.p-lg-10:not(.btn)>tbody>tr>td,.p-lg-10.btn td a{padding:0 !important}.p-3:not(table),.p-3:not(.btn)>tbody>tr>td,.p-3.btn td a{padding:12px !important}.p-6:not(table),.p-6:not(.btn)>tbody>tr>td,.p-6.btn td a{padding:24px !important}*[class*=s-lg-]>tbody>tr>td{font-size:0 !important;line-height:0 !important;height:0 !important}.s-4>tbody>tr>td{font-size:16px !important;line-height:16px !important;height:16px !important}.s-6>tbody>tr>td{font-size:24px !important;line-height:24px !important;height:24px !important}.s-10>tbody>tr>td{font-size:40px !important;line-height:40px !important;height:40px !important}}
|
||||||
table,
|
|
||||||
td {
|
|
||||||
font-family: Helvetica, Arial, sans-serif !important;
|
|
||||||
}
|
|
||||||
.ExternalClass {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.ExternalClass,
|
|
||||||
.ExternalClass p,
|
|
||||||
.ExternalClass span,
|
|
||||||
.ExternalClass font,
|
|
||||||
.ExternalClass td,
|
|
||||||
.ExternalClass div {
|
|
||||||
line-height: 150%;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
* {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
a[x-apple-data-detectors],
|
|
||||||
u + #body a,
|
|
||||||
#MessageViewBody a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: inherit;
|
|
||||||
font-family: inherit;
|
|
||||||
font-weight: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
-ms-interpolation-mode: bicubic;
|
|
||||||
}
|
|
||||||
table:not([class^="s-"]) {
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
mso-table-lspace: 0pt;
|
|
||||||
mso-table-rspace: 0pt;
|
|
||||||
border-spacing: 0px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
table:not([class^="s-"]) td {
|
|
||||||
border-spacing: 0px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 600px) {
|
|
||||||
.w-full,
|
|
||||||
.w-full > tbody > tr > td {
|
|
||||||
width: 100% !important;
|
|
||||||
}
|
|
||||||
.w-24,
|
|
||||||
.w-24 > tbody > tr > td {
|
|
||||||
width: 96px !important;
|
|
||||||
}
|
|
||||||
.p-lg-10:not(table),
|
|
||||||
.p-lg-10:not(.btn) > tbody > tr > td,
|
|
||||||
.p-lg-10.btn td a {
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
|
||||||
.p-3:not(table),
|
|
||||||
.p-3:not(.btn) > tbody > tr > td,
|
|
||||||
.p-3.btn td a {
|
|
||||||
padding: 12px !important;
|
|
||||||
}
|
|
||||||
.p-6:not(table),
|
|
||||||
.p-6:not(.btn) > tbody > tr > td,
|
|
||||||
.p-6.btn td a {
|
|
||||||
padding: 24px !important;
|
|
||||||
}
|
|
||||||
*[class*="s-lg-"] > tbody > tr > td {
|
|
||||||
font-size: 0 !important;
|
|
||||||
line-height: 0 !important;
|
|
||||||
height: 0 !important;
|
|
||||||
}
|
|
||||||
.s-4 > tbody > tr > td {
|
|
||||||
font-size: 16px !important;
|
|
||||||
line-height: 16px !important;
|
|
||||||
height: 16px !important;
|
|
||||||
}
|
|
||||||
.s-6 > tbody > tr > td {
|
|
||||||
font-size: 24px !important;
|
|
||||||
line-height: 24px !important;
|
|
||||||
height: 24px !important;
|
|
||||||
}
|
|
||||||
.s-10 > tbody > tr > td {
|
|
||||||
font-size: 40px !important;
|
|
||||||
line-height: 40px !important;
|
|
||||||
height: 40px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body class="bg-light" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||||
class="bg-light"
|
<table class="bg-light body" valign="top" role="presentation" border="0" cellpadding="0" cellspacing="0" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||||
style="
|
|
||||||
outline: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 24px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 16px;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #000000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="bg-light body"
|
|
||||||
valign="top"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
outline: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 24px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 16px;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #000000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td valign="top" style="line-height: 24px; font-size: 16px; margin: 0;" align="left" bgcolor="#f7fafc">
|
||||||
valign="top"
|
<table class="container" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
|
||||||
style="line-height: 24px; font-size: 16px; margin: 0"
|
|
||||||
align="left"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="container"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td align="center" style="line-height: 24px; font-size: 16px; margin: 0; padding: 0 16px;">
|
||||||
align="center"
|
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0 16px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<!--[if (gte mso 9)|(IE)]>
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
<table align="center" role="presentation">
|
<table align="center" role="presentation">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="600">
|
<td width="600">
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<table
|
<table align="center" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%; max-width: 600px; margin: 0 auto;">
|
||||||
align="center"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%; max-width: 600px; margin: 0 auto"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
style="
|
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="s-10 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||||
style="
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 40px;
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="40"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||||
class="ax-center"
|
|
||||||
role="presentation"
|
|
||||||
align="center"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="margin: 0 auto"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
style="
|
<img class="w-24" src="https://app.revolt.chat/assets/logo_round.png" style="height: auto; line-height: 100%; outline: none; text-decoration: none; display: block; width: 96px; border-style: none; border-width: 0;" width="96">
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="Revolt Logo"
|
|
||||||
class="w-24"
|
|
||||||
src="https://app.revolt.chat/assets/logo_round.png"
|
|
||||||
style="
|
|
||||||
height: auto;
|
|
||||||
line-height: 100%;
|
|
||||||
outline: none;
|
|
||||||
text-decoration: none;
|
|
||||||
display: block;
|
|
||||||
width: 96px;
|
|
||||||
border-style: none;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
width="96"
|
|
||||||
/>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-10 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||||
style="
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 40px;
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="40"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="card p-6 p-lg-10 space-y-4" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; width: 100%; overflow: hidden; border: 1px solid #e2e8f0;" bgcolor="#ffffff">
|
||||||
class="card p-6 p-lg-10 space-y-4"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
border-radius: 6px;
|
|
||||||
border-collapse: separate !important;
|
|
||||||
width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid #e2e8f0;
|
|
||||||
"
|
|
||||||
bgcolor="#ffffff"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; width: 100%; margin: 0; padding: 40px;" align="left" bgcolor="#ffffff">
|
||||||
style="
|
<h1 class="h3 fw-700" style="padding-top: 0; padding-bottom: 0; font-weight: 700 !important; vertical-align: baseline; font-size: 28px; line-height: 33.6px; margin: 0;" align="left">Password Reset</h1>
|
||||||
line-height: 24px;
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 40px;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
bgcolor="#ffffff"
|
|
||||||
>
|
|
||||||
<h1
|
|
||||||
class="h3 fw-700"
|
|
||||||
style="
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 0;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
vertical-align: baseline;
|
|
||||||
font-size: 28px;
|
|
||||||
line-height: 33.6px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
Password Reset
|
|
||||||
</h1>
|
|
||||||
<table
|
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">You requested a password reset, click below to continue.</p>
|
||||||
class=""
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
You requested a password reset, click
|
|
||||||
below to continue.
|
|
||||||
</p>
|
|
||||||
<table
|
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="btn btn-primary p-3 fw-700" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; font-weight: 700 !important;">
|
||||||
class="btn btn-primary p-3 fw-700"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
border-radius: 6px;
|
|
||||||
border-collapse: separate !important;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; border-radius: 6px; font-weight: 700 !important; margin: 0;" align="center" bgcolor="#0d6efd">
|
||||||
style="
|
<a href="{{url}}" style="color: #ffffff; font-size: 16px; font-family: Helvetica, Arial, sans-serif; text-decoration: none; border-radius: 6px; line-height: 20px; display: block; font-weight: 700 !important; white-space: nowrap; background-color: #0d6efd; padding: 12px; border: 1px solid #0d6efd;">Reset</a>
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="center"
|
|
||||||
bgcolor="#0d6efd"
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="{{url}}"
|
|
||||||
style="
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 16px;
|
|
||||||
font-family: Helvetica, Arial,
|
|
||||||
sans-serif;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
line-height: 20px;
|
|
||||||
display: block;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
white-space: nowrap;
|
|
||||||
background-color: #0d6efd;
|
|
||||||
padding: 12px;
|
|
||||||
border: 1px solid #0d6efd;
|
|
||||||
"
|
|
||||||
>Reset</a
|
|
||||||
>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -465,66 +93,58 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-6 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 24px;
|
|
||||||
width: 100%;
|
|
||||||
height: 24px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="24"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div
|
<div class="text-muted text-center" style="color: #718096;" align="center">
|
||||||
class="text-muted text-center"
|
This email is intended for {{email}}<br>
|
||||||
style="color: #718096"
|
Sent from Revolt<br>
|
||||||
align="center"
|
|
||||||
>
|
|
||||||
This email is intended for {{email}}<br />
|
|
||||||
Sent from Revolt<br />
|
|
||||||
Made in Europe
|
Made in Europe
|
||||||
</div>
|
</div>
|
||||||
<table
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-6 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
style="
|
 
|
||||||
line-height: 24px;
|
</td>
|
||||||
font-size: 24px;
|
</tr>
|
||||||
width: 100%;
|
</tbody>
|
||||||
height: 24px;
|
</table>
|
||||||
margin: 0;
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
"
|
<tbody>
|
||||||
align="left"
|
<tr>
|
||||||
width="100%"
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
height="24"
|
 
|
||||||
>
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
|
<div class="text-muted text-xs" style="color: #718096; font-size: 12px; line-height: 14.4px;">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br>
|
||||||
|
Registered Company Number: 16260658<br>
|
||||||
|
Registered Office:<br>
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br>
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -21,6 +21,14 @@
|
|||||||
Sent from Revolt<br />
|
Sent from Revolt<br />
|
||||||
Made in Europe
|
Made in Europe
|
||||||
</div>
|
</div>
|
||||||
|
<div class="text-muted text-xs my-6 ax-center">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br />
|
||||||
|
Registered Company Number: 16260658<br />
|
||||||
|
Registered Office:<br />
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br />
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -5,3 +5,10 @@ Please navigate to: {{url}}
|
|||||||
This email is intended for {{email}}
|
This email is intended for {{email}}
|
||||||
Sent by Revolt
|
Sent by Revolt
|
||||||
Made in Europe
|
Made in Europe
|
||||||
|
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the laws of England and Wales.
|
||||||
|
|
||||||
|
Registration Number: 16260658
|
||||||
|
Registered Office:
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
You requested a password reset, if you did not perform this action you can safely ignore this email.
|
||||||
|
|
||||||
|
Please navigate to: {{url}}
|
||||||
|
|
||||||
|
This email is intended for {{email}}
|
||||||
|
|
||||||
|
This email has no association with Revolt or Revolt Platforms Ltd.
|
||||||
|
Learn more about third party instances here:
|
||||||
|
https://developers.revolt.chat/faq.html
|
||||||
@@ -1,408 +1,80 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!-- Compiled with Bootstrap Email version: 1.5.1 -->
|
<!-- Compiled with Bootstrap Email version: 1.5.1 --><meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
<meta name="x-apple-disable-message-reformatting">
|
||||||
<meta name="x-apple-disable-message-reformatting" />
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
|
||||||
<meta
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
name="format-detection"
|
|
||||||
content="telephone=no, date=no, address=no, email=no"
|
|
||||||
/>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body,
|
body,table,td{font-family:Helvetica,Arial,sans-serif !important}.ExternalClass{width:100%}.ExternalClass,.ExternalClass p,.ExternalClass span,.ExternalClass font,.ExternalClass td,.ExternalClass div{line-height:150%}a{text-decoration:none}*{color:inherit}a[x-apple-data-detectors],u+#body a,#MessageViewBody a{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}img{-ms-interpolation-mode:bicubic}table:not([class^=s-]){font-family:Helvetica,Arial,sans-serif;mso-table-lspace:0pt;mso-table-rspace:0pt;border-spacing:0px;border-collapse:collapse}table:not([class^=s-]) td{border-spacing:0px;border-collapse:collapse}@media screen and (max-width: 600px){.w-full,.w-full>tbody>tr>td{width:100% !important}.w-24,.w-24>tbody>tr>td{width:96px !important}.p-lg-10:not(table),.p-lg-10:not(.btn)>tbody>tr>td,.p-lg-10.btn td a{padding:0 !important}.p-6:not(table),.p-6:not(.btn)>tbody>tr>td,.p-6.btn td a{padding:24px !important}*[class*=s-lg-]>tbody>tr>td{font-size:0 !important;line-height:0 !important;height:0 !important}.s-4>tbody>tr>td{font-size:16px !important;line-height:16px !important;height:16px !important}.s-6>tbody>tr>td{font-size:24px !important;line-height:24px !important;height:24px !important}.s-10>tbody>tr>td{font-size:40px !important;line-height:40px !important;height:40px !important}}
|
||||||
table,
|
|
||||||
td {
|
|
||||||
font-family: Helvetica, Arial, sans-serif !important;
|
|
||||||
}
|
|
||||||
.ExternalClass {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.ExternalClass,
|
|
||||||
.ExternalClass p,
|
|
||||||
.ExternalClass span,
|
|
||||||
.ExternalClass font,
|
|
||||||
.ExternalClass td,
|
|
||||||
.ExternalClass div {
|
|
||||||
line-height: 150%;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
* {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
a[x-apple-data-detectors],
|
|
||||||
u + #body a,
|
|
||||||
#MessageViewBody a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: inherit;
|
|
||||||
font-family: inherit;
|
|
||||||
font-weight: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
-ms-interpolation-mode: bicubic;
|
|
||||||
}
|
|
||||||
table:not([class^="s-"]) {
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
mso-table-lspace: 0pt;
|
|
||||||
mso-table-rspace: 0pt;
|
|
||||||
border-spacing: 0px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
table:not([class^="s-"]) td {
|
|
||||||
border-spacing: 0px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 600px) {
|
|
||||||
.w-full,
|
|
||||||
.w-full > tbody > tr > td {
|
|
||||||
width: 100% !important;
|
|
||||||
}
|
|
||||||
.w-24,
|
|
||||||
.w-24 > tbody > tr > td {
|
|
||||||
width: 96px !important;
|
|
||||||
}
|
|
||||||
.p-lg-10:not(table),
|
|
||||||
.p-lg-10:not(.btn) > tbody > tr > td,
|
|
||||||
.p-lg-10.btn td a {
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
|
||||||
.p-6:not(table),
|
|
||||||
.p-6:not(.btn) > tbody > tr > td,
|
|
||||||
.p-6.btn td a {
|
|
||||||
padding: 24px !important;
|
|
||||||
}
|
|
||||||
*[class*="s-lg-"] > tbody > tr > td {
|
|
||||||
font-size: 0 !important;
|
|
||||||
line-height: 0 !important;
|
|
||||||
height: 0 !important;
|
|
||||||
}
|
|
||||||
.s-4 > tbody > tr > td {
|
|
||||||
font-size: 16px !important;
|
|
||||||
line-height: 16px !important;
|
|
||||||
height: 16px !important;
|
|
||||||
}
|
|
||||||
.s-6 > tbody > tr > td {
|
|
||||||
font-size: 24px !important;
|
|
||||||
line-height: 24px !important;
|
|
||||||
height: 24px !important;
|
|
||||||
}
|
|
||||||
.s-10 > tbody > tr > td {
|
|
||||||
font-size: 40px !important;
|
|
||||||
line-height: 40px !important;
|
|
||||||
height: 40px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body class="bg-light" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||||
class="bg-light"
|
<table class="bg-light body" valign="top" role="presentation" border="0" cellpadding="0" cellspacing="0" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||||
style="
|
|
||||||
outline: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 24px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 16px;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #000000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="bg-light body"
|
|
||||||
valign="top"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
outline: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 24px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 16px;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #000000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td valign="top" style="line-height: 24px; font-size: 16px; margin: 0;" align="left" bgcolor="#f7fafc">
|
||||||
valign="top"
|
<table class="container" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
|
||||||
style="line-height: 24px; font-size: 16px; margin: 0"
|
|
||||||
align="left"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="container"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td align="center" style="line-height: 24px; font-size: 16px; margin: 0; padding: 0 16px;">
|
||||||
align="center"
|
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0 16px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<!--[if (gte mso 9)|(IE)]>
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
<table align="center" role="presentation">
|
<table align="center" role="presentation">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="600">
|
<td width="600">
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<table
|
<table align="center" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%; max-width: 600px; margin: 0 auto;">
|
||||||
align="center"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%; max-width: 600px; margin: 0 auto"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
style="
|
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="s-10 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||||
style="
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 40px;
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="40"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||||
class="ax-center"
|
|
||||||
role="presentation"
|
|
||||||
align="center"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="margin: 0 auto"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
style="
|
<img alt="Revolt Logo" class="w-24" src="https://app.revolt.chat/assets/logo_round.png" style="height: auto; line-height: 100%; outline: none; text-decoration: none; display: block; width: 96px; border-style: none; border-width: 0;" width="96">
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="Revolt Logo"
|
|
||||||
class="w-24"
|
|
||||||
src="https://app.revolt.chat/assets/logo_round.png"
|
|
||||||
style="
|
|
||||||
height: auto;
|
|
||||||
line-height: 100%;
|
|
||||||
outline: none;
|
|
||||||
text-decoration: none;
|
|
||||||
display: block;
|
|
||||||
width: 96px;
|
|
||||||
border-style: none;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
width="96"
|
|
||||||
/>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-10 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||||
style="
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 40px;
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="40"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="card p-6 p-lg-10 space-y-4" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; width: 100%; overflow: hidden; border: 1px solid #e2e8f0;" bgcolor="#ffffff">
|
||||||
class="card p-6 p-lg-10 space-y-4"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
border-radius: 6px;
|
|
||||||
border-collapse: separate !important;
|
|
||||||
width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid #e2e8f0;
|
|
||||||
"
|
|
||||||
bgcolor="#ffffff"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; width: 100%; margin: 0; padding: 40px;" align="left" bgcolor="#ffffff">
|
||||||
style="
|
<h1 class="h3 fw-700" style="padding-top: 0; padding-bottom: 0; font-weight: 700 !important; vertical-align: baseline; font-size: 28px; line-height: 33.6px; margin: 0;" align="left">Account Suspended</h1>
|
||||||
line-height: 24px;
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 40px;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
bgcolor="#ffffff"
|
|
||||||
>
|
|
||||||
<h1
|
|
||||||
class="h3 fw-700"
|
|
||||||
style="
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 0;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
vertical-align: baseline;
|
|
||||||
font-size: 28px;
|
|
||||||
line-height: 33.6px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
Account Suspended
|
|
||||||
</h1>
|
|
||||||
<table
|
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">Your account has been suspended, for one or more reasons:</p>
|
||||||
class=""
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
Your account has been suspended, for one
|
|
||||||
or more reasons:
|
|
||||||
</p>
|
|
||||||
<table
|
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -411,193 +83,98 @@
|
|||||||
<ul class="">
|
<ul class="">
|
||||||
{{list}}
|
{{list}}
|
||||||
</ul>
|
</ul>
|
||||||
<table
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
<p style="display: {{duration_display}}; line-height: 24px; font-size: 16px; width: 100%; margin: 0;" class="" align="left">
|
||||||
style="display: {{duration_display}}; line-height: 24px; font-size: 16px; width: 100%; margin: 0;"
|
You will be able to use your account again in {{duration}} days.
|
||||||
class=""
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
You will be able to use your account again
|
|
||||||
in {{duration}} days.
|
|
||||||
</p>
|
</p>
|
||||||
<table
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">
|
||||||
class=""
|
Further violations may result in a permanent ban depending on
|
||||||
style="
|
severity, please abide by the
|
||||||
line-height: 24px;
|
<a href="https://revolt.chat/aup" style="color: #0d6efd;">Acceptable Usage Policy</a>.
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
Further violations may result in a
|
|
||||||
permanent ban depending on severity,
|
|
||||||
please abide by the
|
|
||||||
<a
|
|
||||||
href="https://revolt.chat/aup"
|
|
||||||
style="color: #0d6efd"
|
|
||||||
>Acceptable Usage Policy</a
|
|
||||||
>.
|
|
||||||
</p>
|
</p>
|
||||||
<table
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
<p style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">Ban evasion is prohibited and will be dealt with accordingly.</p>
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
Ban evasion is prohibited and will be
|
|
||||||
dealt with accordingly.
|
|
||||||
</p>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-6 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 24px;
|
|
||||||
width: 100%;
|
|
||||||
height: 24px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="24"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div
|
<div class="text-muted text-center" style="color: #718096;" align="center">
|
||||||
class="text-muted text-center"
|
This email is intended for {{email}}<br>
|
||||||
style="color: #718096"
|
Sent from Revolt<br>
|
||||||
align="center"
|
|
||||||
>
|
|
||||||
This email is intended for {{email}}<br />
|
|
||||||
Sent from Revolt<br />
|
|
||||||
Made in Europe
|
Made in Europe
|
||||||
</div>
|
</div>
|
||||||
<table
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-6 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
style="
|
 
|
||||||
line-height: 24px;
|
</td>
|
||||||
font-size: 24px;
|
</tr>
|
||||||
width: 100%;
|
</tbody>
|
||||||
height: 24px;
|
</table>
|
||||||
margin: 0;
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
"
|
<tbody>
|
||||||
align="left"
|
<tr>
|
||||||
width="100%"
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
height="24"
|
 
|
||||||
>
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
|
<div class="text-muted text-xs" style="color: #718096; font-size: 12px; line-height: 14.4px;">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br>
|
||||||
|
Registered Company Number: 16260658<br>
|
||||||
|
Registered Office:<br>
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br>
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -33,6 +33,14 @@
|
|||||||
Sent from Revolt<br />
|
Sent from Revolt<br />
|
||||||
Made in Europe
|
Made in Europe
|
||||||
</div>
|
</div>
|
||||||
|
<div class="text-muted text-xs my-6 ax-center">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br />
|
||||||
|
Registered Company Number: 16260658<br />
|
||||||
|
Registered Office:<br />
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br />
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -10,3 +10,10 @@ Ban evasion is prohibited and will be dealt with accordingly.
|
|||||||
This email is intended for {{email}}
|
This email is intended for {{email}}
|
||||||
Sent by Revolt
|
Sent by Revolt
|
||||||
Made in Europe
|
Made in Europe
|
||||||
|
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the laws of England and Wales.
|
||||||
|
|
||||||
|
Registration Number: 16260658
|
||||||
|
Registered Office:
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Your account has been suspended, for one or more reasons:
|
||||||
|
{{list}}
|
||||||
|
|
||||||
|
This email is intended for {{email}}
|
||||||
|
|
||||||
|
This email has no association with Revolt or Revolt Platforms Ltd.
|
||||||
|
Learn more about third party instances here:
|
||||||
|
https://developers.revolt.chat/faq.html
|
||||||
@@ -1,462 +1,90 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!-- Compiled with Bootstrap Email version: 1.3.1 -->
|
<!-- Compiled with Bootstrap Email version: 1.5.1 --><meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
<meta name="x-apple-disable-message-reformatting">
|
||||||
<meta name="x-apple-disable-message-reformatting" />
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
|
||||||
<meta
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
name="format-detection"
|
|
||||||
content="telephone=no, date=no, address=no, email=no"
|
|
||||||
/>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body,
|
body,table,td{font-family:Helvetica,Arial,sans-serif !important}.ExternalClass{width:100%}.ExternalClass,.ExternalClass p,.ExternalClass span,.ExternalClass font,.ExternalClass td,.ExternalClass div{line-height:150%}a{text-decoration:none}*{color:inherit}a[x-apple-data-detectors],u+#body a,#MessageViewBody a{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}img{-ms-interpolation-mode:bicubic}table:not([class^=s-]){font-family:Helvetica,Arial,sans-serif;mso-table-lspace:0pt;mso-table-rspace:0pt;border-spacing:0px;border-collapse:collapse}table:not([class^=s-]) td{border-spacing:0px;border-collapse:collapse}@media screen and (max-width: 600px){.w-full,.w-full>tbody>tr>td{width:100% !important}.w-24,.w-24>tbody>tr>td{width:96px !important}.p-lg-10:not(table),.p-lg-10:not(.btn)>tbody>tr>td,.p-lg-10.btn td a{padding:0 !important}.p-3:not(table),.p-3:not(.btn)>tbody>tr>td,.p-3.btn td a{padding:12px !important}.p-6:not(table),.p-6:not(.btn)>tbody>tr>td,.p-6.btn td a{padding:24px !important}*[class*=s-lg-]>tbody>tr>td{font-size:0 !important;line-height:0 !important;height:0 !important}.s-4>tbody>tr>td{font-size:16px !important;line-height:16px !important;height:16px !important}.s-6>tbody>tr>td{font-size:24px !important;line-height:24px !important;height:24px !important}.s-10>tbody>tr>td{font-size:40px !important;line-height:40px !important;height:40px !important}}
|
||||||
table,
|
|
||||||
td {
|
|
||||||
font-family: Helvetica, Arial, sans-serif !important;
|
|
||||||
}
|
|
||||||
.ExternalClass {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.ExternalClass,
|
|
||||||
.ExternalClass p,
|
|
||||||
.ExternalClass span,
|
|
||||||
.ExternalClass font,
|
|
||||||
.ExternalClass td,
|
|
||||||
.ExternalClass div {
|
|
||||||
line-height: 150%;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
* {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
a[x-apple-data-detectors],
|
|
||||||
u + #body a,
|
|
||||||
#MessageViewBody a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: inherit;
|
|
||||||
font-family: inherit;
|
|
||||||
font-weight: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
-ms-interpolation-mode: bicubic;
|
|
||||||
}
|
|
||||||
table:not([class^="s-"]) {
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
mso-table-lspace: 0pt;
|
|
||||||
mso-table-rspace: 0pt;
|
|
||||||
border-spacing: 0px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
table:not([class^="s-"]) td {
|
|
||||||
border-spacing: 0px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 600px) {
|
|
||||||
.w-full,
|
|
||||||
.w-full > tbody > tr > td {
|
|
||||||
width: 100% !important;
|
|
||||||
}
|
|
||||||
.w-24,
|
|
||||||
.w-24 > tbody > tr > td {
|
|
||||||
width: 96px !important;
|
|
||||||
}
|
|
||||||
.p-lg-10:not(table),
|
|
||||||
.p-lg-10:not(.btn) > tbody > tr > td,
|
|
||||||
.p-lg-10.btn td a {
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
|
||||||
.p-3:not(table),
|
|
||||||
.p-3:not(.btn) > tbody > tr > td,
|
|
||||||
.p-3.btn td a {
|
|
||||||
padding: 12px !important;
|
|
||||||
}
|
|
||||||
.p-6:not(table),
|
|
||||||
.p-6:not(.btn) > tbody > tr > td,
|
|
||||||
.p-6.btn td a {
|
|
||||||
padding: 24px !important;
|
|
||||||
}
|
|
||||||
*[class*="s-lg-"] > tbody > tr > td {
|
|
||||||
font-size: 0 !important;
|
|
||||||
line-height: 0 !important;
|
|
||||||
height: 0 !important;
|
|
||||||
}
|
|
||||||
.s-4 > tbody > tr > td {
|
|
||||||
font-size: 16px !important;
|
|
||||||
line-height: 16px !important;
|
|
||||||
height: 16px !important;
|
|
||||||
}
|
|
||||||
.s-6 > tbody > tr > td {
|
|
||||||
font-size: 24px !important;
|
|
||||||
line-height: 24px !important;
|
|
||||||
height: 24px !important;
|
|
||||||
}
|
|
||||||
.s-10 > tbody > tr > td {
|
|
||||||
font-size: 40px !important;
|
|
||||||
line-height: 40px !important;
|
|
||||||
height: 40px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body class="bg-light" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||||
class="bg-light"
|
<table class="bg-light body" valign="top" role="presentation" border="0" cellpadding="0" cellspacing="0" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||||
style="
|
|
||||||
outline: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 24px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 16px;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #000000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="bg-light body"
|
|
||||||
valign="top"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
outline: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 24px;
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 16px;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #000000;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td valign="top" style="line-height: 24px; font-size: 16px; margin: 0;" align="left" bgcolor="#f7fafc">
|
||||||
valign="top"
|
<table class="container" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
|
||||||
style="line-height: 24px; font-size: 16px; margin: 0"
|
|
||||||
align="left"
|
|
||||||
bgcolor="#f7fafc"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="container"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td align="center" style="line-height: 24px; font-size: 16px; margin: 0; padding: 0 16px;">
|
||||||
align="center"
|
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0 16px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<!--[if (gte mso 9)|(IE)]>
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
<table align="center" role="presentation">
|
<table align="center" role="presentation">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="600">
|
<td width="600">
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<table
|
<table align="center" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%; max-width: 600px; margin: 0 auto;">
|
||||||
align="center"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%; max-width: 600px; margin: 0 auto"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
style="
|
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<table
|
|
||||||
class="s-10 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||||
style="
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 40px;
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="40"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||||
class="ax-center"
|
|
||||||
role="presentation"
|
|
||||||
align="center"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="margin: 0 auto"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
style="
|
<img alt="Revolt Logo" class="w-24" src="https://app.revolt.chat/assets/logo_round.png" style="height: auto; line-height: 100%; outline: none; text-decoration: none; display: block; width: 96px; border-style: none; border-width: 0;" width="96">
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="Revolt Logo"
|
|
||||||
class="w-24"
|
|
||||||
src="https://app.revolt.chat/assets/logo_round.png"
|
|
||||||
style="
|
|
||||||
height: auto;
|
|
||||||
line-height: 100%;
|
|
||||||
outline: none;
|
|
||||||
text-decoration: none;
|
|
||||||
display: block;
|
|
||||||
width: 96px;
|
|
||||||
border-style: none;
|
|
||||||
border-width: 0;
|
|
||||||
"
|
|
||||||
width="96"
|
|
||||||
/>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-10 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||||
style="
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 40px;
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="40"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="card p-6 p-lg-10 space-y-4" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; width: 100%; overflow: hidden; border: 1px solid #e2e8f0;" bgcolor="#ffffff">
|
||||||
class="card p-6 p-lg-10 space-y-4"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
border-radius: 6px;
|
|
||||||
border-collapse: separate !important;
|
|
||||||
width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid #e2e8f0;
|
|
||||||
"
|
|
||||||
bgcolor="#ffffff"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; width: 100%; margin: 0; padding: 40px;" align="left" bgcolor="#ffffff">
|
||||||
style="
|
<h1 class="h3 fw-700" style="padding-top: 0; padding-bottom: 0; font-weight: 700 !important; vertical-align: baseline; font-size: 28px; line-height: 33.6px; margin: 0;" align="left">Almost there!</h1>
|
||||||
line-height: 24px;
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 40px;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
bgcolor="#ffffff"
|
|
||||||
>
|
|
||||||
<h1
|
|
||||||
class="h3 fw-700"
|
|
||||||
style="
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 0;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
vertical-align: baseline;
|
|
||||||
font-size: 28px;
|
|
||||||
line-height: 33.6px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
Almost there!
|
|
||||||
</h1>
|
|
||||||
<table
|
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">To complete your sign up, we just need to verify your email.</p>
|
||||||
class=""
|
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
To complete your sign up, we just need to
|
|
||||||
verify your email.
|
|
||||||
</p>
|
|
||||||
<table
|
|
||||||
class="s-4 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||||
style="
|
|
||||||
line-height: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 100%;
|
|
||||||
height: 16px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="16"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="btn btn-primary p-3 fw-700" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; font-weight: 700 !important;">
|
||||||
class="btn btn-primary p-3 fw-700"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="
|
|
||||||
border-radius: 6px;
|
|
||||||
border-collapse: separate !important;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 16px; border-radius: 6px; font-weight: 700 !important; margin: 0;" align="center" bgcolor="#0d6efd">
|
||||||
style="
|
<a href="{{url}}" style="color: #ffffff; font-size: 16px; font-family: Helvetica, Arial, sans-serif; text-decoration: none; border-radius: 6px; line-height: 20px; display: block; font-weight: 700 !important; white-space: nowrap; background-color: #0d6efd; padding: 12px; border: 1px solid #0d6efd;">Confirm</a>
|
||||||
line-height: 24px;
|
|
||||||
font-size: 16px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="center"
|
|
||||||
bgcolor="#0d6efd"
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="{{url}}"
|
|
||||||
style="
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 16px;
|
|
||||||
font-family: Helvetica, Arial,
|
|
||||||
sans-serif;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
line-height: 20px;
|
|
||||||
display: block;
|
|
||||||
font-weight: 700 !important;
|
|
||||||
white-space: nowrap;
|
|
||||||
background-color: #0d6efd;
|
|
||||||
padding: 12px;
|
|
||||||
border: 1px solid #0d6efd;
|
|
||||||
"
|
|
||||||
>Confirm</a
|
|
||||||
>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -465,66 +93,58 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-6 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
style="
|
|
||||||
line-height: 24px;
|
|
||||||
font-size: 24px;
|
|
||||||
width: 100%;
|
|
||||||
height: 24px;
|
|
||||||
margin: 0;
|
|
||||||
"
|
|
||||||
align="left"
|
|
||||||
width="100%"
|
|
||||||
height="24"
|
|
||||||
>
|
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div
|
<div class="text-muted text-center" style="color: #718096;" align="center">
|
||||||
class="text-muted text-center"
|
This email is intended for {{email}}<br>
|
||||||
style="color: #718096"
|
Sent from Revolt<br>
|
||||||
align="center"
|
|
||||||
>
|
|
||||||
This email is intended for {{email}}<br />
|
|
||||||
Sent from Revolt<br />
|
|
||||||
Made in Europe
|
Made in Europe
|
||||||
</div>
|
</div>
|
||||||
<table
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
class="s-6 w-full"
|
|
||||||
role="presentation"
|
|
||||||
border="0"
|
|
||||||
cellpadding="0"
|
|
||||||
cellspacing="0"
|
|
||||||
style="width: 100%"
|
|
||||||
width="100%"
|
|
||||||
>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
style="
|
 
|
||||||
line-height: 24px;
|
</td>
|
||||||
font-size: 24px;
|
</tr>
|
||||||
width: 100%;
|
</tbody>
|
||||||
height: 24px;
|
</table>
|
||||||
margin: 0;
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
"
|
<tbody>
|
||||||
align="left"
|
<tr>
|
||||||
width="100%"
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
height="24"
|
 
|
||||||
>
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||||
|
<div class="text-muted text-xs" style="color: #718096; font-size: 12px; line-height: 14.4px;">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br>
|
||||||
|
Registered Company Number: 16260658<br>
|
||||||
|
Registered Office:<br>
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br>
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||||
 
|
 
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -22,6 +22,14 @@
|
|||||||
Sent from Revolt<br />
|
Sent from Revolt<br />
|
||||||
Made in Europe
|
Made in Europe
|
||||||
</div>
|
</div>
|
||||||
|
<div class="text-muted text-xs my-6 ax-center">
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the
|
||||||
|
laws of England and Wales.<br />
|
||||||
|
Registered Company Number: 16260658<br />
|
||||||
|
Registered Office:<br />
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,<br />
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,3 +6,10 @@ Please navigate to: {{url}}
|
|||||||
This email is intended for {{email}}
|
This email is intended for {{email}}
|
||||||
Sent by Revolt
|
Sent by Revolt
|
||||||
Made in Europe
|
Made in Europe
|
||||||
|
|
||||||
|
Revolt Platforms Ltd. is a company incorporated and registered under the laws of England and Wales.
|
||||||
|
|
||||||
|
Registration Number: 16260658
|
||||||
|
Registered Office:
|
||||||
|
Suite 5703 Unit 3A, 34-35 Hatton Garden,
|
||||||
|
Holborn, United Kingdom, EC1N 8DX
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
Almost there!
|
||||||
|
To complete your sign up, we just need to verify your email.
|
||||||
|
|
||||||
|
Please navigate to: {{url}}
|
||||||
|
|
||||||
|
This email is intended for {{email}}
|
||||||
|
|
||||||
|
This email has no association with Revolt or Revolt Platforms Ltd.
|
||||||
|
Learn more about third party instances here:
|
||||||
|
https://developers.revolt.chat/faq.html
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-files"
|
name = "revolt-files"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
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>"]
|
||||||
description = "Revolt Backend: S3 and encryption subroutines"
|
description = "Revolt Backend: S3 and encryption subroutines"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
tracing = "0.1"
|
||||||
|
|
||||||
|
ffprobe = "0.4.0"
|
||||||
|
imagesize = "0.13.0"
|
||||||
|
tempfile = "3.12.0"
|
||||||
|
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
aes-gcm = "0.10.3"
|
aes-gcm = "0.10.3"
|
||||||
typenum = "1.17.0"
|
typenum = "1.17.0"
|
||||||
@@ -14,7 +20,19 @@ typenum = "1.17.0"
|
|||||||
aws-config = "1.5.5"
|
aws-config = "1.5.5"
|
||||||
aws-sdk-s3 = { version = "1.46.0", features = ["behavior-version-latest"] }
|
aws-sdk-s3 = { version = "1.46.0", features = ["behavior-version-latest"] }
|
||||||
|
|
||||||
revolt-config = { version = "0.7.16", path = "../config", features = [
|
revolt-config = { version = "0.8.4", path = "../config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.7.16", path = "../result" }
|
revolt-result = { version = "0.8.4", path = "../result" }
|
||||||
|
|
||||||
|
# image processing
|
||||||
|
jxl-oxide = "0.8.1"
|
||||||
|
image = { version = "0.25.2" }
|
||||||
|
|
||||||
|
# svg rendering
|
||||||
|
usvg = "0.44.0"
|
||||||
|
resvg = "0.44.0"
|
||||||
|
tiny-skia = "0.11.4"
|
||||||
|
|
||||||
|
# encoding
|
||||||
|
webp = "0.3.0"
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
use std::io::Write;
|
use std::io::{BufRead, Read, Seek, Write};
|
||||||
|
|
||||||
use aes_gcm::{
|
use aes_gcm::{
|
||||||
aead::{AeadCore, AeadMutInPlace, OsRng},
|
aead::{AeadCore, AeadMutInPlace, OsRng},
|
||||||
Aes256Gcm, Key, KeyInit, Nonce,
|
Aes256Gcm, Key, KeyInit, Nonce,
|
||||||
};
|
};
|
||||||
|
use image::{DynamicImage, ImageBuffer};
|
||||||
use revolt_config::{config, report_internal_error, FilesS3};
|
use revolt_config::{config, report_internal_error, FilesS3};
|
||||||
use revolt_result::{create_error, Result};
|
use revolt_result::{create_error, Result};
|
||||||
|
|
||||||
@@ -13,6 +14,8 @@ use aws_sdk_s3::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use base64::prelude::*;
|
use base64::prelude::*;
|
||||||
|
use tempfile::NamedTempFile;
|
||||||
|
use tiny_skia::Pixmap;
|
||||||
|
|
||||||
/// Size of the authentication tag in the buffer
|
/// Size of the authentication tag in the buffer
|
||||||
pub const AUTHENTICATION_TAG_SIZE_BYTES: usize = 16;
|
pub const AUTHENTICATION_TAG_SIZE_BYTES: usize = 16;
|
||||||
@@ -31,6 +34,7 @@ pub fn create_client(s3_config: FilesS3) -> Client {
|
|||||||
let config = Config::builder()
|
let config = Config::builder()
|
||||||
.region(Region::new(s3_config.region))
|
.region(Region::new(s3_config.region))
|
||||||
.endpoint_url(s3_config.endpoint)
|
.endpoint_url(s3_config.endpoint)
|
||||||
|
.force_path_style(s3_config.path_style_buckets)
|
||||||
.credentials_provider(creds)
|
.credentials_provider(creds)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -108,3 +112,179 @@ pub async fn upload_to_s3(bucket_id: &str, path: &str, buf: &[u8]) -> Result<Str
|
|||||||
|
|
||||||
Ok(BASE64_STANDARD.encode(nonce))
|
Ok(BASE64_STANDARD.encode(nonce))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Delete a file from S3 by path
|
||||||
|
pub async fn delete_from_s3(bucket_id: &str, path: &str) -> Result<()> {
|
||||||
|
let config = config().await;
|
||||||
|
let client = create_client(config.files.s3);
|
||||||
|
|
||||||
|
report_internal_error!(
|
||||||
|
client
|
||||||
|
.delete_object()
|
||||||
|
.bucket(bucket_id)
|
||||||
|
.key(path)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determine size of image at temp file
|
||||||
|
pub fn image_size(f: &NamedTempFile) -> Option<(usize, usize)> {
|
||||||
|
if let Ok(size) = imagesize::size(f.path())
|
||||||
|
.inspect_err(|err| tracing::error!("Failed to generate image size! {err:?}"))
|
||||||
|
{
|
||||||
|
Some((size.width, size.height))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determine size of image with buffer
|
||||||
|
pub fn image_size_vec(v: &[u8], mime: &str) -> Option<(usize, usize)> {
|
||||||
|
match mime {
|
||||||
|
"image/svg+xml" => {
|
||||||
|
let tree =
|
||||||
|
report_internal_error!(usvg::Tree::from_data(v, &Default::default())).ok()?;
|
||||||
|
|
||||||
|
let size = tree.size();
|
||||||
|
Some((size.width() as usize, size.height() as usize))
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
if let Ok(size) = imagesize::blob_size(v)
|
||||||
|
.inspect_err(|err| tracing::error!("Failed to generate image size! {err:?}"))
|
||||||
|
{
|
||||||
|
Some((size.width, size.height))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determine size of video at temp file
|
||||||
|
pub fn video_size(f: &NamedTempFile) -> Option<(i64, i64)> {
|
||||||
|
if let Ok(data) = ffprobe::ffprobe(f.path())
|
||||||
|
.inspect_err(|err| tracing::error!("Failed to ffprobe file! {err:?}"))
|
||||||
|
{
|
||||||
|
// Use first valid stream
|
||||||
|
for stream in data.streams {
|
||||||
|
if let (Some(w), Some(h)) = (stream.width, stream.height) {
|
||||||
|
return Some((w, h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decode image from reader
|
||||||
|
pub fn decode_image<R: Read + BufRead + Seek>(reader: &mut R, mime: &str) -> Result<DynamicImage> {
|
||||||
|
match mime {
|
||||||
|
// Read image using jxl-oxide crate
|
||||||
|
"image/jxl" => {
|
||||||
|
let jxl_image = report_internal_error!(jxl_oxide::JxlImage::builder().read(reader))?;
|
||||||
|
if let Ok(frame) = jxl_image.render_frame(0) {
|
||||||
|
match frame.color_channels().len() {
|
||||||
|
3 => Ok(DynamicImage::ImageRgb8(
|
||||||
|
DynamicImage::ImageRgb32F(
|
||||||
|
ImageBuffer::from_vec(
|
||||||
|
jxl_image.width(),
|
||||||
|
jxl_image.height(),
|
||||||
|
frame.image().buf().to_vec(),
|
||||||
|
)
|
||||||
|
.ok_or_else(|| create_error!(ImageProcessingFailed))?,
|
||||||
|
)
|
||||||
|
.to_rgb8(),
|
||||||
|
)),
|
||||||
|
4 => Ok(DynamicImage::ImageRgba8(
|
||||||
|
DynamicImage::ImageRgba32F(
|
||||||
|
ImageBuffer::from_vec(
|
||||||
|
jxl_image.width(),
|
||||||
|
jxl_image.height(),
|
||||||
|
frame.image().buf().to_vec(),
|
||||||
|
)
|
||||||
|
.ok_or_else(|| create_error!(ImageProcessingFailed))?,
|
||||||
|
)
|
||||||
|
.to_rgba8(),
|
||||||
|
)),
|
||||||
|
_ => Err(create_error!(ImageProcessingFailed)),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(create_error!(ImageProcessingFailed))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Read image using resvg
|
||||||
|
"image/svg+xml" => {
|
||||||
|
// usvg doesn't support Read trait so copy to buffer
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
report_internal_error!(reader.read_to_end(&mut buf))?;
|
||||||
|
|
||||||
|
let tree = report_internal_error!(usvg::Tree::from_data(&buf, &Default::default()))?;
|
||||||
|
let size = tree.size();
|
||||||
|
let mut pixmap = Pixmap::new(size.width() as u32, size.height() as u32)
|
||||||
|
.ok_or_else(|| create_error!(ImageProcessingFailed))?;
|
||||||
|
|
||||||
|
let mut pixmap_mut = pixmap.as_mut();
|
||||||
|
resvg::render(&tree, Default::default(), &mut pixmap_mut);
|
||||||
|
|
||||||
|
Ok(DynamicImage::ImageRgba8(
|
||||||
|
ImageBuffer::from_vec(
|
||||||
|
size.width() as u32,
|
||||||
|
size.height() as u32,
|
||||||
|
pixmap.data().to_vec(),
|
||||||
|
)
|
||||||
|
.ok_or_else(|| create_error!(ImageProcessingFailed))?,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
// Check if we can read using image-rs crate
|
||||||
|
_ => report_internal_error!(report_internal_error!(
|
||||||
|
image::ImageReader::new(reader).with_guessed_format()
|
||||||
|
)?
|
||||||
|
.decode()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check whether given reader has a valid image
|
||||||
|
pub fn is_valid_image<R: Read + BufRead + Seek>(reader: &mut R, mime: &str) -> bool {
|
||||||
|
match mime {
|
||||||
|
// Check if we can read using jxl-oxide crate
|
||||||
|
"image/jxl" => jxl_oxide::JxlImage::builder()
|
||||||
|
.read(reader)
|
||||||
|
.inspect_err(|err| tracing::error!("Failed to read JXL! {err:?}"))
|
||||||
|
.is_ok(),
|
||||||
|
// Check if we can read using image-rs crate
|
||||||
|
_ => !matches!(
|
||||||
|
image::ImageReader::new(reader)
|
||||||
|
.with_guessed_format()
|
||||||
|
.inspect_err(|err| tracing::error!("Failed to read image! {err:?}"))
|
||||||
|
.map(|f| f.decode()),
|
||||||
|
Err(_) | Ok(Err(_))
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create thumbnail from given image
|
||||||
|
pub async fn create_thumbnail(image: DynamicImage, tag: &str) -> Vec<u8> {
|
||||||
|
// Load configuration
|
||||||
|
let config = config().await;
|
||||||
|
let [w, h] = config.files.preview.get(tag).unwrap();
|
||||||
|
|
||||||
|
// Create thumbnail
|
||||||
|
//.resize(width as u32, height as u32, image::imageops::FilterType::Gaussian)
|
||||||
|
// resize is about 2.5x slower,
|
||||||
|
// thumbnail doesn't have terrible quality
|
||||||
|
// so we use thumbnail
|
||||||
|
let image = image.thumbnail(image.width().min(*w as u32), image.height().min(*h as u32));
|
||||||
|
|
||||||
|
// Encode it into WEBP
|
||||||
|
let encoder = webp::Encoder::from_image(&image).expect("Could not create encoder.");
|
||||||
|
if config.files.webp_quality != 100.0 {
|
||||||
|
encoder.encode(config.files.webp_quality).to_vec()
|
||||||
|
} else {
|
||||||
|
encoder.encode_lossless().to_vec()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-models"
|
name = "revolt-models"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -20,13 +20,14 @@ default = ["serde", "partials", "rocket"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { version = "0.7.16", path = "../config" }
|
revolt-config = { version = "0.8.4", path = "../config" }
|
||||||
revolt-permissions = { version = "0.7.16", path = "../permissions" }
|
revolt-permissions = { version = "0.8.4", path = "../permissions" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
regex = "1"
|
regex = "1.11"
|
||||||
indexmap = "1.9.3"
|
indexmap = "1.9.3"
|
||||||
once_cell = "1.17.1"
|
once_cell = "1.17.1"
|
||||||
|
num_enum = "0.6.1"
|
||||||
|
|
||||||
# Rocket
|
# Rocket
|
||||||
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false }
|
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false }
|
||||||
|
|||||||
@@ -306,4 +306,18 @@ impl Channel {
|
|||||||
| Channel::VoiceChannel { id, .. } => id,
|
| Channel::VoiceChannel { id, .. } => id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This returns a Result because the recipient name can't be determined here without a db call,
|
||||||
|
/// which can't be done since this is models, which can't reference the database crate.
|
||||||
|
///
|
||||||
|
/// If it returns Err, you need to fetch the name from the db.
|
||||||
|
pub fn name(&self) -> Result<&str, ()> {
|
||||||
|
match self {
|
||||||
|
Channel::DirectMessage { .. } => Err(()),
|
||||||
|
Channel::SavedMessages { .. } => Ok("Saved Messages"),
|
||||||
|
Channel::TextChannel { name, .. }
|
||||||
|
| Channel::Group { name, .. }
|
||||||
|
| Channel::VoiceChannel { name, .. } => Ok(name),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ auto_derived!(
|
|||||||
/// URL to the original image
|
/// URL to the original image
|
||||||
pub url: String,
|
pub url: String,
|
||||||
/// Width of the image
|
/// Width of the image
|
||||||
pub width: isize,
|
pub width: usize,
|
||||||
/// Height of the image
|
/// Height of the image
|
||||||
pub height: isize,
|
pub height: usize,
|
||||||
/// Positioning and size
|
/// Positioning and size
|
||||||
pub size: ImageSize,
|
pub size: ImageSize,
|
||||||
}
|
}
|
||||||
@@ -26,9 +26,9 @@ auto_derived!(
|
|||||||
/// URL to the original video
|
/// URL to the original video
|
||||||
pub url: String,
|
pub url: String,
|
||||||
/// Width of the video
|
/// Width of the video
|
||||||
pub width: isize,
|
pub width: usize,
|
||||||
/// Height of the video
|
/// Height of the video
|
||||||
pub height: isize,
|
pub height: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type of remote Twitch content
|
/// Type of remote Twitch content
|
||||||
@@ -86,7 +86,7 @@ auto_derived!(
|
|||||||
},
|
},
|
||||||
AppleMusic {
|
AppleMusic {
|
||||||
album_id: String,
|
album_id: String,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
track_id: Option<String>,
|
track_id: Option<String>,
|
||||||
},
|
},
|
||||||
@@ -119,8 +119,6 @@ auto_derived!(
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub video: Option<Video>,
|
pub video: Option<Video>,
|
||||||
|
|
||||||
// #[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
// opengraph_type: Option<String>,
|
|
||||||
/// Site name
|
/// Site name
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub site_name: Option<String>,
|
pub site_name: Option<String>,
|
||||||
@@ -156,11 +154,56 @@ auto_derived!(
|
|||||||
|
|
||||||
/// Embed
|
/// Embed
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
|
#[derive(Default)]
|
||||||
pub enum Embed {
|
pub enum Embed {
|
||||||
Website(WebsiteMetadata),
|
Website(WebsiteMetadata),
|
||||||
Image(Image),
|
Image(Image),
|
||||||
Video(Video),
|
Video(Video),
|
||||||
Text(Text),
|
Text(Text),
|
||||||
|
#[default]
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl WebsiteMetadata {
|
||||||
|
/// Truncate strings in metadata
|
||||||
|
pub fn truncate(&mut self) {
|
||||||
|
if let Some(s) = self.url.as_mut() {
|
||||||
|
s.truncate(256);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(s) = self.original_url.as_mut() {
|
||||||
|
s.truncate(256);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(s) = self.title.as_mut() {
|
||||||
|
s.truncate(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(s) = self.description.as_mut() {
|
||||||
|
s.truncate(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(s) = self.site_name.as_mut() {
|
||||||
|
s.truncate(32);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(s) = self.icon_url.as_mut() {
|
||||||
|
s.truncate(256);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(s) = self.colour.as_mut() {
|
||||||
|
s.truncate(32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if this is considered "empty"
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
(self.title.is_none() || self.title.as_ref().is_some_and(|f| f.is_empty()))
|
||||||
|
&& (self.description.is_none()
|
||||||
|
|| self.description.as_ref().is_some_and(|f| f.is_empty()))
|
||||||
|
&& self.special.is_none()
|
||||||
|
&& self.video.is_none()
|
||||||
|
&& self.image.is_none()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::{IndexMap, IndexSet};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use regex::Regex;
|
|
||||||
use revolt_config::config;
|
use revolt_config::config;
|
||||||
|
|
||||||
#[cfg(feature = "validator")]
|
#[cfg(feature = "validator")]
|
||||||
@@ -13,10 +11,7 @@ use rocket::{FromForm, FromFormField};
|
|||||||
|
|
||||||
use iso8601_timestamp::Timestamp;
|
use iso8601_timestamp::Timestamp;
|
||||||
|
|
||||||
use super::{Embed, File, Member, MessageWebhook, User, Webhook, RE_COLOUR};
|
use super::{Channel, Embed, File, Member, MessageWebhook, User, Webhook, RE_COLOUR};
|
||||||
|
|
||||||
pub static RE_MENTION: Lazy<Regex> =
|
|
||||||
Lazy::new(|| Regex::new(r"<@([0-9A-HJKMNP-TV-Z]{26})>").unwrap());
|
|
||||||
|
|
||||||
auto_derived_partial!(
|
auto_derived_partial!(
|
||||||
/// Message
|
/// Message
|
||||||
@@ -58,6 +53,9 @@ auto_derived_partial!(
|
|||||||
/// Array of user ids mentioned in this message
|
/// Array of user ids mentioned in this message
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub mentions: Option<Vec<String>>,
|
pub mentions: Option<Vec<String>>,
|
||||||
|
/// Array of role ids mentioned in this message
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub role_mentions: Option<Vec<String>>,
|
||||||
/// Array of message ids this message is replying to
|
/// Array of message ids this message is replying to
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub replies: Option<Vec<String>>,
|
pub replies: Option<Vec<String>>,
|
||||||
@@ -209,6 +207,8 @@ auto_derived!(
|
|||||||
pub url: String,
|
pub url: String,
|
||||||
/// The message object itself, to send to clients for processing
|
/// The message object itself, to send to clients for processing
|
||||||
pub message: Message,
|
pub message: Message,
|
||||||
|
/// The channel object itself, for clients to process
|
||||||
|
pub channel: Channel,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Representation of a text embed before it is sent.
|
/// Representation of a text embed before it is sent.
|
||||||
@@ -237,6 +237,10 @@ auto_derived!(
|
|||||||
pub id: String,
|
pub id: String,
|
||||||
/// Whether this reply should mention the message's author
|
/// Whether this reply should mention the message's author
|
||||||
pub mention: bool,
|
pub mention: bool,
|
||||||
|
/// Whether to error if the referenced message doesn't exist.
|
||||||
|
/// Otherwise, send a message without this reply.
|
||||||
|
/// Default is true.
|
||||||
|
pub fail_if_not_exists: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Message to send
|
/// Message to send
|
||||||
@@ -278,7 +282,7 @@ auto_derived!(
|
|||||||
pub struct OptionsQueryMessages {
|
pub struct OptionsQueryMessages {
|
||||||
/// Maximum number of messages to fetch
|
/// Maximum number of messages to fetch
|
||||||
///
|
///
|
||||||
/// For fetching nearby messages, this is \`(limit + 1)\`.
|
/// For fetching nearby messages, this is \`(limit + 2)\`.
|
||||||
#[cfg_attr(feature = "validator", validate(range(min = 1, max = 100)))]
|
#[cfg_attr(feature = "validator", validate(range(min = 1, max = 100)))]
|
||||||
pub limit: Option<i64>,
|
pub limit: Option<i64>,
|
||||||
/// Message id before which messages should be fetched
|
/// Message id before which messages should be fetched
|
||||||
@@ -365,11 +369,16 @@ auto_derived!(
|
|||||||
pub enum MessageFlags {
|
pub enum MessageFlags {
|
||||||
/// Message will not send push / desktop notifications
|
/// Message will not send push / desktop notifications
|
||||||
SuppressNotifications = 1,
|
SuppressNotifications = 1,
|
||||||
|
/// Message will mention all users who can see the channel
|
||||||
|
MentionsEveryone = 2,
|
||||||
|
/// Message will mention all users who are online and can see the channel.
|
||||||
|
/// This cannot be true if MentionsEveryone is true
|
||||||
|
MentionsOnline = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optional fields on message
|
/// Optional fields on message
|
||||||
pub enum FieldsMessage {
|
pub enum FieldsMessage {
|
||||||
Pinned
|
Pinned,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -442,7 +451,7 @@ impl From<SystemMessage> for String {
|
|||||||
|
|
||||||
impl PushNotification {
|
impl PushNotification {
|
||||||
/// Create a new notification from a given message, author and channel ID
|
/// Create a new notification from a given message, author and channel ID
|
||||||
pub async fn from(msg: Message, author: Option<MessageAuthor<'_>>, channel_id: &str) -> Self {
|
pub async fn from(msg: Message, author: Option<MessageAuthor<'_>>, channel: Channel) -> Self {
|
||||||
let config = config().await;
|
let config = config().await;
|
||||||
|
|
||||||
let icon = if let Some(author) = &author {
|
let icon = if let Some(author) = &author {
|
||||||
@@ -496,10 +505,11 @@ impl PushNotification {
|
|||||||
icon,
|
icon,
|
||||||
image,
|
image,
|
||||||
body,
|
body,
|
||||||
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),
|
||||||
message: msg,
|
message: msg,
|
||||||
|
channel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "revolt-parser"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
logos = { version = "*" }
|
||||||
@@ -0,0 +1,245 @@
|
|||||||
|
use std::collections::{HashSet, VecDeque};
|
||||||
|
|
||||||
|
use logos::Logos;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Logos, PartialEq)]
|
||||||
|
#[logos(skip "\n")]
|
||||||
|
pub enum MessageToken {
|
||||||
|
#[token("\\")]
|
||||||
|
Escape,
|
||||||
|
#[regex("(```[^`\n]*)|(``)|`", |lex| lex.slice().to_owned().chars().filter(|&c| c == '`').count())]
|
||||||
|
CodeblockMarker(usize),
|
||||||
|
#[regex("<@[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}>", |lex| lex.slice()[2..lex.slice().len() - 1].to_owned())]
|
||||||
|
UserMention(String),
|
||||||
|
#[regex("<%[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}>", |lex| lex.slice()[2..lex.slice().len() - 1].to_owned())]
|
||||||
|
RoleMention(String),
|
||||||
|
#[token("@everyone")]
|
||||||
|
MentionEveryone,
|
||||||
|
#[token("@online")]
|
||||||
|
MentionOnline
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
|
pub struct MessageResults {
|
||||||
|
pub user_mentions: HashSet<String>,
|
||||||
|
pub role_mentions: HashSet<String>,
|
||||||
|
pub mentions_everyone: bool,
|
||||||
|
pub mentions_online: bool
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MessageParserIterator<I> {
|
||||||
|
inner: I,
|
||||||
|
temp: VecDeque<MessageToken>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<I: Iterator<Item = MessageToken>> Iterator for MessageParserIterator<I> {
|
||||||
|
type Item = MessageToken;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
if !self.temp.is_empty() {
|
||||||
|
self.temp.pop_front()
|
||||||
|
} else {
|
||||||
|
let token = self.inner.next();
|
||||||
|
|
||||||
|
if token == Some(MessageToken::Escape) {
|
||||||
|
self.inner.next();
|
||||||
|
|
||||||
|
token
|
||||||
|
} else if let Some(MessageToken::CodeblockMarker(ty)) = token {
|
||||||
|
loop {
|
||||||
|
let next_token = self.inner.next();
|
||||||
|
|
||||||
|
if next_token == Some(MessageToken::CodeblockMarker(ty)) {
|
||||||
|
self.temp.clear();
|
||||||
|
self.temp.push_back(MessageToken::CodeblockMarker(ty));
|
||||||
|
break next_token
|
||||||
|
} else if let Some(token) = next_token {
|
||||||
|
self.temp.push_back(token);
|
||||||
|
} else {
|
||||||
|
break Some(MessageToken::CodeblockMarker(ty))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_message_iter(text: &str) -> impl Iterator<Item = MessageToken> + '_ {
|
||||||
|
MessageParserIterator {
|
||||||
|
inner: MessageToken::lexer(text).flatten(),
|
||||||
|
temp: VecDeque::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_message(text: &str) -> MessageResults {
|
||||||
|
let mut results = MessageResults::default();
|
||||||
|
|
||||||
|
for token in parse_message_iter(text) {
|
||||||
|
match token {
|
||||||
|
MessageToken::Escape => {}
|
||||||
|
MessageToken::CodeblockMarker(_) => {},
|
||||||
|
MessageToken::UserMention(id) => { results.user_mentions.insert(id); },
|
||||||
|
MessageToken::RoleMention(id) => { results.role_mentions.insert(id); },
|
||||||
|
MessageToken::MentionEveryone => results.mentions_everyone = true,
|
||||||
|
MessageToken::MentionOnline => results.mentions_online = true,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
results
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_no_nodes() {
|
||||||
|
let output = parse_message_iter("Hello everyone").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_simple_user_mention() {
|
||||||
|
let output = parse_message_iter("Hello <@01FD58YK5W7QRV5H3D64KTQYX3>.").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 1);
|
||||||
|
assert_eq!(output[0], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_simple_role_mention() {
|
||||||
|
let output = parse_message_iter("Hello <%01FD58YK5W7QRV5H3D64KTQYX3>.").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 1);
|
||||||
|
assert_eq!(output[0], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mention_everyone() {
|
||||||
|
let output = parse_message_iter("Hello @everyone.").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 1);
|
||||||
|
assert_eq!(output[0], MessageToken::MentionEveryone);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mention_online() {
|
||||||
|
let output = parse_message_iter("Hello @online.").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 1);
|
||||||
|
assert_eq!(output[0], MessageToken::MentionOnline);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_everything() {
|
||||||
|
let output = parse_message_iter("Hello <@01FD58YK5W7QRV5H3D64KTQYX3>, <%01FD58YK5W7QRV5H3D64KTQYX3>, @everyone and @online.").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 4);
|
||||||
|
assert_eq!(output[0], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
assert_eq!(output[1], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
assert_eq!(output[2], MessageToken::MentionEveryone);
|
||||||
|
assert_eq!(output[3], MessageToken::MentionOnline);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_everything_no_spaces() {
|
||||||
|
let output = parse_message_iter("<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 4);
|
||||||
|
assert_eq!(output[0], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
assert_eq!(output[1], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
assert_eq!(output[2], MessageToken::MentionEveryone);
|
||||||
|
assert_eq!(output[3], MessageToken::MentionOnline);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_codeblock_no_mentions() {
|
||||||
|
let output = parse_message_iter("```\n<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online\n```").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 2);
|
||||||
|
assert_eq!(output[0], MessageToken::CodeblockMarker(3));
|
||||||
|
assert_eq!(output[1], MessageToken::CodeblockMarker(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uncontained_codeblock_should_mention() {
|
||||||
|
let output = parse_message_iter("```\n<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 5);
|
||||||
|
assert_eq!(output[0], MessageToken::CodeblockMarker(3));
|
||||||
|
assert_eq!(output[1], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
assert_eq!(output[2], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
assert_eq!(output[3], MessageToken::MentionEveryone);
|
||||||
|
assert_eq!(output[4], MessageToken::MentionOnline);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_inline_codeblock_no_mentions() {
|
||||||
|
|
||||||
|
let output = parse_message_iter("`<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online`").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 2);
|
||||||
|
assert_eq!(output[0], MessageToken::CodeblockMarker(1));
|
||||||
|
assert_eq!(output[0], MessageToken::CodeblockMarker(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uncontained_inline_codeblock_should_mention() {
|
||||||
|
let output = parse_message_iter("`<@01FD58YK5W7QRV5H3D64KTQYX3><%01FD58YK5W7QRV5H3D64KTQYX3>@everyone@online").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 5);
|
||||||
|
assert_eq!(output[0], MessageToken::CodeblockMarker(1));
|
||||||
|
assert_eq!(output[1], MessageToken::UserMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
assert_eq!(output[2], MessageToken::RoleMention("01FD58YK5W7QRV5H3D64KTQYX3".to_string()));
|
||||||
|
assert_eq!(output[3], MessageToken::MentionEveryone);
|
||||||
|
assert_eq!(output[4], MessageToken::MentionOnline);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_double_inline_codeblock() {
|
||||||
|
let output = parse_message_iter("``this should not ping @everyone``").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 2);
|
||||||
|
assert_eq!(output[0], MessageToken::CodeblockMarker(2));
|
||||||
|
assert_eq!(output[1], MessageToken::CodeblockMarker(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_double_inline_codeblock_with_backticks_inside() {
|
||||||
|
let output = parse_message_iter("``this `should` not `ping` @everyone``").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 2);
|
||||||
|
assert_eq!(output[0], MessageToken::CodeblockMarker(2));
|
||||||
|
assert_eq!(output[1], MessageToken::CodeblockMarker(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_in_middle() {
|
||||||
|
let output = parse_message_iter("i am not pinging `@everyone`.").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 2);
|
||||||
|
assert_eq!(output[0], MessageToken::CodeblockMarker(1));
|
||||||
|
assert_eq!(output[1], MessageToken::CodeblockMarker(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_escaped_codeblock() {
|
||||||
|
let output = parse_message_iter("i am ~~not~~ pinging \\`@everyone` ok.").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 3);
|
||||||
|
assert_eq!(output[0], MessageToken::Escape);
|
||||||
|
assert_eq!(output[1], MessageToken::MentionEveryone);
|
||||||
|
assert_eq!(output[2], MessageToken::CodeblockMarker(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_escape_mention() {
|
||||||
|
let output = parse_message_iter("i wont ping \\@everyone").collect::<Vec<_>>();
|
||||||
|
|
||||||
|
assert_eq!(output.len(), 1);
|
||||||
|
assert_eq!(output[0], MessageToken::Escape);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-permissions"
|
name = "revolt-permissions"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -21,7 +21,7 @@ async-std = { version = "1.8.0", features = ["attributes"] }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { version = "0.7.16", path = "../result" }
|
revolt-result = { version = "0.8.4", path = "../result" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
auto_ops = "0.3.0"
|
auto_ops = "0.3.0"
|
||||||
|
|||||||
@@ -90,8 +90,14 @@ pub enum ChannelPermission {
|
|||||||
/// Move members between voice channels
|
/// Move members between voice channels
|
||||||
MoveMembers = 1 << 35,
|
MoveMembers = 1 << 35,
|
||||||
|
|
||||||
|
// * Channel permissions two electric boogaloo
|
||||||
|
/// Mention everyone and online members
|
||||||
|
MentionEveryone = 1 << 37,
|
||||||
|
/// Mention roles
|
||||||
|
MentionRoles = 1 << 38,
|
||||||
|
|
||||||
// * Misc. permissions
|
// * Misc. permissions
|
||||||
// % Bits 36 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
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-presence"
|
name = "revolt-presence"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
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>"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-result"
|
name = "revolt-result"
|
||||||
version = "0.7.16"
|
version = "0.8.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -29,7 +29,7 @@ utoipa = { version = "4.2.3", optional = true }
|
|||||||
|
|
||||||
# Rocket
|
# Rocket
|
||||||
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false }
|
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false }
|
||||||
revolt_rocket_okapi = { version = "0.9.1", optional = true }
|
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
||||||
revolt_okapi = { version = "0.9.1", optional = true }
|
revolt_okapi = { version = "0.9.1", optional = true }
|
||||||
|
|
||||||
# Axum
|
# Axum
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::InvalidRole => StatusCode::NOT_FOUND,
|
ErrorType::InvalidRole => StatusCode::NOT_FOUND,
|
||||||
ErrorType::Banned => StatusCode::FORBIDDEN,
|
ErrorType::Banned => StatusCode::FORBIDDEN,
|
||||||
ErrorType::AlreadyInServer => StatusCode::CONFLICT,
|
ErrorType::AlreadyInServer => StatusCode::CONFLICT,
|
||||||
|
ErrorType::CannotTimeoutYourself => StatusCode::BAD_REQUEST,
|
||||||
|
|
||||||
ErrorType::TooManyServers { .. } => StatusCode::BAD_REQUEST,
|
ErrorType::TooManyServers { .. } => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::TooManyEmbeds { .. } => StatusCode::BAD_REQUEST,
|
ErrorType::TooManyEmbeds { .. } => StatusCode::BAD_REQUEST,
|
||||||
@@ -50,6 +51,7 @@ impl IntoResponse for Error {
|
|||||||
|
|
||||||
ErrorType::ReachedMaximumBots => StatusCode::BAD_REQUEST,
|
ErrorType::ReachedMaximumBots => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::IsBot => StatusCode::BAD_REQUEST,
|
ErrorType::IsBot => StatusCode::BAD_REQUEST,
|
||||||
|
ErrorType::IsNotBot => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::BotIsPrivate => StatusCode::FORBIDDEN,
|
ErrorType::BotIsPrivate => StatusCode::FORBIDDEN,
|
||||||
|
|
||||||
ErrorType::CannotReportYourself => StatusCode::BAD_REQUEST,
|
ErrorType::CannotReportYourself => StatusCode::BAD_REQUEST,
|
||||||
@@ -73,11 +75,15 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::NotFound => StatusCode::NOT_FOUND,
|
ErrorType::NotFound => StatusCode::NOT_FOUND,
|
||||||
ErrorType::NoEffect => StatusCode::OK,
|
ErrorType::NoEffect => StatusCode::OK,
|
||||||
ErrorType::FailedValidation { .. } => StatusCode::BAD_REQUEST,
|
ErrorType::FailedValidation { .. } => StatusCode::BAD_REQUEST,
|
||||||
|
ErrorType::InvalidFlagValue => StatusCode::BAD_REQUEST,
|
||||||
|
ErrorType::FeatureDisabled { .. } => StatusCode::BAD_REQUEST,
|
||||||
|
|
||||||
ErrorType::ProxyError => StatusCode::BAD_REQUEST,
|
ErrorType::ProxyError => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::FileTooSmall => StatusCode::UNPROCESSABLE_ENTITY,
|
ErrorType::FileTooSmall => StatusCode::UNPROCESSABLE_ENTITY,
|
||||||
ErrorType::FileTooLarge { .. } => StatusCode::UNPROCESSABLE_ENTITY,
|
ErrorType::FileTooLarge { .. } => StatusCode::UNPROCESSABLE_ENTITY,
|
||||||
ErrorType::FileTypeNotAllowed => StatusCode::BAD_REQUEST,
|
ErrorType::FileTypeNotAllowed => StatusCode::BAD_REQUEST,
|
||||||
|
ErrorType::ImageProcessingFailed => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
ErrorType::NoEmbedData => StatusCode::BAD_REQUEST,
|
||||||
};
|
};
|
||||||
|
|
||||||
(status, Json(&self)).into_response()
|
(status, Json(&self)).into_response()
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user