use single global function for server name local and user local checking
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
8f17d965b2
commit
9931e60050
14 changed files with 77 additions and 41 deletions
|
@ -1,6 +1,8 @@
|
|||
pub(crate) mod clap;
|
||||
pub(crate) mod debug;
|
||||
pub(crate) mod error;
|
||||
pub(crate) mod server_name;
|
||||
pub(crate) mod user_id;
|
||||
|
||||
use std::{
|
||||
cmp,
|
||||
|
|
8
src/utils/server_name.rs
Normal file
8
src/utils/server_name.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
//! utilities for doing/checking things with ServerName's/server_name's
|
||||
|
||||
use ruma::ServerName;
|
||||
|
||||
use crate::services;
|
||||
|
||||
/// checks if `server_name` is ours
|
||||
pub(crate) fn server_is_ours(server_name: &ServerName) -> bool { server_name == services().globals.config.server_name }
|
8
src/utils/user_id.rs
Normal file
8
src/utils/user_id.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
//! utilities for doing things with UserId's / usernames
|
||||
|
||||
use ruma::UserId;
|
||||
|
||||
use crate::services;
|
||||
|
||||
/// checks if `user_id` is local to us via server_name comparison
|
||||
pub(crate) fn user_is_local(user_id: &UserId) -> bool { user_id.server_name() == services().globals.config.server_name }
|
Loading…
Add table
Add a link
Reference in a new issue