mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-08-31 02:22:29 +00:00
@@ -542,7 +542,7 @@ impl User {
|
||||
pub async fn add_friend(
|
||||
&mut self,
|
||||
db: &Database,
|
||||
amqp: Option<&AMQP>,
|
||||
amqp: &AMQP,
|
||||
target: &mut User,
|
||||
) -> Result<()> {
|
||||
match self.relationship_with(&target.id) {
|
||||
@@ -552,10 +552,8 @@ impl User {
|
||||
RelationshipStatus::Blocked => Err(create_error!(Blocked)),
|
||||
RelationshipStatus::BlockedOther => Err(create_error!(BlockedByOther)),
|
||||
RelationshipStatus::Incoming => {
|
||||
if let Some(amqp) = amqp {
|
||||
// Accept incoming friend request
|
||||
_ = amqp.friend_request_accepted(self, target).await;
|
||||
};
|
||||
// Accept incoming friend request
|
||||
_ = amqp.friend_request_accepted(self, target).await;
|
||||
|
||||
self.apply_relationship(
|
||||
db,
|
||||
@@ -585,9 +583,7 @@ impl User {
|
||||
}));
|
||||
}
|
||||
|
||||
if let Some(amqp) = amqp {
|
||||
_ = amqp.friend_request_received(target, self).await;
|
||||
};
|
||||
_ = amqp.friend_request_received(target, self).await;
|
||||
|
||||
// Send the friend request
|
||||
self.apply_relationship(
|
||||
|
||||
@@ -255,6 +255,7 @@ pub async fn ingress(
|
||||
message
|
||||
.update(
|
||||
db,
|
||||
Some(amqp),
|
||||
PartialMessage {
|
||||
system: message.system.clone(),
|
||||
..Default::default()
|
||||
|
||||
@@ -22,6 +22,6 @@ pub async fn add(
|
||||
return Err(create_error!(IsBot));
|
||||
}
|
||||
|
||||
user.add_friend(db, Some(amqp), &mut target).await?;
|
||||
user.add_friend(db, amqp, &mut target).await?;
|
||||
Ok(Json(target.into(db, &user).await))
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ pub async fn send_friend_request(
|
||||
return Err(create_error!(IsBot));
|
||||
}
|
||||
|
||||
user.add_friend(db, Some(amqp), &mut target).await?;
|
||||
user.add_friend(db, amqp, &mut target).await?;
|
||||
Ok(Json(target.into(db, &user).await))
|
||||
} else {
|
||||
Err(create_error!(InvalidProperty))
|
||||
|
||||
Reference in New Issue
Block a user