mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
Fix: Use channel_invites collection name instead of invites.
Was conflicting with invite-only rauth registrations.
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
export version=0.5.0-alpha.0
|
||||
export version=0.5.0-alpha.0-patch.0
|
||||
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs
|
||||
|
||||
@@ -116,7 +116,7 @@ impl Channel {
|
||||
let messages = get_collection("messages");
|
||||
|
||||
// Delete any invites.
|
||||
get_collection("invites")
|
||||
get_collection("channel_invites")
|
||||
.delete_many(
|
||||
doc! {
|
||||
"channel": id
|
||||
@@ -126,7 +126,7 @@ impl Channel {
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "delete_many",
|
||||
with: "invites",
|
||||
with: "channel_invites",
|
||||
})?;
|
||||
|
||||
// Check if there are any attachments we need to delete.
|
||||
|
||||
@@ -44,7 +44,7 @@ impl Invite {
|
||||
}
|
||||
|
||||
pub async fn get(code: &str) -> Result<Invite> {
|
||||
let doc = get_collection("invites")
|
||||
let doc = get_collection("channel_invites")
|
||||
.find_one(doc! { "_id": code }, None)
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
@@ -60,7 +60,7 @@ impl Invite {
|
||||
}
|
||||
|
||||
pub async fn save(self) -> Result<()> {
|
||||
get_collection("invites")
|
||||
get_collection("channel_invites")
|
||||
.insert_one(
|
||||
to_document(&self).map_err(|_| Error::DatabaseError {
|
||||
operation: "to_bson",
|
||||
@@ -78,7 +78,7 @@ impl Invite {
|
||||
}
|
||||
|
||||
pub async fn delete(&self) -> Result<()> {
|
||||
get_collection("invites")
|
||||
get_collection("channel_invites")
|
||||
.delete_one(
|
||||
doc! {
|
||||
"_id": self.code()
|
||||
|
||||
@@ -165,7 +165,7 @@ impl Server {
|
||||
})?;
|
||||
|
||||
// Delete all channels, members, bans and invites.
|
||||
for with in &["channels", "invites"] {
|
||||
for with in &["channels", "channel_invites"] {
|
||||
get_collection(with)
|
||||
.delete_many(
|
||||
doc! {
|
||||
|
||||
@@ -59,7 +59,7 @@ impl Ref {
|
||||
}
|
||||
|
||||
pub async fn fetch_invite(&self) -> Result<Invite> {
|
||||
self.fetch("invites").await
|
||||
self.fetch("channel_invites").await
|
||||
}
|
||||
|
||||
pub async fn fetch_member(&self, server: &str) -> Result<Member> {
|
||||
|
||||
@@ -37,9 +37,9 @@ pub async fn create_database() {
|
||||
.await
|
||||
.expect("Failed to create server_bans collection.");
|
||||
|
||||
db.create_collection("invites", None)
|
||||
db.create_collection("channel_invites", None)
|
||||
.await
|
||||
.expect("Failed to create invites collection.");
|
||||
.expect("Failed to create channel_invites collection.");
|
||||
|
||||
db.create_collection("migrations", None)
|
||||
.await
|
||||
|
||||
@@ -152,9 +152,9 @@ pub async fn run_migrations(revision: i32) -> i32 {
|
||||
.expect("Failed to create server_bans collection.");
|
||||
|
||||
get_db()
|
||||
.create_collection("invites", None)
|
||||
.create_collection("channel_invites", None)
|
||||
.await
|
||||
.expect("Failed to create invites collection.");
|
||||
.expect("Failed to create channel_invites collection.");
|
||||
}
|
||||
|
||||
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||
|
||||
@@ -27,7 +27,7 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
Err(Error::MissingPermission)?
|
||||
}
|
||||
|
||||
let mut cursor = get_collection("invites")
|
||||
let mut cursor = get_collection("channel_invites")
|
||||
.find(
|
||||
doc! {
|
||||
"server": target.id
|
||||
@@ -37,7 +37,7 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "find",
|
||||
with: "invites",
|
||||
with: "channel_invites",
|
||||
})?;
|
||||
|
||||
let mut invites = vec![];
|
||||
|
||||
@@ -1 +1 @@
|
||||
pub const VERSION: &str = "0.5.0-alpha.0";
|
||||
pub const VERSION: &str = "0.5.0-alpha.0-patch.0";
|
||||
|
||||
Reference in New Issue
Block a user