Remove sbot module prefix from functions within the module #3

Merged
glyph merged 1 commits from sbot_module_cleanup into main 2022-08-23 07:36:40 +00:00

View File

@ -13,15 +13,14 @@ use golgi::{
use log::{debug, info, warn}; use log::{debug, info, warn};
use serde_json::value::Value; 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 /// Check the follow status of a remote peer and follow them if not already
/// following. /// following.
pub async fn follow_if_not_following(remote_peer: &str) -> Result<(), String> { pub async fn follow_if_not_following(remote_peer: &str) -> Result<(), String> {
if let Ok(whoami) = sbot::whoami().await { if let Ok(whoami) = whoami().await {
match sbot::is_following(&whoami, remote_peer).await { match is_following(&whoami, remote_peer).await {
Ok(status) if status.as_str() == "false" => { Ok(status) if status.as_str() == "false" => match follow_peer(remote_peer).await {
match sbot::follow_peer(remote_peer).await {
Ok(_) => { Ok(_) => {
info!("Followed peer {}", &remote_peer); info!("Followed peer {}", &remote_peer);
Ok(()) Ok(())
@ -31,8 +30,7 @@ pub async fn follow_if_not_following(remote_peer: &str) -> Result<(), String> {
warn!("{}", err_msg); warn!("{}", err_msg);
Err(err_msg) Err(err_msg)
} }
} },
}
Ok(status) if status.as_str() == "true" => { Ok(status) if status.as_str() == "true" => {
info!( info!(
"Already following peer {}. No further action taken", "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 /// Check the follow status of a remote peer and unfollow them if already
/// following. /// following.
pub async fn unfollow_if_following(remote_peer: &str) -> Result<(), String> { pub async fn unfollow_if_following(remote_peer: &str) -> Result<(), String> {
if let Ok(whoami) = sbot::whoami().await { if let Ok(whoami) = whoami().await {
match sbot::is_following(&whoami, remote_peer).await { match is_following(&whoami, remote_peer).await {
Ok(status) if status.as_str() == "true" => { Ok(status) if status.as_str() == "true" => {
info!("Unfollowing peer {}", &remote_peer); info!("Unfollowing peer {}", &remote_peer);
match sbot::unfollow_peer(remote_peer).await { match unfollow_peer(remote_peer).await {
Ok(_) => { Ok(_) => {
info!("Unfollowed peer {}", &remote_peer); info!("Unfollowed peer {}", &remote_peer);
Ok(()) Ok(())