mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
18 lines
559 B
Rust
18 lines
559 B
Rust
|
//! # Friends helper
|
||
|
//!
|
||
|
//! @author Pierre Hubert
|
||
|
|
||
|
|
||
|
use crate::data::user::UserID;
|
||
|
use crate::data::error::ResultBoxError;
|
||
|
use crate::helpers::database;
|
||
|
use crate::constants::database_tables_names::FRIENDS_TABLE;
|
||
|
use crate::helpers::database::QueryInfo;
|
||
|
|
||
|
/// Check out whether two users are friend or not
|
||
|
pub fn are_friend(user_one: UserID, user_two: UserID) -> ResultBoxError<bool> {
|
||
|
Ok(database::count(QueryInfo::new(FRIENDS_TABLE)
|
||
|
.cond_i64("ID_personne", user_one)
|
||
|
.cond_i64("ID_amis", user_two)
|
||
|
.cond_i64("actif", 1))? > 0)
|
||
|
}
|