Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f96541efab | ||
|
|
c6414338b6 | ||
|
|
4c4eb60cdb | ||
|
|
11d89b3bf0 | ||
|
|
64bb171cc8 | ||
|
|
6de5ad15c5 | ||
|
|
b5ab16d66f | ||
|
|
b9aad6d38c |
Generated
+2
-2
@@ -2505,7 +2505,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rauth"
|
name = "rauth"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "git+https://github.com/insertish/rauth?rev=ac61714935e3327c07bb0338a01aeec0318f9a96#ac61714935e3327c07bb0338a01aeec0318f9a96"
|
source = "git+https://github.com/insertish/rauth?rev=ab7cc5a9739f1147375d3a559250f4be2a051565#ab7cc5a9739f1147375d3a559250f4be2a051565"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -2986,7 +2986,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket_rauth"
|
name = "rocket_rauth"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "git+https://github.com/insertish/rauth?rev=ac61714935e3327c07bb0338a01aeec0318f9a96#ac61714935e3327c07bb0338a01aeec0318f9a96"
|
source = "git+https://github.com/insertish/rauth?rev=ab7cc5a9739f1147375d3a559250f4be2a051565#ab7cc5a9739f1147375d3a559250f4be2a051565"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"okapi",
|
"okapi",
|
||||||
"rauth",
|
"rauth",
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ mobc-redis = { version = "0.7.0", default-features = false, features = ["async-s
|
|||||||
# web
|
# web
|
||||||
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
||||||
rocket_empty = { git = "https://github.com/insertish/rocket_empty", branch = "master" }
|
rocket_empty = { git = "https://github.com/insertish/rocket_empty", branch = "master" }
|
||||||
rocket_rauth = { git = "https://github.com/insertish/rauth", rev = "ac61714935e3327c07bb0338a01aeec0318f9a96" }
|
rocket_rauth = { git = "https://github.com/insertish/rauth", rev = "ab7cc5a9739f1147375d3a559250f4be2a051565" }
|
||||||
|
|
||||||
# spec generation
|
# spec generation
|
||||||
schemars = "0.8.8"
|
schemars = "0.8.8"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ pub struct DataMessageSend {
|
|||||||
/// Unique token to prevent duplicate message sending
|
/// Unique token to prevent duplicate message sending
|
||||||
///
|
///
|
||||||
/// **This is deprecated and replaced by `Idempotency-Key`!**
|
/// **This is deprecated and replaced by `Idempotency-Key`!**
|
||||||
|
#[validate(length(min = 1, max = 64))]
|
||||||
nonce: Option<String>,
|
nonce: Option<String>,
|
||||||
|
|
||||||
/// Message content to send
|
/// Message content to send
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ rocket_empty = { optional = true, git = "https://github.com/insertish/rocket_emp
|
|||||||
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "5843861a88958c16bfaa0b40f0d8910772bcd2f6" }
|
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "5843861a88958c16bfaa0b40f0d8910772bcd2f6" }
|
||||||
|
|
||||||
# rAuth
|
# rAuth
|
||||||
rauth = { git = "https://github.com/insertish/rauth", rev = "ac61714935e3327c07bb0338a01aeec0318f9a96", features = [ "async-std-runtime" ] }
|
rauth = { git = "https://github.com/insertish/rauth", rev = "ab7cc5a9739f1147375d3a559250f4be2a051565", features = [ "async-std-runtime" ] }
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
sentry = "0.25.0"
|
sentry = "0.25.0"
|
||||||
|
|||||||
@@ -242,7 +242,12 @@ impl Channel {
|
|||||||
/// Add user to a group
|
/// Add user to a group
|
||||||
pub async fn add_user_to_group(&mut self, db: &Database, user: &str, by: &str) -> Result<()> {
|
pub async fn add_user_to_group(&mut self, db: &Database, user: &str, by: &str) -> Result<()> {
|
||||||
if let Channel::Group { recipients, .. } = self {
|
if let Channel::Group { recipients, .. } = self {
|
||||||
recipients.push(user.to_string());
|
let user = user.to_string();
|
||||||
|
if recipients.contains(&user) {
|
||||||
|
return Err(Error::AlreadyInGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
recipients.push(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
match &self {
|
match &self {
|
||||||
|
|||||||
@@ -37,30 +37,46 @@ impl AbstractChannelUnread for MongoDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn acknowledge_channels(&self, user: &str, channels: &[String]) -> Result<()> {
|
async fn acknowledge_channels(&self, user: &str, channels: &[String]) -> Result<()> {
|
||||||
|
let current_time = Ulid::new().to_string();
|
||||||
|
|
||||||
self.col::<Document>(COL)
|
self.col::<Document>(COL)
|
||||||
.update_one(
|
.delete_many(
|
||||||
doc! {
|
doc! {
|
||||||
"_id.channel": {
|
"_id.channel": {
|
||||||
"$in": channels
|
"$in": channels
|
||||||
},
|
},
|
||||||
"_id.user": user,
|
"_id.user": user
|
||||||
},
|
},
|
||||||
doc! {
|
None,
|
||||||
"$unset": {
|
|
||||||
"mentions": 1_i32
|
|
||||||
},
|
|
||||||
"$set": {
|
|
||||||
"last_id": Ulid::new().to_string()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
UpdateOptions::builder().upsert(true).build(),
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|_| Error::DatabaseError {
|
.map_err(|_| Error::DatabaseError {
|
||||||
operation: "update",
|
operation: "delete_many",
|
||||||
with: "channel_unread",
|
with: "channel_unreads",
|
||||||
|
})?;
|
||||||
|
|
||||||
|
self.col::<Document>(COL)
|
||||||
|
.insert_many(
|
||||||
|
channels
|
||||||
|
.iter()
|
||||||
|
.map(|channel| {
|
||||||
|
doc! {
|
||||||
|
"_id": {
|
||||||
|
"channel": channel,
|
||||||
|
"user": user
|
||||||
|
},
|
||||||
|
"last_id": ¤t_time
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<Document>>(),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|_| Error::DatabaseError {
|
||||||
|
operation: "update_many",
|
||||||
|
with: "channel_unreads",
|
||||||
})
|
})
|
||||||
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn add_mention_to_unread<'a>(
|
async fn add_mention_to_unread<'a>(
|
||||||
|
|||||||
Reference in New Issue
Block a user