add: user follows, user blocks, ip bans
TODO: implement user following API endpoints TODO: implement user blocking API endpoints TODO: don't allow blocked users to interact with the users who blocked them
This commit is contained in:
parent
81005a6e1c
commit
559ce19932
25 changed files with 628 additions and 127 deletions
|
@ -19,6 +19,9 @@ pub struct User {
|
|||
pub settings: UserSettings,
|
||||
pub tokens: Vec<Token>,
|
||||
pub permissions: FinePermission,
|
||||
pub notification_count: usize,
|
||||
pub follower_count: usize,
|
||||
pub following_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
@ -48,6 +51,9 @@ impl User {
|
|||
settings: UserSettings::default(),
|
||||
tokens: Vec::new(),
|
||||
permissions: FinePermission::DEFAULT,
|
||||
notification_count: 0,
|
||||
follower_count: 0,
|
||||
following_count: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,3 +103,69 @@ impl Notification {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct UserFollow {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
pub initiator: usize,
|
||||
pub receiver: usize,
|
||||
}
|
||||
|
||||
impl UserFollow {
|
||||
/// Create a new [`UserFollow`].
|
||||
pub fn new(initiator: usize, receiver: usize) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
initiator,
|
||||
receiver,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct UserBlock {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
pub initiator: usize,
|
||||
pub receiver: usize,
|
||||
}
|
||||
|
||||
impl UserBlock {
|
||||
/// Create a new [`UserBlock`].
|
||||
pub fn new(initiator: usize, receiver: usize) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
initiator,
|
||||
receiver,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct IpBan {
|
||||
pub ip: String,
|
||||
pub created: usize,
|
||||
pub reason: String,
|
||||
pub moderator: usize,
|
||||
}
|
||||
|
||||
impl IpBan {
|
||||
/// Create a new [`IpBan`].
|
||||
pub fn new(ip: String, moderator: usize, reason: String) -> Self {
|
||||
Self {
|
||||
ip,
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
reason,
|
||||
moderator,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue