fix: no more id collisions
This commit is contained in:
parent
71d017693c
commit
0b3573a513
11 changed files with 151 additions and 120 deletions
|
@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
|||
use totp_rs::TOTP;
|
||||
use tetratto_shared::{
|
||||
hash::{hash_salted, salt},
|
||||
snow::AlmostSnowflake,
|
||||
snow::Snowflake,
|
||||
unix_epoch_timestamp,
|
||||
};
|
||||
|
||||
|
@ -227,10 +227,7 @@ impl User {
|
|||
let password = hash_salted(password, salt.clone());
|
||||
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
username,
|
||||
password,
|
||||
|
@ -408,10 +405,7 @@ impl Notification {
|
|||
/// Returns a new [`Notification`].
|
||||
pub fn new(title: String, content: String, owner: usize) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
title,
|
||||
content,
|
||||
|
@ -434,10 +428,7 @@ impl UserFollow {
|
|||
/// Create a new [`UserFollow`].
|
||||
pub fn new(initiator: usize, receiver: usize) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
initiator,
|
||||
receiver,
|
||||
|
@ -465,10 +456,7 @@ impl UserBlock {
|
|||
/// Create a new [`UserBlock`].
|
||||
pub fn new(initiator: usize, receiver: usize) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
initiator,
|
||||
receiver,
|
||||
|
@ -488,10 +476,7 @@ impl IpBlock {
|
|||
/// Create a new [`IpBlock`].
|
||||
pub fn new(initiator: usize, receiver: String) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
initiator,
|
||||
receiver,
|
||||
|
@ -532,10 +517,7 @@ impl UserWarning {
|
|||
/// Create a new [`UserWarning`].
|
||||
pub fn new(user: usize, moderator: usize, content: String) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
receiver: user,
|
||||
moderator,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue