no need to call functions using module prefix

This commit is contained in:
glyph 2022-08-23 08:35:20 +01:00
parent fcce647711
commit 21d0c4b6ab
1 changed files with 16 additions and 18 deletions

View File

@ -13,26 +13,24 @@ use golgi::{
use log::{debug, info, warn};
use serde_json::value::Value;
use crate::{db::Post, sbot};
use crate::db::Post;
/// Check the follow status of a remote peer and follow them if not already
/// following.
pub async fn follow_if_not_following(remote_peer: &str) -> Result<(), String> {
if let Ok(whoami) = sbot::whoami().await {
match sbot::is_following(&whoami, remote_peer).await {
Ok(status) if status.as_str() == "false" => {
match sbot::follow_peer(remote_peer).await {
Ok(_) => {
info!("Followed peer {}", &remote_peer);
Ok(())
}
Err(e) => {
let err_msg = format!("Failed to follow peer {}: {}", &remote_peer, e);
warn!("{}", err_msg);
Err(err_msg)
}
if let Ok(whoami) = whoami().await {
match is_following(&whoami, remote_peer).await {
Ok(status) if status.as_str() == "false" => match follow_peer(remote_peer).await {
Ok(_) => {
info!("Followed peer {}", &remote_peer);
Ok(())
}
}
Err(e) => {
let err_msg = format!("Failed to follow peer {}: {}", &remote_peer, e);
warn!("{}", err_msg);
Err(err_msg)
}
},
Ok(status) if status.as_str() == "true" => {
info!(
"Already following peer {}. No further action taken",
@ -55,11 +53,11 @@ pub async fn follow_if_not_following(remote_peer: &str) -> Result<(), String> {
/// Check the follow status of a remote peer and unfollow them if already
/// following.
pub async fn unfollow_if_following(remote_peer: &str) -> Result<(), String> {
if let Ok(whoami) = sbot::whoami().await {
match sbot::is_following(&whoami, remote_peer).await {
if let Ok(whoami) = whoami().await {
match is_following(&whoami, remote_peer).await {
Ok(status) if status.as_str() == "true" => {
info!("Unfollowing peer {}", &remote_peer);
match sbot::unfollow_peer(remote_peer).await {
match unfollow_peer(remote_peer).await {
Ok(_) => {
info!("Unfollowed peer {}", &remote_peer);
Ok(())