Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
805f2c4528 | ||
|
|
5a6155fdb6 | ||
|
|
c5844b6281 | ||
|
|
24d0d2b726 | ||
|
|
f777e2863c | ||
|
|
a80ad1cbe5 | ||
|
|
0b522ebddc | ||
|
|
6bd045eb79 | ||
|
|
0698e115e8 | ||
|
|
8e3765df4c | ||
|
|
1c98ead695 | ||
|
|
8849d03cd2 | ||
|
|
a75e4eabfc |
@@ -0,0 +1,147 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: Report a bug in Stoat — please fill out every required field to help us triage quickly.
|
||||||
|
title: "[Bug]: "
|
||||||
|
labels:
|
||||||
|
- bug
|
||||||
|
- unconfirmed
|
||||||
|
|
||||||
|
body:
|
||||||
|
# ── Thank you section ────────────────────────────────────────────────────────
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**Thank you for taking the time to report a bug for Stoat!**
|
||||||
|
|
||||||
|
Please follow the instructions below and provide as much detail as possible to help us understand and reproduce the issue.
|
||||||
|
|
||||||
|
# ── Pre-flight checks ────────────────────────────────────────────────────────
|
||||||
|
- type: checkboxes
|
||||||
|
id: preflight
|
||||||
|
attributes:
|
||||||
|
label: Pre-flight checklist
|
||||||
|
description: Please confirm all of the following before submitting.
|
||||||
|
options:
|
||||||
|
- label: I am on the latest available version of Stoat.
|
||||||
|
required: true
|
||||||
|
- label: I searched existing issues and did not find a duplicate.
|
||||||
|
required: true
|
||||||
|
- label: This is a bug report, not a support question or feature request.
|
||||||
|
required: true
|
||||||
|
|
||||||
|
# ── Bug description ──────────────────────────────────────────────────────────
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Bug description
|
||||||
|
description: >
|
||||||
|
What happened? What did you expect to happen instead?
|
||||||
|
Keep this brief — detailed steps go in the next field.
|
||||||
|
placeholder: "Example: When I open a DM thread, new messages from the other person do not appear unless I reload the page."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
# ── Steps to reproduce ───────────────────────────────────────────────────────
|
||||||
|
- type: textarea
|
||||||
|
id: steps
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce
|
||||||
|
description: >
|
||||||
|
Provide a numbered list of every step needed to trigger the bug.
|
||||||
|
The clearer this is, the faster we can fix it.
|
||||||
|
placeholder: |
|
||||||
|
1. Log in to Stoat on the web client.
|
||||||
|
2. Open a direct message conversation.
|
||||||
|
3. Ask the other person to send a message.
|
||||||
|
4. Observe that the message does not appear without reloading.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
# ── Expected behavior ────────────────────────────────────────────────────────
|
||||||
|
- type: textarea
|
||||||
|
id: expected
|
||||||
|
attributes:
|
||||||
|
label: Expected behavior
|
||||||
|
description: What should have happened?
|
||||||
|
placeholder: "New messages should appear in real time without a page reload."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
# ── Client / platform ────────────────────────────────────────────────────────
|
||||||
|
- type: dropdown
|
||||||
|
id: platform
|
||||||
|
attributes:
|
||||||
|
label: Client / platform
|
||||||
|
description: Which Stoat client are you using?
|
||||||
|
options:
|
||||||
|
- Web (browser)
|
||||||
|
- Stoat for Desktop
|
||||||
|
- Android
|
||||||
|
- iOS
|
||||||
|
- Self-hosted server
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
# ── Client version ───────────────────────────────────────────────────────────
|
||||||
|
- type: input
|
||||||
|
id: version
|
||||||
|
attributes:
|
||||||
|
label: Client version
|
||||||
|
description: >
|
||||||
|
Find this in **Settings**. For the web client, include the build
|
||||||
|
number shown in the footer or About page.
|
||||||
|
placeholder: "e.g. Stoat for Desktop 1.3.0 or 0.2.1 (2025-10-10)"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
# ── OS / browser details ─────────────────────────────────────────────────────
|
||||||
|
- type: input
|
||||||
|
id: os
|
||||||
|
attributes:
|
||||||
|
label: OS / browser details
|
||||||
|
description: Your operating system and, for web bugs, your browser and its version.
|
||||||
|
placeholder: "e.g. Windows 11, Chrome 121 or macOS 14.3, Stoat for Desktop 1.3.0 or Android 14"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
# ── Reproducibility ──────────────────────────────────────────────────────────
|
||||||
|
- type: dropdown
|
||||||
|
id: reproducibility
|
||||||
|
attributes:
|
||||||
|
label: Reproducibility
|
||||||
|
description: How consistently does this bug occur?
|
||||||
|
options:
|
||||||
|
- Always
|
||||||
|
- Usually
|
||||||
|
- Rarely
|
||||||
|
- Only once
|
||||||
|
- Unknown
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
# ── Screenshots or video ─────────────────────────────────────────────────────
|
||||||
|
- type: textarea
|
||||||
|
id: screenshots
|
||||||
|
attributes:
|
||||||
|
label: Screenshots or video
|
||||||
|
description: Paste images or drag-and-drop a screen recording here. GitHub accepts common image and video formats.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
# ── Additional context ───────────────────────────────────────────────────────
|
||||||
|
- type: textarea
|
||||||
|
id: additional
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: >
|
||||||
|
Anything else that might help: workarounds you found, links to related issues,
|
||||||
|
self-hosted configuration details (Redis, MongoDB, LiveKit, SMTP), network environment, etc.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
# ── Closing note ─────────────────────────────────────────────────────────────
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
---
|
||||||
|
A maintainer will review your report. Please watch for follow-up questions — issues
|
||||||
|
that go unanswered are harder to resolve and may be closed after 30 days of inactivity.
|
||||||
@@ -20,4 +20,4 @@ jobs:
|
|||||||
RELEASE_URL="https://github.com/${REPOSITORY}/releases/tag/${TAG_NAME}"
|
RELEASE_URL="https://github.com/${REPOSITORY}/releases/tag/${TAG_NAME}"
|
||||||
curl -X POST "$WEBHOOK_URL" \
|
curl -X POST "$WEBHOOK_URL" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"content\": \"$RELEASE_URL\"}"
|
-d "{\"content\": \"$RELEASE_URL\"}"
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "0.11.3"
|
".": "0.11.5"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,19 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.11.5](https://github.com/stoatchat/stoatchat/compare/v0.11.4...v0.11.5) (2026-02-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* disable user update events ([#593](https://github.com/stoatchat/stoatchat/issues/593)) ([1c98ead](https://github.com/stoatchat/stoatchat/commit/1c98ead69579b4700be0b51c9020bb8402336cc6))
|
||||||
|
|
||||||
|
## [0.11.4](https://github.com/stoatchat/stoatchat/compare/v0.11.3...v0.11.4) (2026-02-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add separate config option for redis events replica url ([#590](https://github.com/stoatchat/stoatchat/issues/590)) ([a75e4ea](https://github.com/stoatchat/stoatchat/commit/a75e4eabfc4b34aba7620c82ba77558a32d9e10a))
|
||||||
|
|
||||||
## [0.11.3](https://github.com/stoatchat/stoatchat/compare/v0.11.2...v0.11.3) (2026-02-13)
|
## [0.11.3](https://github.com/stoatchat/stoatchat/compare/v0.11.2...v0.11.3) (2026-02-13)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Generated
+20
-32
@@ -6798,7 +6798,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-autumn"
|
name = "revolt-autumn"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-macros",
|
"axum-macros",
|
||||||
@@ -6836,10 +6836,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"amqprs",
|
||||||
"async-channel 2.5.0",
|
"async-channel 2.5.0",
|
||||||
"async-std",
|
"async-std",
|
||||||
|
"async-trait",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
"authifier",
|
"authifier",
|
||||||
"bincode",
|
"bincode",
|
||||||
@@ -6867,7 +6869,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-coalesced"
|
name = "revolt-coalesced"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.0",
|
||||||
"lru 0.16.3",
|
"lru 0.16.3",
|
||||||
@@ -6876,7 +6878,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-config"
|
name = "revolt-config"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"cached",
|
"cached",
|
||||||
@@ -6893,7 +6895,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-crond"
|
name = "revolt-crond"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"revolt-config",
|
"revolt-config",
|
||||||
@@ -6905,7 +6907,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-database"
|
name = "revolt-database"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"amqprs",
|
"amqprs",
|
||||||
"async-lock 2.8.0",
|
"async-lock 2.8.0",
|
||||||
@@ -6955,7 +6957,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"amqprs",
|
"amqprs",
|
||||||
"async-channel 1.9.0",
|
"async-channel 1.9.0",
|
||||||
@@ -6983,7 +6985,6 @@ dependencies = [
|
|||||||
"reqwest 0.11.27",
|
"reqwest 0.11.27",
|
||||||
"revolt-config",
|
"revolt-config",
|
||||||
"revolt-database",
|
"revolt-database",
|
||||||
"revolt-discord",
|
|
||||||
"revolt-models",
|
"revolt-models",
|
||||||
"revolt-permissions",
|
"revolt-permissions",
|
||||||
"revolt-presence",
|
"revolt-presence",
|
||||||
@@ -7004,22 +7005,9 @@ dependencies = [
|
|||||||
"vergen",
|
"vergen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "revolt-discord"
|
|
||||||
version = "0.11.3"
|
|
||||||
dependencies = [
|
|
||||||
"reqwest 0.12.23",
|
|
||||||
"revolt-database",
|
|
||||||
"revolt-models",
|
|
||||||
"revolt-permissions",
|
|
||||||
"revolt-result",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-files"
|
name = "revolt-files"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm",
|
"aes-gcm",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -7047,7 +7035,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-gifbox"
|
name = "revolt-gifbox"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-extra",
|
"axum-extra",
|
||||||
@@ -7070,7 +7058,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-january"
|
name = "revolt-january"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -7098,7 +7086,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-models"
|
name = "revolt-models"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap 1.9.3",
|
"indexmap 1.9.3",
|
||||||
"iso8601-timestamp",
|
"iso8601-timestamp",
|
||||||
@@ -7117,14 +7105,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-parser"
|
name = "revolt-parser"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos",
|
"logos",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-permissions"
|
name = "revolt-permissions"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -7139,7 +7127,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-presence"
|
name = "revolt-presence"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"log",
|
"log",
|
||||||
@@ -7151,7 +7139,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-pushd"
|
name = "revolt-pushd"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"amqprs",
|
"amqprs",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -7179,7 +7167,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-ratelimits"
|
name = "revolt-ratelimits"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"authifier",
|
"authifier",
|
||||||
@@ -7196,7 +7184,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-result"
|
name = "revolt-result"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"log",
|
"log",
|
||||||
@@ -7212,7 +7200,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-voice-ingress"
|
name = "revolt-voice-ingress"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"amqprs",
|
"amqprs",
|
||||||
"async-std",
|
"async-std",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
@@ -36,6 +36,7 @@ async-std = { version = "1.8.0", features = [
|
|||||||
"tokio02",
|
"tokio02",
|
||||||
"attributes",
|
"attributes",
|
||||||
] }
|
] }
|
||||||
|
async-trait = "0.1.89"
|
||||||
|
|
||||||
# core
|
# core
|
||||||
authifier = { version = "1.0.16" }
|
authifier = { version = "1.0.16" }
|
||||||
@@ -48,3 +49,6 @@ revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
|
|||||||
|
|
||||||
# redis
|
# redis
|
||||||
fred = { version = "8.0.1", features = ["subscriber-client"] }
|
fred = { version = "8.0.1", features = ["subscriber-client"] }
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
amqprs = { version = "1.7.0" }
|
||||||
@@ -398,7 +398,8 @@ impl State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Push presence change to the user and all associated server topics
|
/// Push presence change to the user and all associated server topics
|
||||||
pub async fn broadcast_presence_change(&self, target: bool) {
|
pub async fn broadcast_presence_change(&self, _target: bool) {
|
||||||
|
// disabled events
|
||||||
// if if let Some(status) = &self.cache.users.get(&self.cache.user_id).unwrap().status {
|
// if if let Some(status) = &self.cache.users.get(&self.cache.user_id).unwrap().status {
|
||||||
// status.presence != Some(Presence::Invisible)
|
// status.presence != Some(Presence::Invisible)
|
||||||
// } else {
|
// } else {
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
use amqprs::{
|
||||||
|
channel::{
|
||||||
|
BasicConsumeArguments, Channel, ExchangeDeclareArguments, QueueBindArguments,
|
||||||
|
QueueDeclareArguments,
|
||||||
|
},
|
||||||
|
connection::{Connection, OpenConnectionArguments},
|
||||||
|
consumer::AsyncConsumer,
|
||||||
|
BasicProperties, Deliver,
|
||||||
|
};
|
||||||
use async_std::net::TcpListener;
|
use async_std::net::TcpListener;
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use redis_kiss::AsyncCommands;
|
||||||
|
use revolt_database::util::rabbit::set_rabbitmq_connection;
|
||||||
use revolt_presence::clear_region;
|
use revolt_presence::clear_region;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@@ -31,6 +43,55 @@ async fn main() {
|
|||||||
let try_socket = TcpListener::bind(bind).await;
|
let try_socket = TcpListener::bind(bind).await;
|
||||||
let listener = try_socket.expect("Failed to bind");
|
let listener = try_socket.expect("Failed to bind");
|
||||||
|
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
|
let rmq_conn = Connection::open(&OpenConnectionArguments::new(
|
||||||
|
&config.rabbit.host,
|
||||||
|
config.rabbit.port,
|
||||||
|
&config.rabbit.username,
|
||||||
|
&config.rabbit.password,
|
||||||
|
))
|
||||||
|
.await
|
||||||
|
.expect("Failed to connect to RabbitMQ");
|
||||||
|
|
||||||
|
set_rabbitmq_connection(rmq_conn.clone());
|
||||||
|
|
||||||
|
if std::env::var("ENABLE_RABBITMQ_INGRESS").as_deref().is_ok_and(|v| v == "1") {
|
||||||
|
let channel = rmq_conn
|
||||||
|
.open_channel(None)
|
||||||
|
.await
|
||||||
|
.expect("Failed to open RabbitMQ channel.");
|
||||||
|
|
||||||
|
channel
|
||||||
|
.exchange_declare(
|
||||||
|
ExchangeDeclareArguments::new("events", "fanout")
|
||||||
|
.durable(true)
|
||||||
|
.finish(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to declare exchange");
|
||||||
|
|
||||||
|
channel
|
||||||
|
.queue_declare(QueueDeclareArguments::new("events").durable(true).finish())
|
||||||
|
.await
|
||||||
|
.expect("Failed to declare queue");
|
||||||
|
|
||||||
|
channel
|
||||||
|
.queue_bind(QueueBindArguments::new("events", "events", "events"))
|
||||||
|
.await
|
||||||
|
.expect("Failed to bind queue");
|
||||||
|
|
||||||
|
channel
|
||||||
|
.basic_consume(
|
||||||
|
RabbitToRedisConsumer,
|
||||||
|
BasicConsumeArguments::new("events", "")
|
||||||
|
.manual_ack(false)
|
||||||
|
.finish(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to consume channel");
|
||||||
|
}
|
||||||
|
|
||||||
// Start accepting new connections and spawn a client for each connection.
|
// Start accepting new connections and spawn a client for each connection.
|
||||||
while let Ok((stream, addr)) = listener.accept().await {
|
while let Ok((stream, addr)) = listener.accept().await {
|
||||||
async_std::task::spawn(async move {
|
async_std::task::spawn(async move {
|
||||||
@@ -40,3 +101,32 @@ async fn main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct RabbitToRedisConsumer;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl AsyncConsumer for RabbitToRedisConsumer {
|
||||||
|
async fn consume(
|
||||||
|
&mut self,
|
||||||
|
_channel: &Channel,
|
||||||
|
_deliver: Deliver,
|
||||||
|
basic_properties: BasicProperties,
|
||||||
|
content: Vec<u8>,
|
||||||
|
) {
|
||||||
|
let mut redis_conn = redis_kiss::get_connection()
|
||||||
|
.await
|
||||||
|
.expect("Failed to connect to Redis.");
|
||||||
|
|
||||||
|
let pubsub_channel = basic_properties
|
||||||
|
.headers()
|
||||||
|
.expect("No headers")
|
||||||
|
.get(&"c".try_into().unwrap())
|
||||||
|
.expect("No channel header")
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
redis_conn
|
||||||
|
.publish(pubsub_channel, content)
|
||||||
|
.await
|
||||||
|
.expect("failed to publish")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -218,7 +218,13 @@ async fn listener(
|
|||||||
kill_signal_r: async_channel::Receiver<()>,
|
kill_signal_r: async_channel::Receiver<()>,
|
||||||
write: &Mutex<WsWriter>,
|
write: &Mutex<WsWriter>,
|
||||||
) {
|
) {
|
||||||
let redis_config = RedisConfig::from_url(&REDIS_URI).unwrap();
|
let stoat_config = revolt_config::config().await;
|
||||||
|
let url = stoat_config
|
||||||
|
.database
|
||||||
|
.redis_pubsub
|
||||||
|
.unwrap_or(REDIS_URI.to_string());
|
||||||
|
|
||||||
|
let redis_config = RedisConfig::from_url(&url).unwrap();
|
||||||
let subscriber = match report_internal_error!(
|
let subscriber = match report_internal_error!(
|
||||||
fred::types::Builder::from_config(redis_config).build_subscriber_client()
|
fred::types::Builder::from_config(redis_config).build_subscriber_client()
|
||||||
) {
|
) {
|
||||||
@@ -457,8 +463,31 @@ async fn worker(
|
|||||||
};
|
};
|
||||||
|
|
||||||
match payload {
|
match payload {
|
||||||
ClientMessage::BeginTyping { .. } => {}
|
// disabled events
|
||||||
ClientMessage::EndTyping { .. } => {}
|
ClientMessage::BeginTyping { channel } => {
|
||||||
|
if !subscribed.read().await.contains(&channel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventV1::ChannelStartTyping {
|
||||||
|
id: channel.clone(),
|
||||||
|
user: user_id.clone(),
|
||||||
|
}
|
||||||
|
.p(channel.clone())
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
ClientMessage::EndTyping { channel } => {
|
||||||
|
if !subscribed.read().await.contains(&channel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventV1::ChannelStopTyping {
|
||||||
|
id: channel.clone(),
|
||||||
|
user: user_id.clone(),
|
||||||
|
}
|
||||||
|
.p(channel.clone())
|
||||||
|
.await;
|
||||||
|
}
|
||||||
ClientMessage::Subscribe { server_id } => {
|
ClientMessage::Subscribe { server_id } => {
|
||||||
let mut servers = active_servers.lock().await;
|
let mut servers = active_servers.lock().await;
|
||||||
let has_item = servers.contains_key(&server_id);
|
let has_item = servers.contains_key(&server_id);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-coalesced"
|
name = "revolt-coalesced"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>", "Zomatree <me@zomatree.live>"]
|
authors = ["Paul Makles <me@insrt.uk>", "Zomatree <me@zomatree.live>"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-config"
|
name = "revolt-config"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -38,4 +38,4 @@ sentry = { version = "0.31.5", optional = true }
|
|||||||
sentry-anyhow = { version = "0.38.1", optional = true }
|
sentry-anyhow = { version = "0.38.1", optional = true }
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { version = "0.11.3", path = "../result", optional = true }
|
revolt-result = { version = "0.11.5", path = "../result", optional = true }
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ voice_quality = 16000
|
|||||||
# Whether the user can use video streams in voice calls
|
# Whether the user can use video streams in voice calls
|
||||||
video = true
|
video = true
|
||||||
|
|
||||||
# Mamimum resolution (width, height) of video streams in voice calls
|
# Maximum resolution (width, height) of video streams in voice calls
|
||||||
video_resolution = [1080, 720]
|
video_resolution = [1080, 720]
|
||||||
|
|
||||||
# Minimum and maximum aspect ratio of video streams in voice calls
|
# Minimum and maximum aspect ratio of video streams in voice calls
|
||||||
@@ -283,8 +283,8 @@ voice_quality = 16000
|
|||||||
# Whether the user can use video streams in voice calls
|
# Whether the user can use video streams in voice calls
|
||||||
video = true
|
video = true
|
||||||
|
|
||||||
# Mamimum resolution (width, height) of video streams in voice calls
|
# Maximum resolution (width, height) of video streams in voice calls
|
||||||
video_resolution = [1080, 720]
|
video_resolution = [1280, 720]
|
||||||
|
|
||||||
# Minimum and maximum aspect ratio of video streams in voice calls
|
# Minimum and maximum aspect ratio of video streams in voice calls
|
||||||
video_aspect_ratio = [0.3, 2.5]
|
video_aspect_ratio = [0.3, 2.5]
|
||||||
@@ -312,4 +312,4 @@ files = ""
|
|||||||
proxy = ""
|
proxy = ""
|
||||||
pushd = ""
|
pushd = ""
|
||||||
crond = ""
|
crond = ""
|
||||||
gifbox = ""
|
gifbox = ""
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
|
|||||||
pub struct Database {
|
pub struct Database {
|
||||||
pub mongodb: String,
|
pub mongodb: String,
|
||||||
pub redis: String,
|
pub redis: String,
|
||||||
|
pub redis_pubsub: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -448,7 +449,7 @@ pub async fn config() -> Settings {
|
|||||||
let mut config = read().await.try_deserialize::<Settings>().unwrap();
|
let mut config = read().await.try_deserialize::<Settings>().unwrap();
|
||||||
|
|
||||||
// inject REDIS_URI for redis-kiss library
|
// inject REDIS_URI for redis-kiss library
|
||||||
if std::env::var("REDIS_URL").is_err() {
|
if std::env::var("REDIS_URI").is_err() {
|
||||||
std::env::set_var("REDIS_URI", config.database.redis.clone());
|
std::env::set_var("REDIS_URI", config.database.redis.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-database"
|
name = "revolt-database"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -32,19 +32,19 @@ default = ["mongodb", "async-std-runtime", "tasks"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { version = "0.11.3", path = "../config", features = [
|
revolt-config = { version = "0.11.5", path = "../config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.11.3", path = "../result" }
|
revolt-result = { version = "0.11.5", path = "../result" }
|
||||||
revolt-models = { version = "0.11.3", path = "../models", features = [
|
revolt-models = { version = "0.11.5", path = "../models", features = [
|
||||||
"validator",
|
"validator",
|
||||||
] }
|
] }
|
||||||
revolt-presence = { version = "0.11.3", path = "../presence" }
|
revolt-presence = { version = "0.11.5", path = "../presence" }
|
||||||
revolt-permissions = { version = "0.11.3", path = "../permissions", features = [
|
revolt-permissions = { version = "0.11.5", path = "../permissions", features = [
|
||||||
"serde",
|
"serde",
|
||||||
"bson",
|
"bson",
|
||||||
] }
|
] }
|
||||||
revolt-parser = { version = "0.11.3", path = "../parser" }
|
revolt-parser = { version = "0.11.5", path = "../parser" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ use revolt_presence::filter_online;
|
|||||||
|
|
||||||
use serde_json::to_string;
|
use serde_json::to_string;
|
||||||
|
|
||||||
|
// TODO: move away from storing Connection and Channel to using thread local singletons - #659
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AMQP {
|
pub struct AMQP {
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
|
use amqprs::{
|
||||||
|
channel::{BasicPublishArguments},
|
||||||
|
BasicProperties, FieldTable,
|
||||||
|
};
|
||||||
use authifier::AuthifierEvent;
|
use authifier::AuthifierEvent;
|
||||||
use revolt_result::Error;
|
use revolt_result::Error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use revolt_models::v0::{
|
use revolt_models::v0::{
|
||||||
AppendMessage, Channel, ChannelUnread, ChannelVoiceState, Emoji, FieldsChannel, FieldsMember, FieldsMessage, FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message, PartialChannel, PartialMember, PartialMessage, PartialRole, PartialServer, PartialUser, PartialUserVoiceState, PartialWebhook, PolicyChange, RemovalIntention, Report, Server, User, UserSettings, UserVoiceState, Webhook
|
AppendMessage, Channel, ChannelUnread, ChannelVoiceState, Emoji, FieldsChannel, FieldsMember,
|
||||||
|
FieldsMessage, FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey,
|
||||||
|
Message, PartialChannel, PartialMember, PartialMessage, PartialRole, PartialServer,
|
||||||
|
PartialUser, PartialUserVoiceState, PartialWebhook, PolicyChange, RemovalIntention, Report,
|
||||||
|
Server, User, UserSettings, UserVoiceState, Webhook,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Database;
|
use crate::{util::rabbit::get_channel, Database};
|
||||||
|
|
||||||
/// Ping Packet
|
/// Ping Packet
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
@@ -304,14 +312,23 @@ pub enum EventV1 {
|
|||||||
impl EventV1 {
|
impl EventV1 {
|
||||||
/// Publish helper wrapper
|
/// Publish helper wrapper
|
||||||
pub async fn p(self, channel: String) {
|
pub async fn p(self, channel: String) {
|
||||||
#[cfg(not(debug_assertions))]
|
|
||||||
redis_kiss::p(channel, self).await;
|
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
info!("Publishing event to {channel}: {self:?}");
|
info!("Publishing event to {channel}: {self:?}");
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
let rmq = get_channel().await;
|
||||||
redis_kiss::publish(channel, self).await.unwrap();
|
|
||||||
|
let mut headers = FieldTable::new();
|
||||||
|
headers.insert("c".try_into().unwrap(), channel.clone().into());
|
||||||
|
let mut properties = BasicProperties::default();
|
||||||
|
properties.with_headers(headers);
|
||||||
|
|
||||||
|
rmq.basic_publish(
|
||||||
|
properties,
|
||||||
|
serde_json::to_string(&self).unwrap().into_bytes(),
|
||||||
|
BasicPublishArguments::new("events", "events"),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Publish user event
|
/// Publish user event
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
|||||||
use revolt_result::{create_error, Result};
|
use revolt_result::{create_error, Result};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::client::EventV1, util::permissions::DatabasePermissionQuery, Channel, Database, File,
|
events::client::EventV1, util::permissions::DatabasePermissionQuery, Channel,
|
||||||
Server, SystemMessage, User,
|
Database, File, Server, SystemMessage, User,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn default_true() -> bool {
|
fn default_true() -> bool {
|
||||||
@@ -332,7 +332,6 @@ mod tests {
|
|||||||
name: "Server".to_string(),
|
name: "Server".to_string(),
|
||||||
description: None,
|
description: None,
|
||||||
nsfw: None,
|
nsfw: None,
|
||||||
discord_template_id: None,
|
|
||||||
},
|
},
|
||||||
&owner,
|
&owner,
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -653,14 +653,14 @@ impl User {
|
|||||||
self.apply_options(partial.clone());
|
self.apply_options(partial.clone());
|
||||||
db.update_user(&self.id, &partial, remove.clone()).await?;
|
db.update_user(&self.id, &partial, remove.clone()).await?;
|
||||||
|
|
||||||
// EventV1::UserUpdate {
|
EventV1::UserUpdate {
|
||||||
// id: self.id.clone(),
|
id: self.id.clone(),
|
||||||
// data: partial.into(),
|
data: partial.into(),
|
||||||
// clear: remove.into_iter().map(|v| v.into()).collect(),
|
clear: remove.into_iter().map(|v| v.into()).collect(),
|
||||||
// event_id: Some(Ulid::new().to_string()),
|
event_id: Some(Ulid::new().to_string()),
|
||||||
// }
|
}
|
||||||
// .p_user(self.id.clone(), db)
|
.p_user(self.id.clone(), db)
|
||||||
// .await;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ pub mod idempotency;
|
|||||||
pub mod permissions;
|
pub mod permissions;
|
||||||
pub mod reference;
|
pub mod reference;
|
||||||
pub mod test_fixtures;
|
pub mod test_fixtures;
|
||||||
|
pub mod rabbit;
|
||||||
|
|
||||||
pub use funcs::*;
|
pub use funcs::*;
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
use amqprs::{channel::Channel, connection::Connection};
|
||||||
|
use once_cell::sync::OnceCell;
|
||||||
|
use std::{
|
||||||
|
collections::HashMap, future::ready, sync::{LazyLock, RwLock}, thread::{ThreadId, current}
|
||||||
|
};
|
||||||
|
|
||||||
|
static RABBIT_CONNECTION: OnceCell<Connection> = OnceCell::new();
|
||||||
|
static RABBIT_CHANNELS: LazyLock<RwLock<HashMap<ThreadId, Channel>>> =
|
||||||
|
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
|
pub async fn get_channel_with_init<F: AsyncFnOnce(Channel) -> Channel>(init: F) -> Channel {
|
||||||
|
let conn = RABBIT_CONNECTION
|
||||||
|
.get()
|
||||||
|
.expect("Rabbit connection is not initialised.");
|
||||||
|
|
||||||
|
let thread_id = current().id();
|
||||||
|
|
||||||
|
let channel = RABBIT_CHANNELS
|
||||||
|
.read()
|
||||||
|
.expect("Channels poisioned")
|
||||||
|
.get(&thread_id)
|
||||||
|
.cloned();
|
||||||
|
|
||||||
|
if let Some(channel) = channel {
|
||||||
|
channel
|
||||||
|
} else {
|
||||||
|
let mut channel =
|
||||||
|
conn.open_channel(None)
|
||||||
|
.await
|
||||||
|
.expect("Failed to open rabbitmq channel");
|
||||||
|
|
||||||
|
channel = init(channel).await;
|
||||||
|
|
||||||
|
RABBIT_CHANNELS
|
||||||
|
.write()
|
||||||
|
.expect("Channels poisioned")
|
||||||
|
.insert(thread_id, channel.clone());
|
||||||
|
channel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_channel() -> Channel {
|
||||||
|
get_channel_with_init(ready).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_rabbitmq_connection(connection: Connection) -> bool {
|
||||||
|
RABBIT_CONNECTION.set(connection).is_ok()
|
||||||
|
}
|
||||||
@@ -16,7 +16,9 @@ mod voice_client;
|
|||||||
pub use voice_client::VoiceClient;
|
pub use voice_client::VoiceClient;
|
||||||
|
|
||||||
async fn get_connection() -> Result<Conn> {
|
async fn get_connection() -> Result<Conn> {
|
||||||
_get_connection().await.map_err(|_| create_error!(InternalError))
|
_get_connection()
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_error!(InternalError))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn raise_if_in_voice(user: &User, channel_id: &str) -> Result<()> {
|
pub async fn raise_if_in_voice(user: &User, channel_id: &str) -> Result<()> {
|
||||||
@@ -59,6 +61,14 @@ pub async fn get_channel_node(channel: &str) -> Result<Option<String>> {
|
|||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn delete_channel_node(channel: &str) -> Result<()> {
|
||||||
|
get_connection()
|
||||||
|
.await?
|
||||||
|
.del(format!("node:{channel}"))
|
||||||
|
.await
|
||||||
|
.to_internal_error()
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_user_voice_channels(user_id: &str) -> Result<Vec<String>> {
|
pub async fn get_user_voice_channels(user_id: &str) -> Result<Vec<String>> {
|
||||||
get_connection()
|
get_connection()
|
||||||
.await?
|
.await?
|
||||||
@@ -226,6 +236,7 @@ pub async fn delete_channel_voice_state(
|
|||||||
|
|
||||||
let mut pipeline = Pipeline::new();
|
let mut pipeline = Pipeline::new();
|
||||||
pipeline.del(format!("vc_members:{channel_id}"));
|
pipeline.del(format!("vc_members:{channel_id}"));
|
||||||
|
pipeline.del(format!("node:{channel_id}"));
|
||||||
|
|
||||||
for user_id in user_ids {
|
for user_id in user_ids {
|
||||||
let unique_key = format!("{user_id}:{parent_id}");
|
let unique_key = format!("{user_id}:{parent_id}");
|
||||||
@@ -567,15 +578,24 @@ pub async fn get_call_notification_recipients(
|
|||||||
.to_internal_error()
|
.to_internal_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn remove_user_from_voice_channels(db: &Database, voice_client: &VoiceClient, user_id: &str) -> Result<()> {
|
pub async fn remove_user_from_voice_channels(
|
||||||
|
db: &Database,
|
||||||
|
voice_client: &VoiceClient,
|
||||||
|
user_id: &str,
|
||||||
|
) -> Result<()> {
|
||||||
for channel_id in get_user_voice_channels(user_id).await? {
|
for channel_id in get_user_voice_channels(user_id).await? {
|
||||||
remove_user_from_voice_channel(db, voice_client, &channel_id, user_id).await?;
|
remove_user_from_voice_channel(db, voice_client, &channel_id, user_id).await?;
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn remove_user_from_voice_channel(db: &Database, voice_client: &VoiceClient, channel_id: &str, user_id: &str) -> Result<()> {
|
pub async fn remove_user_from_voice_channel(
|
||||||
|
db: &Database,
|
||||||
|
voice_client: &VoiceClient,
|
||||||
|
channel_id: &str,
|
||||||
|
user_id: &str,
|
||||||
|
) -> Result<()> {
|
||||||
if let Some(node) = get_channel_node(channel_id).await? {
|
if let Some(node) = get_channel_node(channel_id).await? {
|
||||||
let _ = voice_client.remove_user(&node, user_id, channel_id).await;
|
let _ = voice_client.remove_user(&node, user_id, channel_id).await;
|
||||||
}
|
}
|
||||||
@@ -587,7 +607,11 @@ pub async fn remove_user_from_voice_channel(db: &Database, voice_client: &VoiceC
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_voice_channel(voice_client: &VoiceClient, channel_id: &str, server_id: Option<&str>) -> Result<()> {
|
pub async fn delete_voice_channel(
|
||||||
|
voice_client: &VoiceClient,
|
||||||
|
channel_id: &str,
|
||||||
|
server_id: Option<&str>,
|
||||||
|
) -> Result<()> {
|
||||||
if let Some(users) = get_voice_channel_members(channel_id).await? {
|
if let Some(users) = get_voice_channel_members(channel_id).await? {
|
||||||
let node = get_channel_node(channel_id).await?.unwrap();
|
let node = get_channel_node(channel_id).await?.unwrap();
|
||||||
|
|
||||||
@@ -597,4 +621,4 @@ pub async fn delete_voice_channel(voice_client: &VoiceClient, channel_id: &str,
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "revolt-discord"
|
|
||||||
version = "0.11.3"
|
|
||||||
edition = "2021"
|
|
||||||
license = "MIT"
|
|
||||||
authors = ["Zomatree <me@zomatree.live>"]
|
|
||||||
description = "Revolt Backend: Discord Compatibility"
|
|
||||||
repository = "https://github.com/stoatchat/stoatchat"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[features]
|
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
# Core
|
|
||||||
revolt-result = { version = "0.11.3", path = "../result" }
|
|
||||||
revolt-database = { version = "0.11.3", path = "../database" }
|
|
||||||
revolt-permissions = { version = "0.11.3", path = "../permissions" }
|
|
||||||
revolt-models = { version = "0.11.3", path = "../models" }
|
|
||||||
|
|
||||||
# Serialisation
|
|
||||||
serde_json = { version = "1" }
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
|
||||||
|
|
||||||
# Http
|
|
||||||
reqwest = { version = "0.12", features = ["json"] }
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
pub mod types;
|
|
||||||
pub mod template;
|
|
||||||
@@ -1,275 +0,0 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use revolt_models::v0;
|
|
||||||
use revolt_permissions::OverrideField;
|
|
||||||
|
|
||||||
use crate::types as discord;
|
|
||||||
use revolt_database::{
|
|
||||||
Category, Channel, Database, PartialChannel, PartialRole, PartialServer, Role, Server,
|
|
||||||
SystemMessageChannels,
|
|
||||||
};
|
|
||||||
use revolt_result::{Result, ToRevoltError};
|
|
||||||
|
|
||||||
pub async fn fetch_template(template_id: &str) -> Result<discord::GuildTemplate> {
|
|
||||||
reqwest::get(format!(
|
|
||||||
"https://discord.com/api/v10/guilds/templates/{template_id}"
|
|
||||||
))
|
|
||||||
.await
|
|
||||||
.to_internal_error()?
|
|
||||||
.json()
|
|
||||||
.await
|
|
||||||
.to_internal_error()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn import_template(
|
|
||||||
db: &Database,
|
|
||||||
server: &mut Server,
|
|
||||||
template: discord::GuildTemplate,
|
|
||||||
) -> Result<Vec<Channel>> {
|
|
||||||
let mut role_mapping = HashMap::new();
|
|
||||||
let mut channel_mapping = HashMap::new();
|
|
||||||
let mut categories = HashMap::new();
|
|
||||||
|
|
||||||
for discord_channel in &template.serialized_source_guild.channels {
|
|
||||||
if discord_channel.channel_type == discord::ChannelType::Category as u32 {
|
|
||||||
categories.insert(discord_channel.id, discord_channel.clone());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut role_positions = template.serialized_source_guild.roles
|
|
||||||
.iter()
|
|
||||||
.filter(|r| r.id != 0)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
role_positions.sort_by(|a, b| b.id.cmp(&a.id));
|
|
||||||
|
|
||||||
let role_positions = role_positions
|
|
||||||
.into_iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(i, r)| (r.id, i as i64))
|
|
||||||
.collect::<HashMap<_, _>>();
|
|
||||||
|
|
||||||
for discord_role in template.serialized_source_guild.roles.clone() {
|
|
||||||
if discord_role.id == 0 {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
role_mapping.insert(
|
|
||||||
discord_role.id,
|
|
||||||
convert_role(db, server, role_positions[&discord_role.id], discord_role).await?,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
for discord_channel in template.serialized_source_guild.channels.clone() {
|
|
||||||
if discord_channel.channel_type == discord::ChannelType::Category as u32 {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
channel_mapping.insert(
|
|
||||||
discord_channel.id,
|
|
||||||
convert_channel(db, server, &categories, &role_mapping, discord_channel).await?,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
convert_server(db, server, &channel_mapping, template.serialized_source_guild).await?;
|
|
||||||
|
|
||||||
Ok(channel_mapping.into_values().collect())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn convert_role(db: &Database, server: &mut Server, rank: i64, role: discord::Role) -> Result<Role> {
|
|
||||||
let mut role_payload = Role::create(db, server, role.name).await?;
|
|
||||||
let mut partial = PartialRole {
|
|
||||||
rank: Some(rank),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
if role.hoist {
|
|
||||||
partial.hoist = Some(true)
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(colors) = role.colors {
|
|
||||||
if colors.primary_color != 0 {
|
|
||||||
partial.colour = Some(format!("#{:x}", colors.primary_color))
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if &role.permissions != "0" {
|
|
||||||
let allow = convert_permissions(&role.permissions);
|
|
||||||
partial.permissions = Some(OverrideField { a: allow, d: 0 });
|
|
||||||
};
|
|
||||||
|
|
||||||
role_payload
|
|
||||||
.update(db, &server.id, partial, Vec::new())
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
server.roles.insert(role_payload.id.clone(), role_payload.clone());
|
|
||||||
|
|
||||||
Ok(role_payload)
|
|
||||||
}
|
|
||||||
|
|
||||||
static PERMISSION_MAPPING: &[(i64, i64)] = &[];
|
|
||||||
|
|
||||||
pub fn convert_permissions(permissions: &str) -> i64 {
|
|
||||||
let value = permissions.parse::<i64>().unwrap();
|
|
||||||
let mut output = 0;
|
|
||||||
|
|
||||||
for (discord_perm, perm) in PERMISSION_MAPPING {
|
|
||||||
if (value & *discord_perm) == *discord_perm {
|
|
||||||
output |= *perm
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
output
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn convert_channel(
|
|
||||||
db: &Database,
|
|
||||||
server: &mut Server,
|
|
||||||
categories: &HashMap<u32, discord::Channel>,
|
|
||||||
role_mapping: &HashMap<u32, Role>,
|
|
||||||
channel: discord::Channel,
|
|
||||||
) -> Result<Channel> {
|
|
||||||
let mut channel_payload = Channel::create_server_channel(
|
|
||||||
db,
|
|
||||||
server,
|
|
||||||
v0::DataCreateServerChannel {
|
|
||||||
channel_type: v0::LegacyServerChannelType::Text,
|
|
||||||
name: channel.name,
|
|
||||||
description: channel.topic,
|
|
||||||
nsfw: channel.nsfw,
|
|
||||||
voice: if channel.channel_type == discord::ChannelType::Voice as u32
|
|
||||||
|| channel.channel_type == discord::ChannelType::StageVoice as u32
|
|
||||||
{
|
|
||||||
Some(v0::VoiceInformation {
|
|
||||||
max_users: channel.user_limit.map(|limit| limit as usize),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let mut partial = PartialChannel::default();
|
|
||||||
let mut role_permissions = HashMap::new();
|
|
||||||
|
|
||||||
if let Some(parent_id) = channel.parent_id {
|
|
||||||
let category = categories.get(&parent_id).unwrap();
|
|
||||||
|
|
||||||
for discord_overwrite in category.permission_overwrites.iter().flatten() {
|
|
||||||
if discord_overwrite.overwrite_type == discord::OverwriteType::Member as u32 {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
let overwrite = OverrideField {
|
|
||||||
a: convert_permissions(&discord_overwrite.allow),
|
|
||||||
d: convert_permissions(&discord_overwrite.deny),
|
|
||||||
};
|
|
||||||
|
|
||||||
if discord_overwrite.id == 0 {
|
|
||||||
partial.default_permissions = Some(overwrite)
|
|
||||||
} else {
|
|
||||||
role_permissions.insert(
|
|
||||||
role_mapping.get(&discord_overwrite.id).unwrap().id.clone(),
|
|
||||||
overwrite,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for discord_overwrite in channel.permission_overwrites.iter().flatten() {
|
|
||||||
if discord_overwrite.overwrite_type == discord::OverwriteType::Member as u32 {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
let overwrite = OverrideField {
|
|
||||||
a: convert_permissions(&discord_overwrite.allow),
|
|
||||||
d: convert_permissions(&discord_overwrite.deny),
|
|
||||||
};
|
|
||||||
|
|
||||||
if discord_overwrite.id == 0 {
|
|
||||||
if let Some(default_permissions) = &mut partial.default_permissions {
|
|
||||||
default_permissions.a |= overwrite.a;
|
|
||||||
default_permissions.d |= overwrite.d;
|
|
||||||
} else {
|
|
||||||
partial.default_permissions = Some(overwrite)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let id = &role_mapping.get(&discord_overwrite.id).unwrap().id;
|
|
||||||
|
|
||||||
if let Some(role_permission) = role_permissions.get_mut(id) {
|
|
||||||
role_permission.a |= overwrite.a;
|
|
||||||
role_permission.d |= overwrite.d;
|
|
||||||
} else {
|
|
||||||
role_permissions.insert(id.clone(), overwrite);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
partial.role_permissions = Some(role_permissions);
|
|
||||||
|
|
||||||
channel_payload.update(db, partial, Vec::new()).await?;
|
|
||||||
|
|
||||||
Ok(channel_payload)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn convert_server(
|
|
||||||
db: &Database,
|
|
||||||
server: &mut Server,
|
|
||||||
channel_mapping: &HashMap<u32, Channel>,
|
|
||||||
guild: discord::Guild,
|
|
||||||
) -> Result<()> {
|
|
||||||
let mut partial = PartialServer {
|
|
||||||
categories: Some(
|
|
||||||
guild
|
|
||||||
.channels
|
|
||||||
.iter()
|
|
||||||
.filter(|c| c.channel_type == discord::ChannelType::Category as u32)
|
|
||||||
.map(|category| {
|
|
||||||
let mut channels = guild
|
|
||||||
.channels
|
|
||||||
.iter()
|
|
||||||
.filter(|c| c.parent_id.as_ref() == Some(&category.id))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
channels.sort_by(|a, b| a.position.cmp(&b.position));
|
|
||||||
|
|
||||||
Category {
|
|
||||||
id: category.id.to_string(),
|
|
||||||
title: category.name.clone(),
|
|
||||||
channels: channels
|
|
||||||
.into_iter()
|
|
||||||
.map(|c| channel_mapping.get(&c.id).unwrap().id().to_string())
|
|
||||||
.collect(),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect(),
|
|
||||||
),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: banner
|
|
||||||
|
|
||||||
if let Some(system_channel_id) = &guild.system_channel_id {
|
|
||||||
let channel_id = channel_mapping
|
|
||||||
.get(system_channel_id)
|
|
||||||
.unwrap()
|
|
||||||
.id()
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
partial.system_messages = Some(SystemMessageChannels {
|
|
||||||
user_banned: Some(channel_id.clone()),
|
|
||||||
user_joined: Some(channel_id.clone()),
|
|
||||||
user_kicked: Some(channel_id.clone()),
|
|
||||||
user_left: Some(channel_id),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
let default_role = guild.roles.iter().find(|r| r.id == 0).unwrap();
|
|
||||||
partial.default_permissions = Some(convert_permissions(&default_role.permissions));
|
|
||||||
|
|
||||||
server.update(db, partial, Vec::new()).await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
use serde::{Serialize, Deserialize};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct GuildTemplate {
|
|
||||||
pub serialized_source_guild: Guild
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
|
||||||
pub struct Guild {
|
|
||||||
pub name: String,
|
|
||||||
pub banner: Option<String>,
|
|
||||||
pub roles: Vec<Role>,
|
|
||||||
pub channels: Vec<Channel>,
|
|
||||||
pub system_channel_id: Option<u32>,
|
|
||||||
pub description: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
|
||||||
pub struct Role {
|
|
||||||
pub id: u32,
|
|
||||||
pub name: String,
|
|
||||||
pub colors: Option<RoleColor>,
|
|
||||||
pub hoist: bool,
|
|
||||||
pub icon: Option<String>,
|
|
||||||
pub position: Option<u32>,
|
|
||||||
pub permissions: String,
|
|
||||||
pub mentionable: bool
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
|
||||||
pub struct RoleColor {
|
|
||||||
pub primary_color: u64,
|
|
||||||
pub secondary_color: Option<u64>,
|
|
||||||
pub tertiary_color: Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
|
||||||
pub struct Channel {
|
|
||||||
pub id: u32,
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
pub channel_type: u32,
|
|
||||||
pub position: u32,
|
|
||||||
pub permission_overwrites: Option<Vec<Overwrite>>,
|
|
||||||
pub name: String,
|
|
||||||
pub topic: Option<String>,
|
|
||||||
pub nsfw: Option<bool>,
|
|
||||||
pub user_limit: Option<u32>,
|
|
||||||
pub parent_id: Option<u32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
|
||||||
pub enum ChannelType {
|
|
||||||
Text = 0,
|
|
||||||
DM = 1,
|
|
||||||
Voice = 2,
|
|
||||||
Group = 3,
|
|
||||||
Category = 4,
|
|
||||||
Announcement = 5,
|
|
||||||
AnnouncementThread = 10,
|
|
||||||
PublicThread = 11,
|
|
||||||
PrivateThread = 12,
|
|
||||||
StageVoice = 13,
|
|
||||||
Directory = 14,
|
|
||||||
Forum = 15,
|
|
||||||
Media = 16,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
|
||||||
pub struct Overwrite {
|
|
||||||
pub id: u32,
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
pub overwrite_type: u32,
|
|
||||||
pub allow: String,
|
|
||||||
pub deny: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
|
||||||
pub enum OverwriteType {
|
|
||||||
Role = 0,
|
|
||||||
Member = 1,
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-files"
|
name = "revolt-files"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
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>"]
|
||||||
@@ -27,10 +27,10 @@ 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.11.3", path = "../config", features = [
|
revolt-config = { version = "0.11.5", path = "../config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.11.3", path = "../result" }
|
revolt-result = { version = "0.11.5", path = "../result" }
|
||||||
|
|
||||||
# image processing
|
# image processing
|
||||||
jxl-oxide = { workspace = true }
|
jxl-oxide = { workspace = true }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-models"
|
name = "revolt-models"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -21,8 +21,8 @@ default = ["serde", "partials", "rocket"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { version = "0.11.3", path = "../config" }
|
revolt-config = { version = "0.11.5", path = "../config" }
|
||||||
revolt-permissions = { version = "0.11.3", path = "../permissions" }
|
revolt-permissions = { version = "0.11.5", path = "../permissions" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
regex = "1.11"
|
regex = "1.11"
|
||||||
|
|||||||
@@ -167,9 +167,6 @@ auto_derived!(
|
|||||||
/// Whether this server is age-restricted
|
/// Whether this server is age-restricted
|
||||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub nsfw: Option<bool>,
|
pub nsfw: Option<bool>,
|
||||||
/// Discord guild template to import from
|
|
||||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
|
||||||
pub discord_template_id: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about new role to create
|
/// Information about new role to create
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-parser"
|
name = "revolt-parser"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-permissions"
|
name = "revolt-permissions"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -22,7 +22,7 @@ async-std = { version = "1.8.0", features = ["attributes"] }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { version = "0.11.3", path = "../result" }
|
revolt-result = { version = "0.11.5", path = "../result" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
auto_ops = "0.3.0"
|
auto_ops = "0.3.0"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-presence"
|
name = "revolt-presence"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
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>"]
|
||||||
@@ -17,7 +17,7 @@ redis-is-patched = []
|
|||||||
async-std = { version = "1.8.0", features = ["attributes"] }
|
async-std = { version = "1.8.0", features = ["attributes"] }
|
||||||
|
|
||||||
# Config for loading Redis URI
|
# Config for loading Redis URI
|
||||||
revolt-config = { version = "0.11.3", path = "../config" }
|
revolt-config = { version = "0.11.5", path = "../config" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-ratelimits"
|
name = "revolt-ratelimits"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
||||||
@@ -18,9 +18,9 @@ axum = ["dep:axum", "revolt-database/axum-impl"]
|
|||||||
default = ["rocket", "axum"]
|
default = ["rocket", "axum"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
revolt-database = { version = "0.11.3", path = "../database" }
|
revolt-database = { version = "0.11.5", path = "../database" }
|
||||||
revolt-result = { version = "0.11.3", path = "../result" }
|
revolt-result = { version = "0.11.5", path = "../result" }
|
||||||
revolt-config = { version = "0.11.3", path = "../config" }
|
revolt-config = { version = "0.11.5", path = "../config" }
|
||||||
|
|
||||||
rocket = { version = "0.5.1", optional = true }
|
rocket = { version = "0.5.1", optional = true }
|
||||||
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-result"
|
name = "revolt-result"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-crond"
|
name = "revolt-crond"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -17,7 +17,7 @@ log = "0.4"
|
|||||||
tokio = { version = "1" }
|
tokio = { version = "1" }
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-database = { version = "0.11.3", path = "../../core/database" }
|
revolt-database = { version = "0.11.5", path = "../../core/database" }
|
||||||
revolt-result = { version = "0.11.3", path = "../../core/result" }
|
revolt-result = { version = "0.11.5", path = "../../core/result" }
|
||||||
revolt-config = { version = "0.11.3", path = "../../core/config" }
|
revolt-config = { version = "0.11.5", path = "../../core/config" }
|
||||||
revolt-files = { version = "0.11.3", path = "../../core/files" }
|
revolt-files = { version = "0.11.5", path = "../../core/files" }
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-pushd"
|
name = "revolt-pushd"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
revolt-result = { version = "0.11.3", path = "../../core/result" }
|
revolt-result = { version = "0.11.5", path = "../../core/result" }
|
||||||
revolt-config = { version = "0.11.3", path = "../../core/config", features = [
|
revolt-config = { version = "0.11.5", path = "../../core/config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
] }
|
] }
|
||||||
revolt-database = { version = "0.11.3", path = "../../core/database" }
|
revolt-database = { version = "0.11.5", path = "../../core/database" }
|
||||||
revolt-models = { version = "0.11.3", path = "../../core/models", features = [
|
revolt-models = { version = "0.11.5", path = "../../core/models", features = [
|
||||||
"validator",
|
"validator",
|
||||||
] }
|
] }
|
||||||
revolt-presence = { version = "0.11.3", path = "../../core/presence", features = [
|
revolt-presence = { version = "0.11.5", path = "../../core/presence", features = [
|
||||||
"redis-is-patched",
|
"redis-is-patched",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ impl DmCallConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ impl FRAcceptedConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ impl FRReceivedConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ impl GenericConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ impl MassMessageConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ impl MessageConsumer {
|
|||||||
config.pushd.vapid.queue.as_str(),
|
config.pushd.vapid.queue.as_str(),
|
||||||
)
|
)
|
||||||
.finish();
|
.finish();
|
||||||
sendable.extras.insert("p265dh".to_string(), sub.p256dh);
|
sendable.extras.insert("p256dh".to_string(), sub.p256dh);
|
||||||
sendable
|
sendable
|
||||||
.extras
|
.extras
|
||||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-voice-ingress"
|
name = "revolt-voice-ingress"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ use revolt_database::{
|
|||||||
iso8601_timestamp::{Duration, Timestamp},
|
iso8601_timestamp::{Duration, Timestamp},
|
||||||
util::reference::Reference,
|
util::reference::Reference,
|
||||||
voice::{
|
voice::{
|
||||||
create_voice_state, delete_voice_state,
|
create_voice_state, delete_channel_node, delete_voice_state, get_user_moved_from_voice,
|
||||||
get_user_moved_from_voice, get_user_moved_to_voice,
|
get_user_moved_to_voice, get_voice_channel_members, update_voice_state_tracks, VoiceClient,
|
||||||
update_voice_state_tracks, VoiceClient,
|
|
||||||
},
|
},
|
||||||
Database, AMQP,
|
Database, AMQP,
|
||||||
};
|
};
|
||||||
@@ -160,6 +159,8 @@ pub async fn ingress(
|
|||||||
// let members = get_voice_channel_members(channel_id).await?;
|
// let members = get_voice_channel_members(channel_id).await?;
|
||||||
|
|
||||||
// if members.is_none_or(|m| m.is_empty()) {
|
// if members.is_none_or(|m| m.is_empty()) {
|
||||||
|
// delete_channel_node(channel_id).await?;
|
||||||
|
//
|
||||||
// // The channel is empty so send out an "end" message for ringing
|
// // The channel is empty so send out an "end" message for ringing
|
||||||
// if let Err(e) = amqp
|
// if let Err(e) = amqp
|
||||||
// .dm_call_updated(user_id, channel_id, None, true, None)
|
// .dm_call_updated(user_id, channel_id, None, true, None)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -84,7 +84,6 @@ revolt-presence = { path = "../core/presence" }
|
|||||||
revolt-result = { path = "../core/result", features = ["rocket", "okapi"] }
|
revolt-result = { path = "../core/result", features = ["rocket", "okapi"] }
|
||||||
revolt-permissions = { path = "../core/permissions", features = ["schemas"] }
|
revolt-permissions = { path = "../core/permissions", features = ["schemas"] }
|
||||||
revolt-ratelimits = { path = "../core/ratelimits", features = ["rocket"] }
|
revolt-ratelimits = { path = "../core/ratelimits", features = ["rocket"] }
|
||||||
revolt-discord = { path = "../core/discord" }
|
|
||||||
|
|
||||||
# voice
|
# voice
|
||||||
livekit-api = "0.4.4"
|
livekit-api = "0.4.4"
|
||||||
|
|||||||
+14
-36
@@ -9,8 +9,7 @@ pub mod routes;
|
|||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
use revolt_config::config;
|
use revolt_config::config;
|
||||||
use revolt_database::events::client::EventV1;
|
use revolt_database::{AMQP, util::rabbit::{get_channel, get_channel_with_init, set_rabbitmq_connection}};
|
||||||
use revolt_database::AMQP;
|
|
||||||
use revolt_ratelimits::rocket as ratelimiter;
|
use revolt_ratelimits::rocket as ratelimiter;
|
||||||
use rocket::{Build, Rocket};
|
use rocket::{Build, Rocket};
|
||||||
use rocket_cors::{AllowedOrigins, CorsOptions};
|
use rocket_cors::{AllowedOrigins, CorsOptions};
|
||||||
@@ -19,11 +18,9 @@ use std::net::Ipv4Addr;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use amqprs::{
|
use amqprs::{
|
||||||
channel::ExchangeDeclareArguments,
|
channel::{Channel, ExchangeDeclareArguments},
|
||||||
connection::{Connection, OpenConnectionArguments},
|
connection::{Connection, OpenConnectionArguments},
|
||||||
};
|
};
|
||||||
use async_std::channel::unbounded;
|
|
||||||
use authifier::AuthifierEvent;
|
|
||||||
use rocket::data::ToByteUnit;
|
use rocket::data::ToByteUnit;
|
||||||
use revolt_database::voice::VoiceClient;
|
use revolt_database::voice::VoiceClient;
|
||||||
|
|
||||||
@@ -39,28 +36,9 @@ pub async fn web() -> Rocket<Build> {
|
|||||||
log::info!("database_here {db:?}");
|
log::info!("database_here {db:?}");
|
||||||
db.migrate_database().await.unwrap();
|
db.migrate_database().await.unwrap();
|
||||||
|
|
||||||
// Setup Authifier event channel
|
|
||||||
let (_, receiver) = unbounded();
|
|
||||||
|
|
||||||
// Setup Authifier
|
// Setup Authifier
|
||||||
let authifier = db.clone().to_authifier().await;
|
let authifier = db.clone().to_authifier().await;
|
||||||
|
|
||||||
// Launch a listener for Authifier events
|
|
||||||
async_std::task::spawn(async move {
|
|
||||||
while let Ok(event) = receiver.recv().await {
|
|
||||||
match &event {
|
|
||||||
AuthifierEvent::CreateSession { .. } | AuthifierEvent::CreateAccount { .. } => {
|
|
||||||
EventV1::Auth(event).global().await
|
|
||||||
}
|
|
||||||
AuthifierEvent::DeleteSession { user_id, .. }
|
|
||||||
| AuthifierEvent::DeleteAllSessions { user_id, .. } => {
|
|
||||||
let id = user_id.to_string();
|
|
||||||
EventV1::Auth(event).private(id).await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Configure CORS
|
// Configure CORS
|
||||||
let cors = CorsOptions {
|
let cors = CorsOptions {
|
||||||
allowed_origins: AllowedOrigins::All,
|
allowed_origins: AllowedOrigins::All,
|
||||||
@@ -121,19 +99,19 @@ pub async fn web() -> Rocket<Build> {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to connect to RabbitMQ");
|
.expect("Failed to connect to RabbitMQ");
|
||||||
|
|
||||||
let channel = connection
|
set_rabbitmq_connection(connection.clone());
|
||||||
.open_channel(None)
|
let channel = get_channel_with_init(|channel: Channel| async {
|
||||||
.await
|
channel
|
||||||
.expect("Failed to open RabbitMQ channel");
|
.exchange_declare(
|
||||||
|
ExchangeDeclareArguments::new(&config.pushd.exchange, "direct")
|
||||||
|
.durable(true)
|
||||||
|
.finish(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to declare exchange");
|
||||||
|
|
||||||
channel
|
channel
|
||||||
.exchange_declare(
|
}).await;
|
||||||
ExchangeDeclareArguments::new(&config.pushd.exchange, "direct")
|
|
||||||
.durable(true)
|
|
||||||
.finish(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.expect("Failed to declare exchange");
|
|
||||||
|
|
||||||
let amqp = AMQP::new(connection, channel);
|
let amqp = AMQP::new(connection, channel);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use revolt_database::{
|
|||||||
util::{permissions::perms, reference::Reference},
|
util::{permissions::perms, reference::Reference},
|
||||||
voice::{
|
voice::{
|
||||||
delete_voice_state, get_channel_node, get_user_voice_channels, get_voice_channel_members,
|
delete_voice_state, get_channel_node, get_user_voice_channels, get_voice_channel_members,
|
||||||
raise_if_in_voice, set_call_notification_recipients, VoiceClient,
|
raise_if_in_voice, set_call_notification_recipients, set_channel_node, VoiceClient,
|
||||||
},
|
},
|
||||||
Database, User,
|
Database, User,
|
||||||
};
|
};
|
||||||
@@ -60,6 +60,7 @@ pub async fn call(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let existing_node = get_channel_node(channel.id()).await?;
|
let existing_node = get_channel_node(channel.id()).await?;
|
||||||
|
let has_existing_node = existing_node.is_some(); // we move existing_node in the next statement so this is the quickest way to know if we need to set it.
|
||||||
|
|
||||||
let node = existing_node
|
let node = existing_node
|
||||||
.or(node)
|
.or(node)
|
||||||
@@ -86,9 +87,11 @@ pub async fn call(
|
|||||||
|
|
||||||
let channel = Reference::from_unchecked(&channel_id)
|
let channel = Reference::from_unchecked(&channel_id)
|
||||||
.as_channel(db)
|
.as_channel(db)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
delete_voice_state(&channel_id, channel.server(), &user.id).await?;
|
if channel.is_ok() {
|
||||||
|
delete_voice_state(&channel_id, channel.unwrap().server(), &user.id).await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
raise_if_in_voice(&user, channel.id()).await?;
|
raise_if_in_voice(&user, channel.id()).await?;
|
||||||
@@ -100,6 +103,10 @@ pub async fn call(
|
|||||||
|
|
||||||
let room = voice_client.create_room(&node, &channel).await?;
|
let room = voice_client.create_room(&node, &channel).await?;
|
||||||
|
|
||||||
|
if !has_existing_node {
|
||||||
|
set_channel_node(channel.id(), &node).await?;
|
||||||
|
}
|
||||||
|
|
||||||
log::debug!("Created room {}", room.name);
|
log::debug!("Created room {}", room.name);
|
||||||
|
|
||||||
if let Some(recipients) = recipients {
|
if let Some(recipients) = recipients {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
use revolt_config::config;
|
use revolt_config::config;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
@@ -54,6 +55,80 @@ pub struct RevoltFeatures {
|
|||||||
pub january: Feature,
|
pub january: Feature,
|
||||||
/// Voice server configuration
|
/// Voice server configuration
|
||||||
pub livekit: VoiceFeature,
|
pub livekit: VoiceFeature,
|
||||||
|
/// Limits
|
||||||
|
pub limits: LimitsConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// # Limits For Users
|
||||||
|
#[derive(Serialize, JsonSchema, Debug)]
|
||||||
|
pub struct LimitsConfig {
|
||||||
|
/// Global Limits
|
||||||
|
pub global: GlobalLimits,
|
||||||
|
/// New User Limits
|
||||||
|
pub new_user: UserLimits,
|
||||||
|
/// Default User Limits
|
||||||
|
pub default: UserLimits,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// # Global limits
|
||||||
|
#[derive(Serialize, JsonSchema, Debug)]
|
||||||
|
pub struct GlobalLimits {
|
||||||
|
/// max group size
|
||||||
|
group_size: i64,
|
||||||
|
/// max message embeds
|
||||||
|
message_embeds: i64,
|
||||||
|
/// max replies
|
||||||
|
message_replies: i64,
|
||||||
|
/// max reactions per message
|
||||||
|
message_reactions: i64,
|
||||||
|
/// max server emoji
|
||||||
|
server_emoji: i64,
|
||||||
|
/// max server roles
|
||||||
|
server_roles: i64,
|
||||||
|
/// max server channels
|
||||||
|
server_channels: i64,
|
||||||
|
body_limit_size: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// # User Limits
|
||||||
|
#[derive(Serialize, JsonSchema, Debug)]
|
||||||
|
pub struct UserLimits {
|
||||||
|
/// Max Outgoing Friend Requests
|
||||||
|
pub outgoing_friend_requests: i64,
|
||||||
|
/// Max Owned Bots
|
||||||
|
pub bots: i64,
|
||||||
|
/// Max message content length
|
||||||
|
pub message_length: i64,
|
||||||
|
/// max message attachments
|
||||||
|
pub message_attachments: i64,
|
||||||
|
/// max servers
|
||||||
|
pub servers: i64,
|
||||||
|
/// max audio quality
|
||||||
|
pub voice_quality: i64,
|
||||||
|
/// video streaming enabled
|
||||||
|
pub video: bool,
|
||||||
|
/// max video resolution (vertical, horizontal)
|
||||||
|
pub video_resolution: [i64; 2],
|
||||||
|
/// min/max aspect ratios
|
||||||
|
pub video_aspect_ratio: [f64; 2],
|
||||||
|
pub file_upload_size_limits: HashMap<String, usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UserLimits {
|
||||||
|
fn from_feature_limits(fl: revolt_config::FeaturesLimits) -> UserLimits {
|
||||||
|
UserLimits {
|
||||||
|
outgoing_friend_requests: fl.outgoing_friend_requests as i64,
|
||||||
|
bots: fl.bots as i64,
|
||||||
|
message_length: fl.message_length as i64,
|
||||||
|
message_attachments: fl.message_attachments as i64,
|
||||||
|
servers: fl.servers as i64,
|
||||||
|
voice_quality: fl.voice_quality as i64,
|
||||||
|
video: fl.video,
|
||||||
|
video_resolution: [fl.video_resolution[0] as i64, fl.video_resolution[1] as i64],
|
||||||
|
video_aspect_ratio: [fl.video_aspect_ratio[0] as f64, fl.video_aspect_ratio[1] as f64],
|
||||||
|
file_upload_size_limits: fl.file_upload_size_limit,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Build Information
|
/// # Build Information
|
||||||
@@ -134,6 +209,20 @@ pub async fn root() -> Result<Json<RevoltConfig>> {
|
|||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
|
limits: LimitsConfig {
|
||||||
|
global: GlobalLimits {
|
||||||
|
group_size: config.features.limits.global.group_size as i64,
|
||||||
|
message_embeds: config.features.limits.global.message_embeds as i64,
|
||||||
|
message_replies: config.features.limits.global.message_replies as i64,
|
||||||
|
message_reactions: config.features.limits.global.message_reactions as i64,
|
||||||
|
server_emoji: config.features.limits.global.server_emoji as i64,
|
||||||
|
server_roles: config.features.limits.global.server_roles as i64,
|
||||||
|
server_channels: config.features.limits.global.server_channels as i64,
|
||||||
|
body_limit_size: config.features.limits.global.body_limit_size as i64,
|
||||||
|
},
|
||||||
|
new_user: UserLimits::from_feature_limits(config.features.limits.new_user),
|
||||||
|
default: UserLimits::from_feature_limits(config.features.limits.default),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
ws: config.hosts.events,
|
ws: config.hosts.events,
|
||||||
app: config.hosts.app,
|
app: config.hosts.app,
|
||||||
|
|||||||
@@ -29,17 +29,7 @@ pub async fn create_server(
|
|||||||
|
|
||||||
user.can_acquire_server(db).await?;
|
user.can_acquire_server(db).await?;
|
||||||
|
|
||||||
let (server, channels) = if let Some(discord_template_id) = data.discord_template_id.clone() {
|
let (server, channels) = Server::create(db, data, &user, true).await?;
|
||||||
let (mut server, _) = Server::create(db, data, &user, false).await?;
|
|
||||||
|
|
||||||
let template = revolt_discord::template::fetch_template(&discord_template_id).await?;
|
|
||||||
let channels = revolt_discord::template::import_template(db, &mut server, template).await?;
|
|
||||||
|
|
||||||
(server, channels)
|
|
||||||
} else {
|
|
||||||
Server::create(db, data, &user, true).await?
|
|
||||||
};
|
|
||||||
|
|
||||||
let (_, channels) = Member::create(db, &server, &user, Some(channels)).await?;
|
let (_, channels) = Member::create(db, &server, &user, Some(channels)).await?;
|
||||||
|
|
||||||
Ok(Json(v0::CreateServerLegacyResponse {
|
Ok(Json(v0::CreateServerLegacyResponse {
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ use futures::StreamExt;
|
|||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use redis_kiss::redis::aio::PubSub;
|
use redis_kiss::redis::aio::PubSub;
|
||||||
use revolt_database::{
|
use revolt_database::{
|
||||||
events::client::EventV1, Channel, Database, Member, Message, PartialRole, Server, User, AMQP,
|
events::client::EventV1,
|
||||||
|
util::rabbit::{get_channel, set_rabbitmq_connection},
|
||||||
|
Channel, Database, Member, Message, PartialRole, Server, User, AMQP,
|
||||||
};
|
};
|
||||||
use revolt_database::{util::idempotency::IdempotencyKey, Role};
|
use revolt_database::{util::idempotency::IdempotencyKey, Role};
|
||||||
use revolt_models::v0;
|
use revolt_models::v0;
|
||||||
@@ -59,10 +61,16 @@ impl TestHarness {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let channel = connection.open_channel(None).await.unwrap();
|
|
||||||
|
set_rabbitmq_connection(connection.clone());
|
||||||
|
let channel = get_channel().await;
|
||||||
|
|
||||||
let amqp = AMQP::new(connection, channel);
|
let amqp = AMQP::new(connection, channel);
|
||||||
|
|
||||||
|
async_std::task::spawn(async {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
TestHarness {
|
TestHarness {
|
||||||
client,
|
client,
|
||||||
authifier,
|
authifier,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-autumn"
|
name = "revolt-autumn"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
@@ -44,16 +44,16 @@ tracing = "0.1"
|
|||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|
||||||
# Core crates
|
# Core crates
|
||||||
revolt-files = { version = "0.11.3", path = "../../core/files" }
|
revolt-files = { version = "0.11.5", path = "../../core/files" }
|
||||||
revolt-config = { version = "0.11.3", path = "../../core/config" }
|
revolt-config = { version = "0.11.5", path = "../../core/config" }
|
||||||
revolt-database = { version = "0.11.3", path = "../../core/database", features = [
|
revolt-database = { version = "0.11.5", path = "../../core/database", features = [
|
||||||
"axum-impl",
|
"axum-impl",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.11.3", path = "../../core/result", features = [
|
revolt-result = { version = "0.11.5", path = "../../core/result", features = [
|
||||||
"utoipa",
|
"utoipa",
|
||||||
"axum",
|
"axum",
|
||||||
] }
|
] }
|
||||||
revolt-ratelimits = { version = "0.11.3", path = "../../core/ratelimits", features = ["axum"] }
|
revolt-ratelimits = { version = "0.11.5", path = "../../core/ratelimits", features = ["axum"] }
|
||||||
|
|
||||||
# Axum / web server
|
# Axum / web server
|
||||||
tempfile = "3.12.0"
|
tempfile = "3.12.0"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-gifbox"
|
name = "revolt-gifbox"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
@@ -17,19 +17,19 @@ tokio = { version = "1.0", features = ["full"] }
|
|||||||
reqwest = { version = "0.12", features = ["json"] }
|
reqwest = { version = "0.12", features = ["json"] }
|
||||||
|
|
||||||
# Core crates
|
# Core crates
|
||||||
revolt-config = { version = "0.11.3", path = "../../core/config" }
|
revolt-config = { version = "0.11.5", path = "../../core/config" }
|
||||||
revolt-models = { version = "0.11.3", path = "../../core/models" }
|
revolt-models = { version = "0.11.5", path = "../../core/models" }
|
||||||
revolt-result = { version = "0.11.3", path = "../../core/result", features = [
|
revolt-result = { version = "0.11.5", path = "../../core/result", features = [
|
||||||
"utoipa",
|
"utoipa",
|
||||||
"axum",
|
"axum",
|
||||||
] }
|
] }
|
||||||
revolt-coalesced = { version = "0.11.3", path = "../../core/coalesced", features = [
|
revolt-coalesced = { version = "0.11.5", path = "../../core/coalesced", features = [
|
||||||
"queue",
|
"queue",
|
||||||
] }
|
] }
|
||||||
revolt-database = { version = "0.11.3", path = "../../core/database", features = [
|
revolt-database = { version = "0.11.5", path = "../../core/database", features = [
|
||||||
"axum-impl",
|
"axum-impl",
|
||||||
] }
|
] }
|
||||||
revolt-ratelimits = { version = "0.11.3", path = "../../core/ratelimits", features = [
|
revolt-ratelimits = { version = "0.11.5", path = "../../core/ratelimits", features = [
|
||||||
"axum",
|
"axum",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-january"
|
name = "revolt-january"
|
||||||
version = "0.11.3"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
@@ -33,13 +33,13 @@ tracing = "0.1"
|
|||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|
||||||
# Core crates
|
# Core crates
|
||||||
revolt-config = { version = "0.11.3", path = "../../core/config" }
|
revolt-config = { version = "0.11.5", path = "../../core/config" }
|
||||||
revolt-models = { version = "0.11.3", path = "../../core/models" }
|
revolt-models = { version = "0.11.5", path = "../../core/models" }
|
||||||
revolt-result = { version = "0.11.3", path = "../../core/result", features = [
|
revolt-result = { version = "0.11.5", path = "../../core/result", features = [
|
||||||
"utoipa",
|
"utoipa",
|
||||||
"axum",
|
"axum",
|
||||||
] }
|
] }
|
||||||
revolt-files = { version = "0.11.3", path = "../../core/files" }
|
revolt-files = { version = "0.11.5", path = "../../core/files" }
|
||||||
|
|
||||||
# Axum / web server
|
# Axum / web server
|
||||||
axum = { version = "0.7.5" }
|
axum = { version = "0.7.5" }
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
0.11.3
|
0.11.5
|
||||||
|
|||||||
Reference in New Issue
Block a user