forked from jmug/stoatchat
Fix import and cargo fmt
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use crate::{notifications::{events::ClientboundNotification, hive}, util::result::Result};
|
||||
use crate::{
|
||||
database::{
|
||||
entities::{RelationshipStatus, User},
|
||||
@@ -8,6 +7,10 @@ use crate::{
|
||||
},
|
||||
util::result::Error,
|
||||
};
|
||||
use crate::{
|
||||
notifications::{events::ClientboundNotification, hive},
|
||||
util::result::Result,
|
||||
};
|
||||
use futures::try_join;
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
@@ -55,16 +58,19 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
id: user.id.clone(),
|
||||
user: target.id.clone(),
|
||||
status: RelationshipStatus::Friend
|
||||
}.publish(user.id.clone()),
|
||||
}
|
||||
.publish(user.id.clone()),
|
||||
ClientboundNotification::UserRelationship {
|
||||
id: target.id.clone(),
|
||||
user: user.id.clone(),
|
||||
status: RelationshipStatus::Friend
|
||||
}.publish(target.id.clone())
|
||||
).ok();
|
||||
}
|
||||
.publish(target.id.clone())
|
||||
)
|
||||
.ok();
|
||||
|
||||
Ok(json!({ "status": "Friend" }))
|
||||
},
|
||||
}
|
||||
Err(_) => Err(Error::DatabaseError {
|
||||
operation: "update_one",
|
||||
with: "user",
|
||||
@@ -108,19 +114,22 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
id: user.id.clone(),
|
||||
user: target.id.clone(),
|
||||
status: RelationshipStatus::Outgoing
|
||||
}.publish(user.id.clone()),
|
||||
}
|
||||
.publish(user.id.clone()),
|
||||
ClientboundNotification::UserRelationship {
|
||||
id: target.id.clone(),
|
||||
user: user.id.clone(),
|
||||
status: RelationshipStatus::Incoming
|
||||
}.publish(target.id.clone())
|
||||
).ok();
|
||||
}
|
||||
.publish(target.id.clone())
|
||||
)
|
||||
.ok();
|
||||
|
||||
hive::subscribe_if_exists(user.id.clone(), target.id.clone()).ok();
|
||||
hive::subscribe_if_exists(target.id.clone(), user.id.clone()).ok();
|
||||
|
||||
Ok(json!({ "status": "Outgoing" }))
|
||||
},
|
||||
}
|
||||
Err(_) => Err(Error::DatabaseError {
|
||||
operation: "update_one",
|
||||
with: "user",
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
use crate::{notifications::{events::ClientboundNotification, hive}, util::result::Result};
|
||||
use crate::{
|
||||
database::entities::RelationshipStatus, database::entities::User, database::get_collection,
|
||||
database::guards::reference::Ref, database::permissions::get_relationship, util::result::Error,
|
||||
};
|
||||
use crate::{
|
||||
notifications::{events::ClientboundNotification, hive},
|
||||
util::result::Result,
|
||||
};
|
||||
use futures::try_join;
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
@@ -35,8 +38,11 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
ClientboundNotification::UserRelationship {
|
||||
id: user.id.clone(),
|
||||
user: target.id.clone(),
|
||||
status: RelationshipStatus::Blocked
|
||||
}.publish(user.id.clone()).await.ok();
|
||||
status: RelationshipStatus::Blocked,
|
||||
}
|
||||
.publish(user.id.clone())
|
||||
.await
|
||||
.ok();
|
||||
|
||||
Ok(json!({ "status": "Blocked" }))
|
||||
}
|
||||
@@ -77,19 +83,22 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
id: user.id.clone(),
|
||||
user: target.id.clone(),
|
||||
status: RelationshipStatus::Blocked
|
||||
}.publish(user.id.clone()),
|
||||
}
|
||||
.publish(user.id.clone()),
|
||||
ClientboundNotification::UserRelationship {
|
||||
id: target.id.clone(),
|
||||
user: user.id.clone(),
|
||||
status: RelationshipStatus::BlockedOther
|
||||
}.publish(target.id.clone())
|
||||
).ok();
|
||||
}
|
||||
.publish(target.id.clone())
|
||||
)
|
||||
.ok();
|
||||
|
||||
hive::subscribe_if_exists(user.id.clone(), target.id.clone()).ok();
|
||||
hive::subscribe_if_exists(target.id.clone(), user.id.clone()).ok();
|
||||
|
||||
Ok(json!({ "status": "Blocked" }))
|
||||
},
|
||||
}
|
||||
Err(_) => Err(Error::DatabaseError {
|
||||
operation: "update_one",
|
||||
with: "user",
|
||||
@@ -131,16 +140,19 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
id: user.id.clone(),
|
||||
user: target.id.clone(),
|
||||
status: RelationshipStatus::Blocked
|
||||
}.publish(user.id.clone()),
|
||||
}
|
||||
.publish(user.id.clone()),
|
||||
ClientboundNotification::UserRelationship {
|
||||
id: target.id.clone(),
|
||||
user: user.id.clone(),
|
||||
status: RelationshipStatus::BlockedOther
|
||||
}.publish(target.id.clone())
|
||||
).ok();
|
||||
|
||||
}
|
||||
.publish(target.id.clone())
|
||||
)
|
||||
.ok();
|
||||
|
||||
Ok(json!({ "status": "Blocked" }))
|
||||
},
|
||||
}
|
||||
Err(_) => Err(Error::DatabaseError {
|
||||
operation: "update_one",
|
||||
with: "user",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::database::entities::{Channel, User};
|
||||
use crate::database::entities::User;
|
||||
use crate::database::get_collection;
|
||||
use crate::util::result::{Error, Result};
|
||||
use futures::StreamExt;
|
||||
use mongodb::bson::{doc, from_bson, Bson};
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
|
||||
#[get("/dms")]
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
use crate::{notifications::{hive, events::ClientboundNotification}, util::result::Result};
|
||||
use crate::{
|
||||
database::entities::RelationshipStatus, database::entities::User, database::get_collection,
|
||||
database::guards::reference::Ref, database::permissions::get_relationship, util::result::Error,
|
||||
};
|
||||
use crate::{
|
||||
notifications::{events::ClientboundNotification, hive},
|
||||
util::result::Result,
|
||||
};
|
||||
use futures::try_join;
|
||||
use hive_pubsub::PubSub;
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use hive_pubsub::PubSub;
|
||||
|
||||
#[delete("/<target>/friend")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
@@ -54,20 +57,23 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
id: user.id.clone(),
|
||||
user: target.id.clone(),
|
||||
status: RelationshipStatus::None
|
||||
}.publish(user.id.clone()),
|
||||
}
|
||||
.publish(user.id.clone()),
|
||||
ClientboundNotification::UserRelationship {
|
||||
id: target.id.clone(),
|
||||
user: user.id.clone(),
|
||||
status: RelationshipStatus::None
|
||||
}.publish(target.id.clone())
|
||||
).ok();
|
||||
|
||||
}
|
||||
.publish(target.id.clone())
|
||||
)
|
||||
.ok();
|
||||
|
||||
let hive = hive::get_hive();
|
||||
hive.unsubscribe(&user.id, &target.id).ok();
|
||||
hive.unsubscribe(&target.id, &user.id).ok();
|
||||
|
||||
|
||||
Ok(json!({ "status": "None" }))
|
||||
},
|
||||
}
|
||||
Err(_) => Err(Error::DatabaseError {
|
||||
operation: "update_one",
|
||||
with: "user",
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
use crate::{notifications::{events::ClientboundNotification, hive}, util::result::Result};
|
||||
use crate::{
|
||||
database::entities::RelationshipStatus, database::entities::User, database::get_collection,
|
||||
database::guards::reference::Ref, database::permissions::get_relationship, util::result::Error,
|
||||
};
|
||||
use crate::{
|
||||
notifications::{events::ClientboundNotification, hive},
|
||||
util::result::Result,
|
||||
};
|
||||
use futures::try_join;
|
||||
use hive_pubsub::PubSub;
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
|
||||
@@ -42,8 +46,11 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
ClientboundNotification::UserRelationship {
|
||||
id: user.id.clone(),
|
||||
user: target.id.clone(),
|
||||
status: RelationshipStatus::BlockedOther
|
||||
}.publish(user.id.clone()).await.ok();
|
||||
status: RelationshipStatus::BlockedOther,
|
||||
}
|
||||
.publish(user.id.clone())
|
||||
.await
|
||||
.ok();
|
||||
|
||||
Ok(json!({ "status": "BlockedOther" }))
|
||||
}
|
||||
@@ -82,20 +89,23 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
id: user.id.clone(),
|
||||
user: target.id.clone(),
|
||||
status: RelationshipStatus::None
|
||||
}.publish(user.id.clone()),
|
||||
}
|
||||
.publish(user.id.clone()),
|
||||
ClientboundNotification::UserRelationship {
|
||||
id: target.id.clone(),
|
||||
user: user.id.clone(),
|
||||
status: RelationshipStatus::None
|
||||
}.publish(target.id.clone())
|
||||
).ok();
|
||||
|
||||
}
|
||||
.publish(target.id.clone())
|
||||
)
|
||||
.ok();
|
||||
|
||||
let hive = hive::get_hive();
|
||||
hive.unsubscribe(&user.id, &target.id).ok();
|
||||
hive.unsubscribe(&target.id, &user.id).ok();
|
||||
|
||||
|
||||
Ok(json!({ "status": "None" }))
|
||||
},
|
||||
}
|
||||
Err(_) => Err(Error::DatabaseError {
|
||||
operation: "update_one",
|
||||
with: "user",
|
||||
|
||||
Reference in New Issue
Block a user